Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.
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
37 changes: 37 additions & 0 deletions setup-profiles/ansible-setup-profile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Ansible setup-profile
Ansible playbook to generate setup-profile for [gbench](https://github.com/gluster/gbench/) using jinja2 template.

## How to run?

Run the playbook `configure.yml` with additional parameters for servers, clients and devices. Where servers are list of coma seperated hosts(IP addresses/hostnames) that are going to be glusterfs server, clients are coma seperated clients(IP addresses/hosts) that are going to be gluster clients and devices are the list of coma seperated drives(currently same devices names are considered) that are attached to the servers.

```console
ansible-playbook configure.yml -e 'servers=host1,host2,...hostn clients=client1,client2,...clientn devices=sda,sdb'
```

## What `configure.yml` does?
`configure.yml` takes the aditional facts and use it to generate another yaml file `exportenv.yml` using jinja template and `systems.yml` which stores server and client IP/hostname and then it includes the generated `exportenv.yml` and runs its tasks.

`exportenv.yml` creates directories for server and client and adds public files in those created directories.

For example there are three servers whose IP addresses are `10.0.0.1`, `10.0.0.2` and `10.0.0.3` and two clients `10.0.0.4` and `10.0.0.5` the generated directory structure will look like the following which is according to the desired setup-profile
```console
ansible-playbook configure.yml -e 'servers=10.0.0.1,10.0.0.2,10.0.0.3 clients=10.0.0.4,10.0.0.5 devices=sda,sdb,sdc'
```

```
setup-profile
├── group_vars
│   ├── all
│   ├── client1
│   │   └── public
│   ├── client2
│   │   └── public
│   ├── server1
│   │   └── public
│   ├── server2
│   │   └── public
│   └── server3
│   └── public
└── inventory.ini
```
18 changes: 18 additions & 0 deletions setup-profiles/ansible-setup-profile/configure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- hosts: localhost
tasks:

# Create exportenv.yml from the src jinja2 file
- template:
src: templates/exportenv.yml.j2
dest: exportenv.yml

# Create systems file containing servers and clients from the src jinja2 file
- template:
src: templates/systems.yml.j2
dest: systems.yml

# includes the tasks from exportenv.yml which was created above
- include: exportenv.yml
...

16 changes: 16 additions & 0 deletions setup-profiles/ansible-setup-profile/setup-profile/group_vars/all
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
# Common variables for all hosts

ansible_connection: ssh
ansible_user: root

# Cleanup of devices is allowed on this setup
gbench_device_cleanup: yes

gbench_client_mountpoint: "/mnt/gbench/"
# Infiniband (IB) over IP variables
#ipoib_device: ib0
#ipoib_netmask: 255.255.255.0
#ipoib_use_gateway: yes
#ipoib_gateway: em1

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
glusterip: {{ hostvars[inventory_hostname]['client%s' | format(var)] }}

41 changes: 41 additions & 0 deletions setup-profiles/ansible-setup-profile/templates/exportenv.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
- include_vars: systems.yml

- template:
src: templates/inventory.ini.j2
dest: setup-profile/inventory.ini

# Create directory for servers and copy public file with value set to server ip/hostname
{% for server in servers.split(',') %}
{% set var = loop.index %}
- file:
path: setup-profile/group_vars/server{{ loop.index }}
state: directory

- name: server{{ var }}
template:
src: templates/server_public.j2
dest: setup-profile/group_vars/server{{ var }}/public
vars:
var: {{ var }}

{% endfor %}

# Create directory for clients and copy public file with value set to client ip/hostname
{% for client in clients.split(',') %}
{% set var = loop.index %}
- file:
path: setup-profile/group_vars/client{{ loop.index }}
state: directory

- name: client{{ var }}
template:
src: templates/client_public.j2
dest: setup-profile/group_vars/client{{ var }}/public
vars:
var: {{ var }}

{% endfor %}

...

23 changes: 23 additions & 0 deletions setup-profiles/ansible-setup-profile/templates/inventory.ini.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[servers]
{% for host in servers.split(',') %}
{{ host }}
{% endfor %}

[clients]
{% for host in clients.split(',') %}
{{ host }}
{% endfor %}

{% for server in servers.split(',') %}
[server{{ loop.index }}]
{{ server }}

{% endfor %}

{% for client in clients.split(',') %}
[client{{ loop.index }}]
{{ client }}

{% endfor %}


Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
glusterip: {{ hostvars[inventory_hostname]['server%s' | format(var)] }}

devices:
# Generate list of drives
{% for device in devices.split(',') %}
- '/dev/{{ device }}'
{% endfor %}
11 changes: 11 additions & 0 deletions setup-profiles/ansible-setup-profile/templates/systems.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
servers: {{ servers }}
clients: {{ clients }}

{% for server in servers.split(',') %}
server{{ loop.index }}: {{ server }}
{% endfor %}

{% for client in clients.split(',') %}
client{{ loop.index }}: {{ client }}
{% endfor %}