"when" keyword should precede "block" keyword

Otherwise the reader is forced to search for "when" when blocks are too
long.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
pull/3764/head
Rishabh Dave 2019-03-28 13:43:30 +05:30 committed by mergify[bot]
parent 76f80277ed
commit e0beaf123a
16 changed files with 89 additions and 90 deletions

View File

@ -20,6 +20,8 @@
# - All previous versions from Canonical
# - Infernalis from ceph.com
- name: debian based systems - configure cluster name
when:
- ansible_os_family == "Debian"
block:
- name: check /etc/default/ceph exist
stat:
@ -28,6 +30,8 @@
check_mode: no
- name: configure cluster name
when:
- etc_default_ceph.stat.exists
block:
- name: when /etc/default/ceph is not dir
lineinfile:
@ -48,7 +52,3 @@
line: "CLUSTER={{ cluster }}"
when:
- etc_default_ceph.stat.isdir
when:
- etc_default_ceph.stat.exists
when:
- ansible_os_family == "Debian"

View File

@ -4,7 +4,10 @@
when:
- containerized_deployment|bool
- block:
- name: config file operations related to OSDs
when:
- inventory_hostname in groups.get(osd_group_name, [])
block:
- name: count number of osds for ceph-disk scenarios
set_fact:
num_osds: "{{ devices | length | int }}"
@ -67,11 +70,11 @@
- osd_scenario == 'lvm'
- not (lvm_batch_report.stdout | from_json).changed
when:
- inventory_hostname in groups.get(osd_group_name, [])
# ceph-common
- block:
- name: config file operation for non-containerized scenarios
when:
- not containerized_deployment|bool
block:
- name: create ceph conf directory
file:
path: "/etc/ceph"
@ -122,10 +125,11 @@
when:
- inventory_hostname in groups[mon_group_name]
- ceph_conf_local
when:
- not containerized_deployment|bool
- block:
- name: config file operations for containerized scenarios
when:
- containerized_deployment|bool
block:
- name: create a local fetch directory if it does not exist
file:
path: "{{ fetch_directory }}"
@ -156,6 +160,3 @@
- restart ceph rgws
- restart ceph mgrs
- restart ceph rbdmirrors
when:
- containerized_deployment|bool

View File

@ -3,6 +3,8 @@
include_tasks: remove_ceph_udev_rules.yml
- name: debian based systems tasks
when:
- ansible_distribution == 'Debian'
block:
- name: include debian_prerequisites.yml
include_tasks: debian_prerequisites.yml
@ -17,10 +19,12 @@
until: result is succeeded
tags:
with_pkg
when:
- ansible_distribution == 'Debian'
- name: ubuntu based systems tasks
when:
- ansible_distribution == 'Ubuntu'
tags:
with_pkg
block:
- name: install docker on ubuntu
package:
@ -29,7 +33,6 @@
update_cache: yes
register: result
until: result is succeeded
- name: install python3-docker on bionic
package:
name: python3-docker
@ -38,10 +41,6 @@
register: result
until: result is succeeded
when: ansible_lsb.codename == 'bionic'
when:
- ansible_distribution == 'Ubuntu'
tags:
with_pkg
# ensure extras enabled for docker
- name: enable extras on centos
@ -56,6 +55,9 @@
with_pkg
- name: red hat 7 based systems tasks
when:
- ansible_os_family == 'RedHat'
- ansible_distribution_major_version == '7'
block:
- name: install python-docker-py on red hat / centos
package:
@ -81,11 +83,10 @@
tags:
with_pkg
- name: red hat 8 based systems tasks
when:
- ansible_os_family == 'RedHat'
- ansible_distribution_major_version == '7'
- name: red hat 8 based systems tasks
- ansible_distribution_major_version == '8'
block:
- name: install podman
package:
@ -95,9 +96,6 @@
until: result is succeeded
tags:
with_pkg
when:
- ansible_os_family == 'RedHat'
- ansible_distribution_major_version == '8'
- name: ensure tmpfiles.d is present
lineinfile:

View File

@ -106,7 +106,12 @@
when:
- ceph_current_status.fsid is defined
- block:
- name: fsid realted tasks
when:
- generate_fsid
- ceph_current_status.fsid is undefined
- not rolling_update
block:
- name: generate cluster fsid
shell: python -c 'import uuid; print(str(uuid.uuid4()))'
register: cluster_uuid
@ -118,11 +123,6 @@
set_fact:
fsid: "{{ cluster_uuid.stdout }}"
when:
- generate_fsid
- ceph_current_status.fsid is undefined
- not rolling_update
- name: set_fact mds_name ansible_hostname
set_fact:
mds_name: "{{ ansible_hostname }}"

View File

@ -13,7 +13,12 @@
- radosgw_address is defined
- radosgw_address != '0.0.0.0'
- block:
- name: tasks for radosgw interface
when:
- radosgw_address_block == 'subnet'
- radosgw_address == '0.0.0.0'
- radosgw_interface != 'interface'
block:
- name: set_fact _interface
set_fact:
_interface: "{{ 'ansible_' + (radosgw_interface | replace('-', '_')) }}"
@ -29,7 +34,3 @@
_radosgw_address: "{{ hostvars[inventory_hostname][_interface][ip_version][0]['address'] }}"
when:
- ip_version == 'ipv6'
when:
- radosgw_address_block == 'subnet'
- radosgw_address == '0.0.0.0'
- radosgw_interface != 'interface'

View File

@ -12,7 +12,10 @@
when:
- not containerized_deployment
- block:
- when:
- (firewalld_pkg_query.get('rc', 1) == 0
or is_atomic)
block:
- name: start firewalld
service:
name: firewalld
@ -165,8 +168,4 @@
tags:
- firewall
when:
- (firewalld_pkg_query.get('rc', 1) == 0
or is_atomic)
- meta: flush_handlers

View File

@ -1,7 +1,13 @@
---
- name: red hat based systems tasks
when:
- ansible_os_family == 'RedHat'
block:
- name: when ceph_iscsi_config_dev is true
when:
- ceph_origin == 'repository'
- ceph_repository == 'dev'
- ceph_iscsi_config_dev
block:
- name: set_fact ceph_iscsi_repos
set_fact:
@ -28,10 +34,6 @@
with_together:
- "{{ ceph_iscsi_config_dev_yum_repo.results }}"
- "{{ ceph_iscsi_repos }}"
when:
- ceph_origin == 'repository'
- ceph_repository == 'dev'
- ceph_iscsi_config_dev
- name: install ceph iscsi package
package:
@ -45,8 +47,6 @@
- targetcli
- python-rtslib
- ceph-iscsi-cli
when:
- ansible_os_family == 'RedHat'
- name: check the status of the target.service override
stat:

View File

@ -16,7 +16,10 @@
delay: "{{ handler_health_mon_check_delay }}"
changed_when: false
- block:
- name: tasks for MONs when cephx is enabled
when:
- cephx
block:
- name: fetch ceph initial keys
ceph_key:
state: fetch_initial_keys
@ -58,8 +61,6 @@
with_items:
- "{{ groups.get(mon_group_name) if groups.get(mgr_group_name, []) | length == 0 else groups.get(mgr_group_name, []) }}"
delegate_to: "{{ groups[mon_group_name][0] }}"
when:
- cephx
- name: copy keys to the ansible server
fetch:

View File

@ -45,6 +45,8 @@
- item.create|bool
- name: cephx related tasks
when:
- cephx
block:
- name: copy bootstrap cephx keys
copy:
@ -59,6 +61,8 @@
- item.copy_key|bool
- name: nfs object gateway related tasks
when:
- nfs_obj_gw
block:
- name: create rados gateway keyring
command: ceph --cluster {{ cluster }} --name client.bootstrap-rgw --keyring /var/lib/ceph/bootstrap-rgw/{{ cluster }}.keyring auth get-or-create client.rgw.{{ ansible_hostname }} osd 'allow rwx' mon 'allow rw' -o /var/lib/ceph/radosgw/{{ cluster }}-rgw.{{ ansible_hostname }}/keyring
@ -72,10 +76,6 @@
owner: "ceph"
group: "ceph"
mode: "0600"
when:
- nfs_obj_gw
when:
- cephx
- name: change ownership on /var/log/ganesha
file:

View File

@ -1,7 +1,12 @@
---
- name: debian based systems - repo handling
when:
- ceph_origin == 'repository'
block:
- name: stable repos specific tasks
when:
- nfs_ganesha_stable
- ceph_repository == 'community'
block:
- name: add nfs-ganesha stable repository
apt_repository:
@ -19,11 +24,11 @@
until: update_ganesha_apt_cache | success
when:
- add_ganesha_apt_repo | changed
when:
- nfs_ganesha_stable
- ceph_repository == 'community'
- name: debian based systems - dev repos specific tasks
when:
- nfs_ganesha_dev
- ceph_repository == 'dev'
block:
- name: fetch nfs-ganesha development repository
uri:
@ -38,15 +43,13 @@
owner: root
group: root
backup: yes
when:
- nfs_ganesha_dev
- ceph_repository == 'dev'
when:
- ceph_origin == 'repository'
- name: debain based systems - install required packages
block:
- name: debian based systems- non-rhcs installation
when:
- (ceph_origin == 'repository' or ceph_origin == 'distro')
- ceph_repository != 'rhcs'
block:
- name: install jemalloc for debian
apt:
@ -69,11 +72,11 @@
register: result
until: result is succeeded
when: nfs_file_gw
when:
- (ceph_origin == 'repository' or ceph_origin == 'distro')
- ceph_repository != 'rhcs'
- name: debian based systems - rhcs installation
when:
- (ceph_origin == 'repository' or ceph_origin == 'distro')
- ceph_repository == 'rhcs'
block:
- name: install red hat storage nfs gateway for debian
apt:
@ -97,6 +100,3 @@
until: result is succeeded
when:
- nfs_obj_gw
when:
- (ceph_origin == 'repository' or ceph_origin == 'distro')
- ceph_repository == 'rhcs'

View File

@ -1,5 +1,7 @@
---
- name: red hat based systems - repo handling
when:
- ceph_origin == 'repository'
block:
- name: add nfs-ganesha stable repository
yum_repository:
@ -31,8 +33,6 @@
when:
- nfs_ganesha_dev
- ceph_repository == 'dev'
when:
- ceph_origin == 'repository'
- name: red hat based systems - install nfs packages
block:

View File

@ -1,7 +1,8 @@
---
- block:
# For openstack VMs modify the mount point below depending on if the Openstack
# VM deploy tool defaults to mounting ephemeral disks
- name: container specific tasks
when:
- containerized_deployment
block:
- name: umount ceph disk (if on openstack)
mount:
name: /mnt
@ -38,8 +39,6 @@
setype: "bin_t"
notify:
- restart ceph osds
when:
- containerized_deployment
# this is for ceph-disk, the ceph-disk command is gone so we have to list /var/lib/ceph
- name: get osd ids

View File

@ -1,5 +1,8 @@
---
- name: debian based systems tasks
when:
- osd_objectstore == 'filestore'
- ansible_os_family == "Debian"
block:
- name: disable osd directory parsing by updatedb
command: updatedb -e /var/lib/ceph
@ -11,9 +14,6 @@
regexp: '^(PRUNEPATHS(?!.*/var/lib/ceph).*)"$'
replace: '\1 /var/lib/ceph"'
failed_when: false
when:
- osd_objectstore == 'filestore'
- ansible_os_family == "Debian"
- name: create tmpfiles.d directory
file:

View File

@ -1,5 +1,7 @@
---
- name: devices validation
when:
- devices is defined
block:
- name: validate devices is actually a device
parted:
@ -14,8 +16,6 @@
when:
- item.failed
with_items: "{{ devices_parted.results }}"
when:
- devices is defined
- name: validate dedicated_device is/are actually device(s)
parted:

View File

@ -18,6 +18,9 @@
- ansible_os_family not in ['Debian', 'RedHat', 'ClearLinux', 'Suse']
- name: red hat based systems tasks
when:
- ceph_repository == 'rhcs'
- ansible_distribution == 'Red Hat Enterprise Linux'
block:
- name: fail on unsupported distribution for red hat ceph storage
fail:
@ -26,6 +29,8 @@
- ansible_distribution_version | version_compare('7.3', '<')
- name: subscription manager related tasks
when:
- ceph_repository_type == 'cdn'
block:
- name: determine if node is registered with subscription-manager
command: subscription-manager identity
@ -39,11 +44,6 @@
msg: "You must register your machine with subscription-manager"
when:
- subscription.rc != '0'
when:
- ceph_repository_type == 'cdn'
when:
- ceph_repository == 'rhcs'
- ansible_distribution == 'Red Hat Enterprise Linux'
- name: fail on unsupported distribution for ubuntu cloud archive
fail:

View File

@ -11,6 +11,8 @@
- not use_fqdn_yes_i_am_sure
- name: debian based systems tasks
when:
- ansible_os_family == 'Debian'
block:
- name: fail if local scenario is enabled on debian
fail:
@ -26,8 +28,6 @@
- ceph_repository_type == 'cdn'
- ceph_rhcs_cdn_debian_repo == 'https://customername:customerpasswd@rhcs.download.redhat.com'
- ceph_repository not in ['rhcs', 'dev', 'obs']
when:
- ansible_os_family == 'Debian'
- name: validate ntp daemon type
fail: