-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Stéphane Graber <[email protected]>
- Loading branch information
Showing
6 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
- name: LVM Cluster - Generate configuration | ||
hosts: all | ||
order: shuffle | ||
gather_facts: no | ||
vars: | ||
task_name: "{{ lvmcluster_name | default('') }}" | ||
any_errors_fatal: true | ||
tasks: | ||
- name: Create cluster directory | ||
delegate_to: 127.0.0.1 | ||
file: | ||
path: "../data/lvmcluster/{{ task_name }}" | ||
mode: 0755 | ||
state: directory | ||
throttle: 1 | ||
when: 'task_name' | ||
register: create | ||
|
||
- name: Create cluster host_id tracking | ||
delegate_to: 127.0.0.1 | ||
throttle: 1 | ||
copy: | ||
content: "{}" | ||
dest: "../data/lvmcluster/{{ task_name }}/host_id.yaml" | ||
mode: 0644 | ||
when: "create.changed" | ||
|
||
- name: Update cluster host_id tracking | ||
delegate_to: 127.0.0.1 | ||
throttle: 1 | ||
template: | ||
src: "../files/lvmcluster/host_id.yaml.tpl" | ||
dest: "../data/lvmcluster/{{ task_name }}/host_id.yaml" | ||
vars: | ||
task_host_ids: "{{ lookup('file', '../data/lvmcluster/' + task_name + '/host_id.yaml') | from_yaml }}" | ||
|
||
- name: LVM Cluster - Install packages and host config | ||
hosts: all | ||
order: shuffle | ||
gather_facts: no | ||
vars: | ||
task_name: "{{ lvmcluster_name | default('') }}" | ||
task_host_ids: "{{ lookup('file', '../data/lvmcluster/' + task_name + '/host_id.yaml') | from_yaml }}" | ||
any_errors_fatal: true | ||
tasks: | ||
- name: Install the LVM packages | ||
apt: | ||
name: | ||
- lvm2 | ||
- lvm2-lockd | ||
- sanlock | ||
install_recommends: no | ||
state: present | ||
|
||
- name: Configure for LVM cluster | ||
template: | ||
src: ../files/lvmcluster/lvmlocal.conf.tpl | ||
dest: /etc/lvm/lvmlocal.conf | ||
|
||
- name: LVM Cluster - Create VGs | ||
hosts: all | ||
order: shuffle | ||
gather_facts: no | ||
vars: | ||
task_vgs: "{{ lvmcluster_vgs | default({}) }}" | ||
any_errors_fatal: true | ||
tasks: | ||
- name: Check for existing VGs | ||
shell: | ||
cmd: "vgs {{ item }}" | ||
register: check | ||
loop: "{{ lvmcluster_vgs.keys() }}" | ||
run_once: true | ||
changed_when: false | ||
failed_when: "check.rc not in (0, 5)" | ||
|
||
- name: Create the VG (first server) | ||
shell: | ||
cmd: "vgcreate --shared {{ item.item }} {{ task_vgs[item.item] }}" | ||
when: "item.rc == 5" | ||
loop: "{{ check.results }}" | ||
run_once: true | ||
register: create | ||
|
||
- name: Ensure lock manager is running | ||
shell: | ||
cmd: "vgchange --lock-start" | ||
when: "create.changed" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
- import_playbook: books/ceph.yaml | ||
- import_playbook: books/lvmcluster.yaml | ||
- import_playbook: books/ovn.yaml | ||
- import_playbook: books/incus.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% set ns = namespace() %} | ||
{% set ns.next = 1 %} | ||
{% for key, value in task_host_ids.items() %} | ||
{% if value >= ns.next %} | ||
{% set ns.next = value + 1 %} | ||
{% endif %} | ||
{% endfor %} | ||
{% for host in vars['ansible_play_hosts'] %} | ||
{% if not host in task_host_ids %} | ||
{{ host }}: {{ ns.next }} | ||
{% set ns.next = ns.next + 1 %} | ||
{% else %} | ||
{{ host }}: {{ task_host_ids[host] | default(0) }} | ||
{% endif %} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Managed by Ansible, do not modify. | ||
|
||
# Cluster is {{ task_name }} | ||
|
||
global { | ||
use_lvmlockd = 1 | ||
} | ||
|
||
local { | ||
host_id = {{ task_host_ids[inventory_hostname] }} | ||
} |