Skip to content

Improve documentation and add Ansible playbook to automate building p… #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 44 additions & 38 deletions doc/BUILDING.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
# Building

## CMake
Install CMake > 3.20.

- Build commands:
```bash
cmake -DCMAKE_BUILD_TYPE=Debug -S . -B $BUILD_DIR
cmake --build $BUILD_DIR
```

- Test commands:
```bash
cmake --build $BUILD_DIR -t test
```

- Install command:
```bash
cmake --install $BUILD_DIR --prefix $INSTALL_DIR --component geds
```

## Docker

`build-docker.sh` builds a docker container with GRPC and a build of GEDS in `/usr/local/opt/geds`.

## Dependencies

### MacOS
# Building GEDS

- [Workflow](#workflow)
- [Instructions for MacOS](#instructions-for-macos)
- [Instructions for Linux](#instructions-for-linux)
- [Deploying via Docker](#deploying-via-docker)
- [Deploying via Ansible](#deploying-via-ansible)

## Workflow <a name="workflow"></a>
The general workflow of building GEDS from source is:
1. Pull GEDS repository: `git pull https://github.com/IBM/GEDS.git`
2. Install dependencies, e.g. `cmake` version > 3.20 (check via `cmake --version`)
3. Create `build` and `install` directory in the GEDS folder and set environment variables: `export $BUILD_DIR=~/GEDS/build` & `export $INSTALL_DIR=~/GEDS/bin`
4. Build Boost
5. Build AWS SDK
6. Build GEDS
7. Install GEDS

## Instructions for MacOS <a name="instructions-for-macos"></a>

Install the following dependencies through homebrew:

Expand Down Expand Up @@ -54,23 +45,38 @@ Finally build it with:
cmake --build . --target all
```

### Linux

Install the following dependencies:
## Instructions for Linux <a name="instructions-for-linux"></a>
Install GEDS dependencies:

```
apt-get install -y \
clang \
curl wget \
build-essential gcc ninja-build \
openjdk-11-jdk \
python3.9 python3.9-dev python3-distutils
sudo apt install -y clang curl wget build-essential gcc ninja-build openjdk-11-jdk python3-dev python3-distutils cmake
```

and a recent version (>= 3.20) of CMake:
CMake version >= 3.20:
```
CMAKE_VERSION=3.22.4
wget --quiet -O cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz \
&& tar xf cmake.tar.gz --strip-components=1 -C /usr/local/ \
&& rm cmake.tar.gz
```

Install AWS SDK dependecies:
```
sudo apt install libcurl4-openssl-dev libssl-de uuid-dev zlib1g-dev libpulse-dev
```

Build AWS SDK: `/bin/bash build-aws-sdk.sh`

Build Boost: `/bin/bash build-boost.sh`

Build GEDS:
1. Check if environment variables are correctly set via `printenv | grep BUILD_DIR` and `printenv | grep INSTALL_DIR`
2. `cmake -DCMAKE_BUILD_TYPE=Debug -S . -B $BUILD_DIR`
3. `cmake --build $BUILD_DIR -j 4` (-j specifies the number of cores to use)
4. `cmake --install $BUILD_DIR --prefix $INSTALL_DIR --component geds`

## Deploying via Docker <a name="deploying-via-docker"></a>
`build-docker.sh` builds a docker container with GRPC and a build of GEDS in `/usr/local/opt/geds`.

## Deploying via Ansible <a name="deploying-via-ansible"></a>
We offer an Ansible playbook to automate GEDS building from source on multiple clients.
123 changes: 123 additions & 0 deletions doc/geds_ansible.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
---
- hosts: geds
name: Update all apt packages
become: false
vars:
ansible_python_interpreter: /usr/bin/python3
remote_home: "{{ ansible_env.HOME }}"

tasks:
- name: Update and upgrade
tags: update
become: true
apt:
upgrade: yes
update_cache: yes

- name: Reboot
tags: reboot
become: true
reboot:

- name: Install GEDS dependencies
tags: dependencies
become: true
apt:
pkg:
- clang
- curl
- wget
- build-essential
- gcc
- ninja-build
- openjdk-11-jdk
- python3-dev
- python3-distutils
- cmake
state: latest
update_cache: yes

- name: Create GEDS directory
tags: git
become: false
file:
path: "{{ remote_home }}/GEDS"
state: directory

- name: Git clone GEDS
tags: git
become: false
ansible.builtin.git:
repo: "https://github.com/IBM/GEDS.git"
dest: "{{ remote_home }}/GEDS/"

- name: AWS dependencies
tags: aws
become: true
apt:
pkg:
- libcurl4-openssl-dev
- libssl-dev
- uuid-dev
- zlib1g-dev
- libpulse-dev
state: latest
update_cache: yes

- name: Build AWS
tags: aws
become: false
ansible.builtin.command: /bin/bash build-aws-sdk.sh
async: 3600
poll: 30
args:
chdir: "{{ remote_home }}/GEDS"

- name: Build boost
tags: boost
become: false
ansible.builtin.command: /bin/bash build-boost.sh
args:
chdir: "{{ remote_home }}/GEDS"

- name: Create GEDS build directory
tags: geds
become: false
file:
path: "{{ remote_home }}/GEDS/build"
state: directory

- name: Build GEDS
tags: geds
become: false
ansible.builtin.command: cmake -DCMAKE_BUILD_TYPE=Debug -S . -B $BUILD_DIR
args:
chdir: "{{ remote_home }}/GEDS"
environment:
BUILD_DIR: "{{ remote_home }}/GEDS/build"

- name: Build GEDS
tags: geds
become: false
ansible.builtin.command: cmake --build $BUILD_DIR -j 4
args:
chdir: "{{ remote_home }}/GEDS"
environment:
BUILD_DIR: "{{ remote_home }}/GEDS/build"

- name: Create GEDS install directory
tags: geds
become: false
file:
path: "{{ remote_home }}/GEDS/bin"
state: directory

- name: Install GEDS
tags: geds
become: false
ansible.builtin.command: cmake --install $BUILD_DIR --prefix $INSTALL_DIR --component geds
args:
chdir: "{{ remote_home }}/GEDS"
environment:
BUILD_DIR: "{{ remote_home }}/GEDS/build"
INSTALL_DIR: "{{ remote_home }}/GEDS/bin"