site.yml: main playbook refactor

Having a single play calling the different roles avoid issues with
handler being called twice when collocating daemons.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
refact_main_playbook
Guillaume Abrioux 2020-10-20 10:01:32 +02:00
parent ca90614a66
commit ff17416db5
2 changed files with 30 additions and 208 deletions

View File

@ -1,7 +1,7 @@
--- ---
- name: set_fact add_osd - name: set_fact add_osd
set_fact: set_fact:
add_osd: "{{ groups[osd_group_name] | length != ansible_play_hosts_all | length }}" add_osd: "{{ (groups[osd_group_name] | length) != (ansible_play_hosts_all | intersect(groups[osd_group_name]) | length) }}"
- name: set_fact container_exec_cmd - name: set_fact container_exec_cmd
set_fact: set_fact:
@ -73,7 +73,7 @@
when: when:
- not rolling_update | default(False) | bool - not rolling_update | default(False) | bool
- not switch_to_containers | default(False) | bool - not switch_to_containers | default(False) | bool
- inventory_hostname == ansible_play_hosts_all | last - inventory_hostname == ansible_play_hosts_all | intersect(groups[osd_group_name]) | last
- name: wait for all osd to be up - name: wait for all osd to be up
command: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} osd stat -f json" command: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} osd stat -f json"
@ -87,7 +87,7 @@
- (wait_for_all_osds_up.stdout | from_json)["num_osds"] == (wait_for_all_osds_up.stdout | from_json)["num_up_osds"] - (wait_for_all_osds_up.stdout | from_json)["num_osds"] == (wait_for_all_osds_up.stdout | from_json)["num_up_osds"]
when: when:
- not ansible_check_mode - not ansible_check_mode
- inventory_hostname == ansible_play_hosts_all | last - inventory_hostname == ansible_play_hosts_all | intersect(groups[osd_group_name]) | last
- name: include crush_rules.yml - name: include crush_rules.yml
include_tasks: crush_rules.yml include_tasks: crush_rules.yml

View File

@ -61,12 +61,12 @@
name: ceph-infra name: ceph-infra
- import_role: - import_role:
name: ceph-common name: ceph-common
- import_role:
name: ceph-handler
- import_role:
name: ceph-config
tags: ['ceph_update_config']
- hosts: mons
gather_facts: false
become: True
any_errors_fatal: true
pre_tasks:
- name: set ceph monitor install 'In Progress' - name: set ceph monitor install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -74,27 +74,9 @@
installer_phase_ceph_mon: installer_phase_ceph_mon:
status: "In Progress" status: "In Progress"
start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
- include_role:
tasks:
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
- import_role:
name: ceph-config
tags: ['ceph_update_config']
- import_role:
name: ceph-mon name: ceph-mon
- import_role: when: inventory_hostname in groups.get(mon_group_name, [])
name: ceph-mgr
when: groups.get(mgr_group_name, []) | length == 0
post_tasks:
- name: set ceph monitor install 'Complete' - name: set ceph monitor install 'Complete'
run_once: true run_once: true
set_stats: set_stats:
@ -103,11 +85,6 @@
status: "Complete" status: "Complete"
end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
- hosts: mgrs
gather_facts: false
become: True
any_errors_fatal: true
pre_tasks:
- name: set ceph manager install 'In Progress' - name: set ceph manager install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -115,24 +92,11 @@
installer_phase_ceph_mgr: installer_phase_ceph_mgr:
status: "In Progress" status: "In Progress"
start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
- include_role:
tasks:
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
- import_role:
name: ceph-config
tags: ['ceph_update_config']
- import_role:
name: ceph-mgr name: ceph-mgr
when:
post_tasks: - (inventory_hostname in groups.get(mon_group_name, []) and groups.get(mgr_group_name, []) | length == 0) or
(inventory_hostname in groups.get(mgr_group_name, []) and groups.get(mgr_group_name, []) | length > 0)
- name: set ceph manager install 'Complete' - name: set ceph manager install 'Complete'
run_once: true run_once: true
set_stats: set_stats:
@ -141,11 +105,6 @@
status: "Complete" status: "Complete"
end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
- hosts: osds
gather_facts: false
become: True
any_errors_fatal: true
pre_tasks:
- name: set ceph osd install 'In Progress' - name: set ceph osd install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -154,23 +113,10 @@
status: "In Progress" status: "In Progress"
start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
tasks: - include_role:
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
- import_role:
name: ceph-config
tags: ['ceph_update_config']
- import_role:
name: ceph-osd name: ceph-osd
when: inventory_hostname in groups.get(osd_group_name, [])
post_tasks:
- name: set ceph osd install 'Complete' - name: set ceph osd install 'Complete'
run_once: true run_once: true
set_stats: set_stats:
@ -179,11 +125,6 @@
status: "Complete" status: "Complete"
end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
- hosts: mdss
gather_facts: false
become: True
any_errors_fatal: true
pre_tasks:
- name: set ceph mds install 'In Progress' - name: set ceph mds install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -192,23 +133,10 @@
status: "In Progress" status: "In Progress"
start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
tasks: - include_role:
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
- import_role:
name: ceph-config
tags: ['ceph_update_config']
- import_role:
name: ceph-mds name: ceph-mds
when: inventory_hostname in groups.get(mds_group_name, [])
post_tasks:
- name: set ceph mds install 'Complete' - name: set ceph mds install 'Complete'
run_once: true run_once: true
set_stats: set_stats:
@ -217,11 +145,6 @@
status: "Complete" status: "Complete"
end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
- hosts: rgws
gather_facts: false
become: True
any_errors_fatal: true
pre_tasks:
- name: set ceph rgw install 'In Progress' - name: set ceph rgw install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -230,23 +153,10 @@
status: "In Progress" status: "In Progress"
start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
tasks: - include_role:
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
- import_role:
name: ceph-config
tags: ['ceph_update_config']
- import_role:
name: ceph-rgw name: ceph-rgw
when: inventory_hostname in groups.get(rgw_group_name, [])
post_tasks:
- name: set ceph rgw install 'Complete' - name: set ceph rgw install 'Complete'
run_once: true run_once: true
set_stats: set_stats:
@ -255,12 +165,6 @@
status: "Complete" status: "Complete"
end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
- hosts: clients
gather_facts: false
become: True
any_errors_fatal: true
tags: 'ceph_client'
pre_tasks:
- name: set ceph client install 'In Progress' - name: set ceph client install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -269,23 +173,10 @@
status: "In Progress" status: "In Progress"
start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
tasks: - include_role:
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
- import_role:
name: ceph-config
tags: ['ceph_update_config']
- import_role:
name: ceph-client name: ceph-client
when: inventory_hostname in groups.get(client_group_name, [])
post_tasks:
- name: set ceph client install 'Complete' - name: set ceph client install 'Complete'
run_once: true run_once: true
set_stats: set_stats:
@ -294,11 +185,6 @@
status: "Complete" status: "Complete"
end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
- hosts: nfss
gather_facts: false
become: True
any_errors_fatal: true
pre_tasks:
- name: set ceph nfs install 'In Progress' - name: set ceph nfs install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -307,23 +193,9 @@
status: "In Progress" status: "In Progress"
start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
tasks: - include_role:
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
- import_role:
name: ceph-config
tags: ['ceph_update_config']
- import_role:
name: ceph-nfs name: ceph-nfs
when: inventory_hostname in groups.get(nfs_group_name, [])
post_tasks:
- name: set ceph nfs install 'Complete' - name: set ceph nfs install 'Complete'
run_once: true run_once: true
set_stats: set_stats:
@ -332,11 +204,6 @@
status: "Complete" status: "Complete"
end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
- hosts: rbdmirrors
gather_facts: false
become: True
any_errors_fatal: true
pre_tasks:
- name: set ceph rbd mirror install 'In Progress' - name: set ceph rbd mirror install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -345,23 +212,10 @@
status: "In Progress" status: "In Progress"
start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
tasks: - include_role:
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
- import_role:
name: ceph-config
tags: ['ceph_update_config']
- import_role:
name: ceph-rbd-mirror name: ceph-rbd-mirror
when: inventory_hostname in groups.get(rbdmirror_group_name, [])
post_tasks:
- name: set ceph rbd mirror install 'Complete' - name: set ceph rbd mirror install 'Complete'
run_once: true run_once: true
set_stats: set_stats:
@ -370,12 +224,6 @@
status: "Complete" status: "Complete"
end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
- hosts:
- iscsigws
gather_facts: false
become: True
any_errors_fatal: true
pre_tasks:
- name: set ceph iscsi gateway install 'In Progress' - name: set ceph iscsi gateway install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -384,23 +232,10 @@
status: "In Progress" status: "In Progress"
start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
tasks: - include_role:
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
- import_role:
name: ceph-config
tags: ['ceph_update_config']
- import_role:
name: ceph-iscsi-gw name: ceph-iscsi-gw
when: inventory_hostname in groups.get(iscsi_gw_group_name, [])
post_tasks:
- name: set ceph iscsi gw install 'Complete' - name: set ceph iscsi gw install 'Complete'
run_once: true run_once: true
set_stats: set_stats:
@ -409,12 +244,6 @@
status: "Complete" status: "Complete"
end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
- hosts:
- rgwloadbalancers
gather_facts: false
become: True
any_errors_fatal: true
pre_tasks:
- name: set ceph rgw loadbalancer install 'In Progress' - name: set ceph rgw loadbalancer install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -423,17 +252,10 @@
status: "In Progress" status: "In Progress"
start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
tasks: - include_role:
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-rgw-loadbalancer name: ceph-rgw-loadbalancer
when: inventory_hostname in groups.get(rgwloadbalancer_group_name, [])
post_tasks:
- name: set ceph rgw loadbalancer install 'Complete' - name: set ceph rgw loadbalancer install 'Complete'
run_once: true run_once: true
set_stats: set_stats: