]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
Resolve issues when groups names not in default value. 1391/head
authorKonstantin Shalygin <k0ste@k0ste.ru>
Fri, 24 Mar 2017 06:40:15 +0000 (13:40 +0700)
committerKonstantin Shalygin <k0ste@k0ste.ru>
Mon, 27 Mar 2017 14:44:30 +0000 (21:44 +0700)
infrastructure-playbooks/cluster-os-migration.yml
infrastructure-playbooks/rolling_update.yml
infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml
roles/ceph-mon/tasks/ceph_keys.yml
roles/ceph-mon/tasks/docker/main.yml
roles/ceph-mon/tasks/docker/start_docker_monitor.yml
roles/ceph-mon/tasks/main.yml
roles/ceph-nfs/tasks/docker/main.yml
roles/ceph-rgw/tasks/docker/copy_configs.yml

index 53430e33ec6078f800253cdb4db0ad65184bb9d8..a030fa3f3bcfa3438273e125ba6a6a2ab660ab11 100644 (file)
     - name: Set the noout flag
       command: ceph osd set noout
       delegate_to: "{{ item }}"
-      with_items: "{{ groups.mons[0] }}"
+      with_items: "{{ groups[mon_group_name][0] }}"
       when: migration_completed.stat.exists == False
 
     - name: Check if sysvinit
     - name: Unset the noout flag
       command: ceph osd unset noout
       delegate_to: "{{ item }}"
-      with_items: "{{ groups.mons[0] }}"
+      with_items: "{{ groups[mon_group_name][0] }}"
       when: migration_completed.stat.exists == False
 
 - hosts: rgws
index b351b66d398952bb2f154e6bee281a80e63b011e..4d973444d60e29da06d30911b85bf680f5bed7f1 100644 (file)
@@ -62,7 +62,7 @@
 
   pre_tasks:
     - name: set mon_host_count
-      set_fact: mon_host_count={{ groups.mons | length }}
+      set_fact: mon_host_count={{ groups[mon_group_name] | length }}
 
     - debug: msg="WARNING - upgrading a ceph cluster with only one monitor node ({{ inventory_hostname }})"
       when: mon_host_count | int == 1
         - mon_containerized_deployment
 
     - name: set mon_host_count
-      set_fact: mon_host_count={{ groups.mons | length }}
+      set_fact: mon_host_count={{ groups[mon_group_name] | length }}
 
     - name: select a running monitor if multiple monitors
       set_fact: mon_host={{ item }}
-      with_items: "{{ groups.mons }}"
+      with_items: "{{ groups[mon_group_name] }}"
       when:
         - mon_host_count | int > 1
         - item != inventory_hostname
 
     - name: select first monitor if only one monitor
       set_fact: mon_host={{ item }}
-      with_items: "{{ groups.mons[0] }}"
+      with_items: "{{ groups[mon_group_name][0] }}"
       when:
         - mon_host_count | int == 1
 
         - noout
         - noscrub
         - nodeep-scrub
-      delegate_to: "{{ groups.mons[0] }}"
+      delegate_to: "{{ groups[mon_group_name][0] }}"
       when: not mon_containerized_deployment
 
     - name: set containerized osd flags
       command: |
-          docker exec ceph-osd-{{ hostvars[groups.mons[0]]['ansible_hostname'] }} ceph osd set {{ item }} --cluster {{ cluster }}
+          docker exec ceph-osd-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }} ceph osd set {{ item }} --cluster {{ cluster }}
       with_items:
         - noout
         - noscrub
         - nodeep-scrub
-      delegate_to: "{{ groups.mons[0] }}"
+      delegate_to: "{{ groups[mon_group_name][0] }}"
       when: mon_containerized_deployment
 
     - name: get osd numbers
       until: result.rc == 0
       retries: "{{ health_osd_check_retries }}"
       delay: "{{ health_osd_check_delay }}"
-      delegate_to: "{{ groups.mons[0] }}"
+      delegate_to: "{{ groups[mon_group_name][0] }}"
       when: not osd_containerized_deployment
 
     - name: container - waiting for clean pgs...
       shell: |
-        test "$(docker exec ceph-osd-{{ hostvars[groups.mons[0]]['ansible_hostname'] }} ceph pg stat --cluster {{ cluster }} | sed 's/^.*pgs://;s/active+clean.*//;s/ //')" -eq "$(docker exec {{ hostvars[groups.mons[0]]['ansible_hostname'] }} ceph pg stat --cluster {{ cluster }} | sed 's/pgs.*//;s/^.*://;s/ //')" && docker exec {{ hostvars[groups.mons[0]]['ansible_hostname'] }} ceph health --cluster {{ cluster }}  | egrep -sq "HEALTH_OK|HEALTH_WARN"
+        test "$(docker exec ceph-osd-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }} ceph pg stat --cluster {{ cluster }} | sed 's/^.*pgs://;s/active+clean.*//;s/ //')" -eq "$(docker exec {{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }} ceph pg stat --cluster {{ cluster }} | sed 's/pgs.*//;s/^.*://;s/ //')" && docker exec {{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }} ceph health --cluster {{ cluster }}  | egrep -sq "HEALTH_OK|HEALTH_WARN"
       register: result
       until: result.rc == 0
       retries: "{{ health_osd_check_retries }}"
       delay: "{{ health_osd_check_delay }}"
-      delegate_to: "{{ groups.mons[0] }}"
+      delegate_to: "{{ groups[mon_group_name][0] }}"
       when: osd_containerized_deployment
 
     - name: unset osd flags
         - noout
         - noscrub
         - nodeep-scrub
-      delegate_to: "{{ groups.mons[0] }}"
+      delegate_to: "{{ groups[mon_group_name][0] }}"
       when: not osd_containerized_deployment
 
     - name: unset containerized osd flags
       command: |
-          docker exec ceph-osd-{{ hostvars[groups.mons[0]]['ansible_hostname'] }} ceph osd unset {{ item }} --cluster {{ cluster }}
+          docker exec ceph-osd-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }} ceph osd unset {{ item }} --cluster {{ cluster }}
       with_items:
         - noout
         - noscrub
         - nodeep-scrub
-      delegate_to: "{{ groups.mons[0] }}"
+      delegate_to: "{{ groups[mon_group_name][0] }}"
       when: osd_containerized_deployment
 
 
index 876d7302195a9aa69f96e80f249e86278fec5a37..18d9da08a0687568fa36fda296a77ad86321d242 100644 (file)
@@ -98,7 +98,7 @@
 
   - name: select a running monitor
     set_fact: mon_host={{ item }}
-    with_items: "{{ groups.mons }}"
+    with_items: "{{ groups[mon_group_name] }}"
     when: item != inventory_hostname
 
   - name: get current ceph fsid
     retries: 10
     delay: 10
     changed_when: false
-    delegate_to: "{{ groups.mons[0] }}"
+    delegate_to: "{{ groups[mon_group_name][0] }}"
 
 
 - name: switching from non-containerized to containerized ceph mds
index 67a6823e308e38ea50ab5b7c43d798a31b5a3508..732b5af14062efce0ba8ffee12c3d98fe120db9b 100644 (file)
@@ -68,7 +68,7 @@
 - include: openstack_config.yml
   when:
     - openstack_config
-    - inventory_hostname == groups.mons|last
+    - "{{ inventory_hostname == groups[mon_group_name] | last }}"
 
 - name: find ceph keys
   shell: ls -1 /etc/ceph/*.keyring
index aa3fbeddcd661b26c77576cb16ee71ce8bea48f8..d2265eda7df3e940706ac78330d3901a8526a035 100644 (file)
 
 - name: force peer addition as potential bootstrap peer for cluster bringup
   command: docker exec ceph-mon-{{ ansible_hostname }} ceph --admin-daemon /var/run/ceph/{{ cluster }}-mon.{{ ansible_fqdn }}.asok add_bootstrap_peer_hint {{ hostvars[item]['ansible_' + ceph_mon_docker_interface].ipv4.address }}
-  with_items: "{{ groups.mons }}"
+  with_items: "{{ groups[mon_group_name] }}"
   changed_when: false
   failed_when: false
   when:
-    - inventory_hostname == groups.mons[0]
+    - "{{ inventory_hostname == groups[mon_group_name][0] }}"
     - not mon_containerized_deployment_with_kv
 
 - include: copy_configs.yml
@@ -78,7 +78,7 @@
     - cephx
     - mon_containerized_deployment
     - groups[restapi_group_name] is defined
-    - inventory_hostname == groups.mons|last
+    - "{{ inventory_hostname == groups[mon_group_name] | last }}"
     - not mon_containerized_deployment_with_kv
 
 - include: "{{ playbook_dir }}/roles/ceph-mon/tasks/set_osd_pool_default_pg_num.yml"
@@ -87,4 +87,4 @@
 - include: "{{ playbook_dir }}/roles/ceph-mon/tasks/openstack_config.yml"
   when:
     - openstack_config
-    - inventory_hostname == groups.mons|last
+    - "{{ inventory_hostname == groups[mon_group_name] | last }}"
index 6339a1b6a612d3390667b24fccb0c669e6792f88..fcd8af4b4b61c83012cf7ac87544460bf4e3d277 100644 (file)
@@ -11,7 +11,7 @@
       KV_PORT: "{{kv_port}}"
   run_once: true
   when:
-    - inventory_hostname == groups.mons[0]
+    - "{{ inventory_hostname == groups[mon_group_name][0] }}"
     - mon_containerized_deployment_with_kv
     - mon_containerized_default_ceph_conf_with_kv
 
@@ -29,7 +29,7 @@
       - /etc/ceph/"{{ cluster }}".conf:/etc/ceph/ceph.defaults
   run_once: true
   when:
-    - inventory_hostname == groups.mons[0]
+    - "{{ inventory_hostname == groups[mon_group_name][0] }}"
     - mon_containerized_deployment_with_kv
     - not mon_containerized_default_ceph_conf_with_kv
 
index 9d7c5c81a62263957bb8b7d07557d43ef308727f..0c6f75ec01640a4288a1e2700aeaed84b8989758 100644 (file)
@@ -15,7 +15,7 @@
     - not mon_containerized_deployment
     - groups[mds_group_name] is defined
     - "{{ groups[mds_group_name]|length > 0 }}"
-    - inventory_hostname == groups.mons|last
+    - "{{ inventory_hostname == groups[mon_group_name] | last }}"
 
 - include: secure_cluster.yml
   when:
index 2bff17fa736918ee081fa1af1159e9d3f53ea736..314614b3639555de339d6cf7273e85ffd55da074 100644 (file)
@@ -41,7 +41,7 @@
 # let the first ganesha create configs and users
 - include: create_configs.yml
   when:
-    inventory_hostname == groups.nfss[0] and
+    inventory_hostname == groups[nfs_group_name][0] and
     not mon_containerized_default_ceph_conf_with_kv
 
 # Copy Ganesha configs to host
index 757648a2e78f141d2ff0e60239b99db47368be6f..a05d638ae1ed82cfbc78276d11ef0d130374ab50 100644 (file)
@@ -9,7 +9,7 @@
   wait_for: path="/var/lib/ceph/radosgw/{{ ansible_hostname }}/keyring"
   when:
     - nfs_obj_gw
-    - inventory_hostname == groups.rgws[0]
+    - inventory_hostname == groups[rgw_group_name][0]
 
 - name: stat for config and keys
   local_action: stat path={{ fetch_directory }}/docker_mon_files/{{ item }}
@@ -21,7 +21,7 @@
   register: statconfig
   when:
     - nfs_obj_gw
-    - inventory_hostname == groups.rgws[0]
+    - inventory_hostname == groups[rgw_group_name][0]
 
 - name: push ceph files to the ansible server
   fetch:
@@ -34,4 +34,4 @@
   when:
     - nfs_obj_gw
     - item.1.stat.exists == false
-    - inventory_hostname == groups.rgws[0]
+    - inventory_hostname == groups[rgw_group_name][0]