From: Rishabh Dave Date: Thu, 28 Mar 2019 08:13:30 +0000 (+0530) Subject: "when" keyword should precede "block" keyword X-Git-Tag: v5.0.0alpha1~452 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e0beaf123ac8c4de8212377c24c3e11c8a774b89;p=ceph-ansible.git "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 --- diff --git a/roles/ceph-common/tasks/configure_cluster_name.yml b/roles/ceph-common/tasks/configure_cluster_name.yml index 16b3f587c..93d00a6df 100644 --- a/roles/ceph-common/tasks/configure_cluster_name.yml +++ b/roles/ceph-common/tasks/configure_cluster_name.yml @@ -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" diff --git a/roles/ceph-config/tasks/main.yml b/roles/ceph-config/tasks/main.yml index 46294b9ba..0fa3c833a 100644 --- a/roles/ceph-config/tasks/main.yml +++ b/roles/ceph-config/tasks/main.yml @@ -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 diff --git a/roles/ceph-container-common/tasks/pre_requisites/prerequisites.yml b/roles/ceph-container-common/tasks/pre_requisites/prerequisites.yml index e6d001a87..2b83815ff 100644 --- a/roles/ceph-container-common/tasks/pre_requisites/prerequisites.yml +++ b/roles/ceph-container-common/tasks/pre_requisites/prerequisites.yml @@ -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: diff --git a/roles/ceph-facts/tasks/facts.yml b/roles/ceph-facts/tasks/facts.yml index b55c2d314..96cf69f1c 100644 --- a/roles/ceph-facts/tasks/facts.yml +++ b/roles/ceph-facts/tasks/facts.yml @@ -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 }}" diff --git a/roles/ceph-facts/tasks/set_radosgw_address.yml b/roles/ceph-facts/tasks/set_radosgw_address.yml index b0dcd0331..c0ee159d3 100644 --- a/roles/ceph-facts/tasks/set_radosgw_address.yml +++ b/roles/ceph-facts/tasks/set_radosgw_address.yml @@ -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' diff --git a/roles/ceph-infra/tasks/configure_firewall.yml b/roles/ceph-infra/tasks/configure_firewall.yml index a8d9ccbff..6bfe58047 100644 --- a/roles/ceph-infra/tasks/configure_firewall.yml +++ b/roles/ceph-infra/tasks/configure_firewall.yml @@ -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 diff --git a/roles/ceph-iscsi-gw/tasks/non-container/prerequisites.yml b/roles/ceph-iscsi-gw/tasks/non-container/prerequisites.yml index cbd7d002f..e0dbaf937 100644 --- a/roles/ceph-iscsi-gw/tasks/non-container/prerequisites.yml +++ b/roles/ceph-iscsi-gw/tasks/non-container/prerequisites.yml @@ -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: diff --git a/roles/ceph-mon/tasks/ceph_keys.yml b/roles/ceph-mon/tasks/ceph_keys.yml index 84ff97773..8569c2f59 100644 --- a/roles/ceph-mon/tasks/ceph_keys.yml +++ b/roles/ceph-mon/tasks/ceph_keys.yml @@ -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: diff --git a/roles/ceph-nfs/tasks/pre_requisite_non_container.yml b/roles/ceph-nfs/tasks/pre_requisite_non_container.yml index 9b905aa6a..9b00c1377 100644 --- a/roles/ceph-nfs/tasks/pre_requisite_non_container.yml +++ b/roles/ceph-nfs/tasks/pre_requisite_non_container.yml @@ -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: diff --git a/roles/ceph-nfs/tasks/pre_requisite_non_container_debian.yml b/roles/ceph-nfs/tasks/pre_requisite_non_container_debian.yml index 784562cee..6c9e8d18d 100644 --- a/roles/ceph-nfs/tasks/pre_requisite_non_container_debian.yml +++ b/roles/ceph-nfs/tasks/pre_requisite_non_container_debian.yml @@ -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' diff --git a/roles/ceph-nfs/tasks/pre_requisite_non_container_red_hat.yml b/roles/ceph-nfs/tasks/pre_requisite_non_container_red_hat.yml index 9878f16bc..719812bed 100644 --- a/roles/ceph-nfs/tasks/pre_requisite_non_container_red_hat.yml +++ b/roles/ceph-nfs/tasks/pre_requisite_non_container_red_hat.yml @@ -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: diff --git a/roles/ceph-osd/tasks/start_osds.yml b/roles/ceph-osd/tasks/start_osds.yml index 06215f20f..ede90d654 100644 --- a/roles/ceph-osd/tasks/start_osds.yml +++ b/roles/ceph-osd/tasks/start_osds.yml @@ -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 diff --git a/roles/ceph-osd/tasks/system_tuning.yml b/roles/ceph-osd/tasks/system_tuning.yml index e956b35b9..6a825fd61 100644 --- a/roles/ceph-osd/tasks/system_tuning.yml +++ b/roles/ceph-osd/tasks/system_tuning.yml @@ -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: diff --git a/roles/ceph-validate/tasks/check_devices.yml b/roles/ceph-validate/tasks/check_devices.yml index a8122021c..7e0803caf 100644 --- a/roles/ceph-validate/tasks/check_devices.yml +++ b/roles/ceph-validate/tasks/check_devices.yml @@ -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: diff --git a/roles/ceph-validate/tasks/check_system.yml b/roles/ceph-validate/tasks/check_system.yml index 704cb3e6d..8cea2648a 100644 --- a/roles/ceph-validate/tasks/check_system.yml +++ b/roles/ceph-validate/tasks/check_system.yml @@ -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: diff --git a/roles/ceph-validate/tasks/main.yml b/roles/ceph-validate/tasks/main.yml index 935bd560b..3150ca6e4 100644 --- a/roles/ceph-validate/tasks/main.yml +++ b/roles/ceph-validate/tasks/main.yml @@ -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: