]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
"when" keyword should precede "block" keyword
authorRishabh Dave <ridave@redhat.com>
Thu, 28 Mar 2019 08:13:30 +0000 (13:43 +0530)
committermergify[bot] <mergify[bot]@users.noreply.github.com>
Fri, 29 Mar 2019 16:16:04 +0000 (16:16 +0000)
Otherwise the reader is forced to search for "when" when blocks are too
long.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
16 files changed:
roles/ceph-common/tasks/configure_cluster_name.yml
roles/ceph-config/tasks/main.yml
roles/ceph-container-common/tasks/pre_requisites/prerequisites.yml
roles/ceph-facts/tasks/facts.yml
roles/ceph-facts/tasks/set_radosgw_address.yml
roles/ceph-infra/tasks/configure_firewall.yml
roles/ceph-iscsi-gw/tasks/non-container/prerequisites.yml
roles/ceph-mon/tasks/ceph_keys.yml
roles/ceph-nfs/tasks/pre_requisite_non_container.yml
roles/ceph-nfs/tasks/pre_requisite_non_container_debian.yml
roles/ceph-nfs/tasks/pre_requisite_non_container_red_hat.yml
roles/ceph-osd/tasks/start_osds.yml
roles/ceph-osd/tasks/system_tuning.yml
roles/ceph-validate/tasks/check_devices.yml
roles/ceph-validate/tasks/check_system.yml
roles/ceph-validate/tasks/main.yml

index 16b3f587cd9cc833f1dba5eb115be1d3345f8c2e..93d00a6dfde88c9b86167d8b6d818e72d34b3936 100644 (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"
index 46294b9badb8ceb184ca83ddf42b5fc36ee70ee4..0fa3c833a02a3154a422537f77d2430fd031afe7 100644 (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 }}"
       - 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"
     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 }}"
       - restart ceph rgws
       - restart ceph mgrs
       - restart ceph rbdmirrors
-
-  when:
-    - containerized_deployment|bool
index e6d001a873edfe84df663401bef8f1bb87cbd707..2b83815ffa5d9886d82df5ae77801831e6ada7b6 100644 (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
       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
       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:
       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:
index b55c2d314cd434277fcd7acd68433696cceb1eae..96cf69f1cc0b5c4288c4e3ce14f4a5389affd56e 100644 (file)
   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
     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 }}"
index b0dcd03316b82fbf0e1332589ee9886c4a6fc6b5..c0ee159d35fea75750dc4d4183f9748e61436370 100644 (file)
     - 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'
index a8d9ccbff91726517fc4026aab3091b31faa1a93..6bfe58047998633cfb393fc5b05c5c1e309abf9c 100644 (file)
   when:
     - not containerized_deployment
 
-- block:
+- when:
+    - (firewalld_pkg_query.get('rc', 1) == 0
+      or is_atomic)
+  block:
   - name: start firewalld
     service:
       name: firewalld
     tags:
       - firewall
 
-  when:
-    - (firewalld_pkg_query.get('rc', 1) == 0
-      or is_atomic)
-
 - meta: flush_handlers
index cbd7d002f49730365ec5da297a7eb9d39c321e0b..e0dbaf9371fc958d607cb6dcf5faea5f88670dd5 100644 (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:
           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:
index 84ff977730e4a7d3cc938ff75135bb51a6da9d7f..8569c2f59c67d7b1a2d169de9574883b60a7cfe2 100644 (file)
   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:
index 9b905aa6aab35b65f05dc2d7e57486478257461f..9b00c1377947e4c1fc6504714cb4e6a8ea5d6023 100644 (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
             owner: "ceph"
             group: "ceph"
             mode: "0600"
-      when:
-        - nfs_obj_gw
-  when:
-    - cephx
 
 - name: change ownership on /var/log/ganesha
   file:
index 784562cee3a7ed647e8b712e9513dc337310a42d..6c9e8d18df7a900ee9ea1712b9d8d72c82d600ed 100644 (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:
           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:
             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:
           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:
           until: result is succeeded
           when:
             - nfs_obj_gw
-      when:
-        - (ceph_origin == 'repository' or ceph_origin == 'distro')
-        - ceph_repository == 'rhcs'
index 9878f16bc5439b2bb38a0f1ed0bdd9c7e9e6b660..719812bedc2bb2a3e06fe672ad38ae4a817805c8 100644 (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:
index 06215f20ff0a3ac5076c5d3121ea49e5e84538ef..ede90d654614a24b01bf7043d8850e05f3ce8f7f 100644 (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
index e956b35b950d18f18acf61052a01dfa23f77d9c5..6a825fd61663a6dc359268d6e520064c8e1434ba 100644 (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:
index a8122021c0b7e37e4deb0b09b88f9eff9c5b815d..7e0803cafa0246c34c03e26f817138c33f7de65e 100644 (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:
index 704cb3e6d11d60416ef5db0ea28aa3fc8d17cd40..8cea2648ac2b526695da3bf2ab0160d8aded744e 100644 (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
             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:
index 935bd560b29de49bfa613429553db3436e102e9a..3150ca6e4a78724e5b1eb6c246d59231302ff7ad 100644 (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: