use pre_tasks and post_tasks when necessary

Signed-off-by: Rishabh Dave <ridave@redhat.com>
pull/3420/head
Rishabh Dave 2018-11-12 17:51:26 +05:30 committed by mergify[bot]
parent e4f0af2b78
commit 2fb12ae554
7 changed files with 62 additions and 63 deletions

View File

@ -24,8 +24,7 @@
vars: vars:
delegate_facts_host: True delegate_facts_host: True
tasks: pre_tasks:
# pre-tasks for following import
- name: gather facts - name: gather facts
setup: setup:
when: when:
@ -42,6 +41,7 @@
when: when:
- delegate_facts_host | bool - delegate_facts_host | bool
tasks:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
@ -52,8 +52,7 @@
gather_facts: False gather_facts: False
become: True become: True
tasks: pre_tasks:
# pre-tasks for following import
# this task is needed so we can skip the openstack_config.yml include in roles/ceph-osd # this task is needed so we can skip the openstack_config.yml include in roles/ceph-osd
- name: set_fact add_osd - name: set_fact add_osd
set_fact: set_fact:
@ -65,6 +64,7 @@
run_once: True run_once: True
changed_when: False changed_when: False
tasks:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
@ -88,7 +88,7 @@
- import_role: - import_role:
name: ceph-osd name: ceph-osd
# post-tasks for preceding import post_tasks:
- name: unset noup flag - name: unset noup flag
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd unset noup" command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd unset noup"
delegate_to: "{{ groups['mons'][0] }}" delegate_to: "{{ groups['mons'][0] }}"

View File

@ -34,8 +34,7 @@
vars: vars:
mon_group_name: mons mon_group_name: mons
osd_group_name: osds osd_group_name: osds
tasks: pre_tasks:
# pre-task for following import
- name: exit playbook, if user did not mean to shrink cluster - name: exit playbook, if user did not mean to shrink cluster
fail: fail:
msg: "Exiting shrink-osd playbook, no osd(s) was/were removed.. msg: "Exiting shrink-osd playbook, no osd(s) was/were removed..
@ -52,10 +51,11 @@
-e osd_to_kill=0,1,2,3 argument." -e osd_to_kill=0,1,2,3 argument."
when: osd_to_kill is not defined when: osd_to_kill is not defined
tasks:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
# post-task for preceding import post_tasks:
- name: "set_fact docker_exec_cmd build {{ container_binary }} exec command (containerized)" - name: "set_fact docker_exec_cmd build {{ container_binary }} exec command (containerized)"
set_fact: set_fact:
docker_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}" docker_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}"

View File

@ -38,8 +38,7 @@
mon_group_name: mons mon_group_name: mons
osd_group_name: osds osd_group_name: osds
tasks: pre_tasks:
# pre-task for following import
- name: exit playbook, if user did not mean to shrink cluster - name: exit playbook, if user did not mean to shrink cluster
fail: fail:
msg: "Exiting shrink-osd playbook, no osd(s) was/were removed.. msg: "Exiting shrink-osd playbook, no osd(s) was/were removed..
@ -56,10 +55,11 @@
-e osd_to_kill=0,1,2,3 argument." -e osd_to_kill=0,1,2,3 argument."
when: osd_to_kill is not defined when: osd_to_kill is not defined
tasks:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
# post-task for preceding import post_tasks:
- name: set_fact docker_exec_cmd build docker exec command (containerized) - name: set_fact docker_exec_cmd build docker exec command (containerized)
set_fact: set_fact:
docker_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}" docker_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}"

View File

@ -56,8 +56,7 @@
- "{{ mon_group_name|default('mons') }}" - "{{ mon_group_name|default('mons') }}"
serial: 1 serial: 1
become: true become: true
tasks: pre_tasks:
# pre-tasks for following import -
- name: select a running monitor - name: select a running monitor
set_fact: mon_host={{ item }} set_fact: mon_host={{ item }}
with_items: "{{ groups[mon_group_name] }}" with_items: "{{ groups[mon_group_name] }}"
@ -112,6 +111,7 @@
changed_when: false changed_when: false
failed_when: false failed_when: false
tasks:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
- import_role: - import_role:
@ -121,7 +121,6 @@
- import_role: - import_role:
name: ceph-mon name: ceph-mon
# post-tasks for preceding import -
post_tasks: post_tasks:
# We don't do a container test by running 'docker exec ...' since not all the monitors have switched to containers yet. # We don't do a container test by running 'docker exec ...' since not all the monitors have switched to containers yet.
# Thus, we continue to use the 'ceph' binary from the host, there is no issue with that. # Thus, we continue to use the 'ceph' binary from the host, there is no issue with that.
@ -145,8 +144,7 @@
serial: 1 serial: 1
become: true become: true
tasks: pre_tasks:
# pre-tasks for following import -
# failed_when: false is here because if we're # failed_when: false is here because if we're
# working with a jewel cluster then ceph mgr # working with a jewel cluster then ceph mgr
# will not exist # will not exist
@ -174,6 +172,7 @@
- /var/lib/ceph - /var/lib/ceph
- /etc/ceph - /etc/ceph
tasks:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
@ -200,12 +199,11 @@
serial: 1 serial: 1
become: true become: true
tasks: pre_tasks:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
# pre-tasks for following importing
- name: collect running osds and ceph-disk unit(s) - name: collect running osds and ceph-disk unit(s)
shell: | shell: |
systemctl list-units | grep "loaded active" | grep -Eo 'ceph-osd@[0-9]+.service|ceph-disk@dev-[a-z]{3,4}[0-9]{1}.service|ceph-volume|ceph\.target' systemctl list-units | grep "loaded active" | grep -Eo 'ceph-osd@[0-9]+.service|ceph-disk@dev-[a-z]{3,4}[0-9]{1}.service|ceph-volume|ceph\.target'
@ -290,6 +288,7 @@
when: when:
- osd_running.rc != 0 - osd_running.rc != 0
tasks:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
@ -302,7 +301,7 @@
- import_role: - import_role:
name: ceph-osd name: ceph-osd
# post-task for preceding import - post_tasks:
- name: get num_pgs - name: get num_pgs
command: > command: >
{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }} ceph --cluster {{ cluster }} -s --format json {{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }} ceph --cluster {{ cluster }} -s --format json
@ -335,9 +334,8 @@
serial: 1 serial: 1
become: true become: true
tasks: pre_tasks:
# pre-tasks for following inmport
- name: stop non-containerized ceph mds(s) - name: stop non-containerized ceph mds(s)
service: service:
name: "ceph-mds@{{ ansible_hostname }}" name: "ceph-mds@{{ ansible_hostname }}"
@ -361,6 +359,7 @@
- /var/lib/ceph - /var/lib/ceph
- /etc/ceph - /etc/ceph
tasks:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
@ -385,9 +384,8 @@
serial: 1 serial: 1
become: true become: true
tasks: pre_tasks:
# pre-tasks for following import -
- name: stop non-containerized ceph rgw(s) - name: stop non-containerized ceph rgw(s)
service: service:
name: "ceph-radosgw@rgw.{{ ansible_hostname }}" name: "ceph-radosgw@rgw.{{ ansible_hostname }}"
@ -411,6 +409,7 @@
- /var/lib/ceph - /var/lib/ceph
- /etc/ceph - /etc/ceph
tasks:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
@ -435,8 +434,7 @@
serial: 1 serial: 1
become: true become: true
tasks: pre_tasks:
# pre-tasks for following import -
- name: stop non-containerized ceph rbd mirror(s) - name: stop non-containerized ceph rbd mirror(s)
service: service:
name: "ceph-rbd-mirror@rbd-mirror.{{ ansible_hostname }}" name: "ceph-rbd-mirror@rbd-mirror.{{ ansible_hostname }}"
@ -460,6 +458,7 @@
- /var/lib/ceph - /var/lib/ceph
- /etc/ceph - /etc/ceph
tasks:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
@ -484,9 +483,8 @@
serial: 1 serial: 1
become: true become: true
tasks: pre_tasks:
# pre-tasks for following import -
# failed_when: false is here because if we're # failed_when: false is here because if we're
# working with a jewel cluster then ceph nfs # working with a jewel cluster then ceph nfs
# will not exist # will not exist
@ -514,6 +512,7 @@
- /var/lib/ceph - /var/lib/ceph
- /etc/ceph - /etc/ceph
tasks:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults

View File

@ -35,7 +35,7 @@
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
# post-tasks for preceding import - post_tasks:
- name: get the name of the existing ceph cluster - name: get the name of the existing ceph cluster
shell: | shell: |
basename $(grep --exclude '*.bak' -R fsid /etc/ceph/ | egrep -o '^[^.]*' | head -n 1) basename $(grep --exclude '*.bak' -R fsid /etc/ceph/ | egrep -o '^[^.]*' | head -n 1)

View File

@ -37,8 +37,7 @@
vars: vars:
mon_group_name: mons mon_group_name: mons
osd_group_name: osds osd_group_name: osds
tasks: pre_tasks:
# pre-tasks for following import -
- name: exit playbook, if user did not mean to replace the osd(s) - name: exit playbook, if user did not mean to replace the osd(s)
fail: fail:
msg: "Exiting replace-osd playbook, no osd(s) was/were replaced.. msg: "Exiting replace-osd playbook, no osd(s) was/were replaced..
@ -55,10 +54,11 @@
-e osd_to_replace=0,1,2,3 argument." -e osd_to_replace=0,1,2,3 argument."
when: osd_to_replace is not defined when: osd_to_replace is not defined
tasks:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
# post-tasks for preceding import - post_tasks:
- name: set_fact docker_exec_cmd build docker exec command (containerized) - name: set_fact docker_exec_cmd build docker exec command (containerized)
set_fact: set_fact:
docker_exec_cmd: "docker exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}" docker_exec_cmd: "docker exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}"

View File

@ -24,8 +24,7 @@
vars: vars:
delegate_facts_host: True delegate_facts_host: True
tasks: pre_tasks:
# pre-tasks for following imports -
# If we can't get python2 installed before any module is used we will fail # If we can't get python2 installed before any module is used we will fail
# so just try what we can to get it installed # so just try what we can to get it installed
- name: check for python2 - name: check for python2
@ -72,6 +71,7 @@
- ansible_distribution == 'Fedora' - ansible_distribution == 'Fedora'
- ansible_distribution_major_version|int >= 23 - ansible_distribution_major_version|int >= 23
tasks:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
- import_role: - import_role:
@ -83,8 +83,7 @@
gather_facts: false gather_facts: false
become: True become: True
any_errors_fatal: true any_errors_fatal: true
tasks: pre_tasks:
# pre-tasks for following imports -
- name: set ceph monitor install 'In Progress' - name: set ceph monitor install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -93,6 +92,7 @@
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:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
tags: ['ceph_update_config'] tags: ['ceph_update_config']
@ -108,7 +108,7 @@
- import_role: - import_role:
name: ceph-mgr name: ceph-mgr
# post-tasks for preceding imports - post_tasks:
- name: set ceph monitor install 'Complete' - name: set ceph monitor install 'Complete'
run_once: true run_once: true
set_stats: set_stats:
@ -121,8 +121,7 @@
gather_facts: false gather_facts: false
become: True become: True
any_errors_fatal: true any_errors_fatal: true
tasks: pre_tasks:
# pre-tasks for following imports -
- name: set ceph manager install 'In Progress' - name: set ceph manager install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -131,6 +130,7 @@
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:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
tags: ['ceph_update_config'] tags: ['ceph_update_config']
@ -144,7 +144,7 @@
- import_role: - import_role:
name: ceph-mgr name: ceph-mgr
# post-tasks for following imports - post_tasks:
- name: set ceph manager install 'Complete' - name: set ceph manager install 'Complete'
run_once: true run_once: true
set_stats: set_stats:
@ -157,8 +157,7 @@
gather_facts: false gather_facts: false
become: True become: True
any_errors_fatal: true any_errors_fatal: true
tasks: pre_tasks:
# pre-tasks for following imports -
- name: set ceph agent install 'In Progress' - name: set ceph agent install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -167,6 +166,7 @@
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:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
tags: ['ceph_update_config'] tags: ['ceph_update_config']
@ -180,7 +180,7 @@
- import_role: - import_role:
name: ceph-agent name: ceph-agent
# post-tasks for following imports - post_tasks:
- name: set ceph agent install 'Complete' - name: set ceph agent install 'Complete'
run_once: true run_once: true
set_stats: set_stats:
@ -193,8 +193,7 @@
gather_facts: false gather_facts: false
become: True become: True
any_errors_fatal: true any_errors_fatal: true
tasks: pre_tasks:
# pre-tasks for following imports -
- name: set ceph osd install 'In Progress' - name: set ceph osd install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -203,6 +202,7 @@
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:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
tags: ['ceph_update_config'] tags: ['ceph_update_config']
@ -216,7 +216,7 @@
- import_role: - import_role:
name: ceph-osd name: ceph-osd
# post-tasks for following imports - post_tasks:
- name: set ceph osd install 'Complete' - name: set ceph osd install 'Complete'
run_once: true run_once: true
set_stats: set_stats:
@ -229,8 +229,7 @@
gather_facts: false gather_facts: false
become: True become: True
any_errors_fatal: true any_errors_fatal: true
tasks: pre_tasks:
# pre-tasks for following imports -
- name: set ceph mds install 'In Progress' - name: set ceph mds install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -239,6 +238,7 @@
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:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
tags: ['ceph_update_config'] tags: ['ceph_update_config']
@ -252,7 +252,7 @@
- import_role: - import_role:
name: ceph-mds name: ceph-mds
# post-tasks for following imports - post_tasks:
- name: set ceph mds install 'Complete' - name: set ceph mds install 'Complete'
run_once: true run_once: true
set_stats: set_stats:
@ -265,8 +265,7 @@
gather_facts: false gather_facts: false
become: True become: True
any_errors_fatal: true any_errors_fatal: true
tasks: pre_tasks:
# pre-tasks for following imports -
- name: set ceph rgw install 'In Progress' - name: set ceph rgw install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -275,6 +274,7 @@
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:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
tags: ['ceph_update_config'] tags: ['ceph_update_config']
@ -288,7 +288,7 @@
- import_role: - import_role:
name: ceph-rgw name: ceph-rgw
# post-tasks for following imports - post_tasks:
- name: set ceph rgw install 'Complete' - name: set ceph rgw install 'Complete'
run_once: true run_once: true
set_stats: set_stats:
@ -301,8 +301,7 @@
gather_facts: false gather_facts: false
become: True become: True
any_errors_fatal: true any_errors_fatal: true
tasks: pre_tasks:
# pre-tasks for following imports -
- name: set ceph nfs install 'In Progress' - name: set ceph nfs install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -311,6 +310,7 @@
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:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
tags: ['ceph_update_config'] tags: ['ceph_update_config']
@ -324,7 +324,7 @@
- import_role: - import_role:
name: ceph-nfs name: ceph-nfs
# post-tasks for following imports - post_tasks:
- name: set ceph nfs install 'Complete' - name: set ceph nfs install 'Complete'
run_once: true run_once: true
set_stats: set_stats:
@ -337,8 +337,7 @@
gather_facts: false gather_facts: false
become: True become: True
any_errors_fatal: true any_errors_fatal: true
tasks: pre_tasks:
# pre-tasks for following imports -
- 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:
@ -347,6 +346,7 @@
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:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
tags: ['ceph_update_config'] tags: ['ceph_update_config']
@ -360,7 +360,7 @@
- import_role: - import_role:
name: ceph-rbd-mirror name: ceph-rbd-mirror
# post-tasks for following imports - 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:
@ -373,8 +373,7 @@
gather_facts: false gather_facts: false
become: True become: True
any_errors_fatal: true any_errors_fatal: true
tasks: pre_tasks:
# pre-tasks for following imports -
- name: set ceph client install 'In Progress' - name: set ceph client install 'In Progress'
run_once: true run_once: true
set_stats: set_stats:
@ -383,6 +382,7 @@
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:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
tags: ['ceph_update_config'] tags: ['ceph_update_config']
@ -396,7 +396,7 @@
- import_role: - import_role:
name: ceph-client name: ceph-client
# post-tasks for following imports - post_tasks:
- name: set ceph client install 'Complete' - name: set ceph client install 'Complete'
run_once: true run_once: true
set_stats: set_stats:
@ -411,8 +411,7 @@
gather_facts: false gather_facts: false
become: True become: True
any_errors_fatal: true any_errors_fatal: true
tasks: pre_tasks:
# pre-tasks for following imports -
- 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:
@ -421,6 +420,7 @@
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:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
tags: ['ceph_update_config'] tags: ['ceph_update_config']
@ -436,7 +436,7 @@
- import_role: - import_role:
name: ceph-iscsi-gw name: ceph-iscsi-gw
# post-tasks for following imports - 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: