]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
playbook: homogenize the way list osd ids 1404/head
authorSébastien Han <seb@redhat.com>
Thu, 30 Mar 2017 09:51:38 +0000 (11:51 +0200)
committerSébastien Han <seb@redhat.com>
Thu, 30 Mar 2017 09:51:38 +0000 (11:51 +0200)
Problem: too many different commands to do the same thing. The 'cut'
command on infrastructure-playbooks/purge-cluster.yml was also wrong.
This sed command from osixia in ceph-docker
https://github.com/ceph/ceph-docker/pull/580/ addresses all the
scenarios.

Signed-off-by: Sébastien Han <seb@redhat.com>
infrastructure-playbooks/purge-cluster.yml
infrastructure-playbooks/rolling_update.yml
infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml
roles/ceph-common/handlers/restart-osd.yml
roles/ceph-common/handlers/validate-osd.yml
roles/ceph-osd/tasks/activate_osds.yml
tests/conftest.py

index df68836b1e6788eb4307957d2d5939854f80f5f5..6fe42ded1a9cd5b074cf8aef9aa0bbd8176005af 100644 (file)
       - osd_auto_discovery
 
   - name: get osd numbers
-    shell: "if [ -d /var/lib/ceph/osd ] ; then ls /var/lib/ceph/osd | cut -d '-' -f 2 ; fi"
+    shell: "if [ -d /var/lib/ceph/osd ] ; then ls /var/lib/ceph/osd | sed 's/.*-//' ; fi"
     register: osd_ids
     changed_when: false
 
     when: ansible_service_mgr == 'sysvinit'
 
   - name: stop ceph osds on ubuntu
-    shell: |
-      for id in $(ls /var/lib/ceph/osd/ |grep -oP '\d+$'); do
-        initctl stop ceph-osd cluster={{ cluster }} id=$id
-      done
+    command: initctl stop ceph-osd cluster={{ cluster }} id={{ item }}
     failed_when: false
     when: ansible_service_mgr == 'upstart'
     with_items: "{{ osd_ids.stdout_lines }}"
index 4d973444d60e29da06d30911b85bf680f5bed7f1..3e6cf688699560879cc81021d492ef7636610b14 100644 (file)
       when: mon_containerized_deployment
 
     - name: get osd numbers
-      shell: "if [ -d /var/lib/ceph/osd ] ; then ls /var/lib/ceph/osd | cut -d '-' -f 2 ; fi"
+      shell: "if [ -d /var/lib/ceph/osd ] ; then ls /var/lib/ceph/osd | sed 's/.*-//' ; fi"
       register: osd_ids
       changed_when: false
       when: not osd_containerized_deployment
 
   post_tasks:
     - name: get osd numbers
-      shell: "if [ -d /var/lib/ceph/osd ] ; then ls /var/lib/ceph/osd | cut -d '-' -f 2 ; fi"
+      shell: "if [ -d /var/lib/ceph/osd ] ; then ls /var/lib/ceph/osd | sed 's/.*-//' ; fi"
       register: osd_ids
       changed_when: false
       when: not osd_containerized_deployment
index 18d9da08a0687568fa36fda296a77ad86321d242..e578614c0acbcf7bd2943cda07c106d070d81a27 100644 (file)
 
   - name: collect osd ids
     shell: |
-      if [ -d /var/lib/ceph/osd ] ; then ls /var/lib/ceph/osd | cut -d '-' -f 2 ; fi
+      if [ -d /var/lib/ceph/osd ] ; then ls /var/lib/ceph/osd | sed 's/.*-//' ; fi
     register: osd_ids
     changed_when: false
 
index 89c05303b1526ad58a87cfddbc9238620a47956f..93641f92696c3c497f5966d81e980956880aae99 100644 (file)
@@ -4,7 +4,7 @@
 # for restarting them specifically.
 - name: restart ceph osds
   shell: |
-    for id in $(ls /var/lib/ceph/osd/ |grep -oP '\d+$'); do
+    for id in $(ls /var/lib/ceph/osd/ | sed 's/.*-//'); do
       systemctl restart ceph-osd@$id
       sleep 5
     done
index 88881212c11a60ee3b594bfb97c0bf4c943f875f..aefe1b9bef270c93ccda71465b41b50924295075 100644 (file)
@@ -1,7 +1,7 @@
 ---
 - name: collect osds
   shell: |
-    ls /var/lib/ceph/osd/ |grep -oP '\d+$'
+    ls /var/lib/ceph/osd/ | sed 's/.*-//'
   register: osd_ids
 
 - name: wait for ceph osd socket(s)
index bb4b8ca9fbc8c7e6b89caa1487664dfb85ee2869..4e8dd1aae702100d29ed76dc93593e314830cfad 100644 (file)
@@ -82,7 +82,8 @@
   when: crush_location
 
 - name: get osd id
-  shell: 'ls /var/lib/ceph/osd/ | grep -oP "\d+$"'
+  shell: |
+    ls /var/lib/ceph/osd/ | sed 's/.*-//'
   changed_when: false
   failed_when: false
   always_run: true
index 390695bf7279e465786fb8435ba051f1ab19fb6b..4899fbcd664e74c7f0dfc56d5515fd1ecf098440 100644 (file)
@@ -42,7 +42,7 @@ def node(Ansible, Interface, Command, request):
         # boxes we test with use that interface. OSDs are the only
         # nodes that have this interface.
         cluster_address = Interface("eth2").addresses[0]
-        cmd = Command('sudo ls /var/lib/ceph/osd/ | grep -oP "\d+$"')
+        cmd = Command('sudo ls /var/lib/ceph/osd/ | sed "s/.*-//"')
         if cmd.rc == 0:
             osd_ids = cmd.stdout.rstrip("\n").split("\n")
             osds = osd_ids