]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
Updates to containerized purge cluster playbook 892/head
authorIvan Font <ivan.font@redhat.com>
Fri, 22 Jul 2016 05:29:58 +0000 (22:29 -0700)
committerIvan Font <ivan.font@redhat.com>
Fri, 22 Jul 2016 05:36:42 +0000 (22:36 -0700)
- Update plays to use *_group_name variables that can be overridden by
  user on the command line to use whatever group names desired
- Only gather_facts when necessary to greatly increase speed of playbook
- Prompt user for removing packages on non-atomic hosts only if desired
- Removed unnecessary package-removal
- Zap OSD devices twice to avoid lingering partitions

Signed-off-by: Ivan Font <ivan.font@redhat.com>
purge-docker-cluster.yml

index 29a43778deeb2d7b670fe85bbb842266553bc9a6..82961383c1f2b294a69f2609768344b3fafdebaf 100644 (file)
@@ -7,12 +7,22 @@
   hosts:
     - localhost
 
+  gather_facts: false
+
   vars_prompt:
     - name: ireallymeanit
       prompt: Are you sure you want to purge the cluster?
       default: 'no'
       private: no
 
+    - name: remove_packages
+      prompt: >
+        If --skip-tags=with_pkg is not set docker packages
+        and more will be uninstalled from non-atomic hosts.
+        Do you want to continue?
+      default: 'no'
+      private: no
+
   tasks:
   - name: exit playbook, if user did not mean to purge cluster
     fail:
          invoking the playbook"
     when: ireallymeanit != 'yes'
 
-
-- name: retrieve variables
-
-  hosts:
-    - all
-    - localhost
-
-  tasks:
-    - include_vars: roles/ceph-common/defaults/main.yml
-    - include_vars: roles/ceph-mon/defaults/main.yml
-    - include_vars: roles/ceph-osd/defaults/main.yml
-    - include_vars: roles/ceph-mds/defaults/main.yml
-    - include_vars: roles/ceph-rgw/defaults/main.yml
-    - include_vars: roles/ceph-nfs/defaults/main.yml
-    - include_vars: roles/ceph-restapi/defaults/main.yml
-    - include_vars: group_vars/all
-
-    - name: check if it is Atomic host
-      stat: path=/run/ostree-booted
-      register: stat_ostree
-
-    - name: set fact for using Atomic host
-      set_fact:
-        is_atomic: "{{ stat_ostree.stat.exists }}"
+  - name: exit playbook, if user did not mean to remove packages
+    fail:
+      msg: >
+        "Exiting purge-docker-cluster playbook. No packages were removed.
+         To skip removing packages use --skip-tag=with_pkg. To continue
+         with removing packages, do not specify --skip-tag=with_pkg and
+         either say 'yes' on the prompt or use `-e remove_packages=yes`
+         on the command line when invoking the playbook"
+    when: remove_packages != 'yes'
 
 
 - name: purge ceph mds cluster
 
+  vars:
+    mds_group_name: mdss
+
   hosts:
-    - mdss
+    - "{{ mds_group_name }}"
 
   become: true
 
   tasks:
+  - include_vars: roles/ceph-common/defaults/main.yml
+  - include_vars: roles/ceph-mds/defaults/main.yml
+  - include_vars: group_vars/all
+
   - name: disable ceph mds service
     service:
       name: "ceph-mds@{{ ansible_hostname }}"
     tags:
       remove_img
 
+
 - name: purge ceph rgw cluster
 
+  vars:
+    rgw_group_name: rgws
+
   hosts:
-    - rgws
+    - "{{ rgw_group_name }}"
 
   become: true
 
   tasks:
+  - include_vars: roles/ceph-common/defaults/main.yml
+  - include_vars: roles/ceph-rgw/defaults/main.yml
+  - include_vars: group_vars/all
+
   - name: disable ceph rgw service
     service:
       name: "ceph-rgw@{{ ansible_hostname }}"
     tags:
       remove_img
 
-  - name: remove libnss3-tools on redhat
-    yum:
-      name: libnss3-tools
-      state: absent
-    when:
-      ansible_pkg_mgr == "yum" and
-      radosgw_keystone
-
-  - name: remove libnss3-tools on redhat
-    dnf:
-      name: libnss3-tools
-      state: absent
-    when:
-      ansible_pkg_mgr == "dnf" and
-      radosgw_keystone
-
-  - name: install libnss3-tools on debian
-    apt:
-      name: libnss3-tools
-      state: absent
-    when:
-      ansible_pkg_mgr == 'apt' and
-      radosgw_keystone
-
 
 - name: purge ceph nfs cluster
 
+  vars:
+    nfs_group_name: nfss
+
   hosts:
-    - nfss
+    - "{{ nfs_group_name }}"
 
   become: true
 
   tasks:
+  - include_vars: roles/ceph-common/defaults/main.yml
+  - include_vars: roles/ceph-nfs/defaults/main.yml
+  - include_vars: group_vars/all
+
   - name: disable ceph nfs service
     service:
       name: "ceph-nfs@{{ ansible_hostname }}"
 
 - name: purge ceph osd cluster
 
+  vars:
+    osd_group_name: osds
+
   hosts:
-    - osds
+    - "{{ osd_group_name }}"
 
   become: true
 
   tasks:
+  - include_vars: roles/ceph-common/defaults/main.yml
+  - include_vars: roles/ceph-osd/defaults/main.yml
+  - include_vars: group_vars/all
+
   - name: disable ceph osd service
     service:
       name: "ceph-osd@{{ item | basename }}"
       state: absent
     with_items: "{{ ceph_osd_docker_devices }}"
 
+  # zap twice
+  - name: zap ceph osd disk
+    docker:
+      image: "{{ ceph_osd_docker_username }}/{{ ceph_osd_docker_imagename }}:{{ ceph_osd_docker_image_tag }}"
+      name: "{{ ansible_hostname }}-osd-zap-{{ item | regex_replace('/', '') }}"
+      net: host
+      pid: host
+      state: started
+      privileged: yes
+      env: "CEPH_DAEMON=zap_device,OSD_DEVICE={{ item }}"
+      volumes: "/var/lib/ceph:/var/lib/ceph,/etc/ceph:/etc/ceph,/dev:/dev,/run:/run"
+    with_items: "{{ ceph_osd_docker_devices }}"
+
+  - name: remove ceph osd zap disk container
+    docker:
+      image: "{{ ceph_osd_docker_username }}/{{ ceph_osd_docker_imagename }}:{{ ceph_osd_docker_image_tag }}"
+      name: "{{ ansible_hostname }}-osd-zap-{{ item | regex_replace('/', '') }}"
+      state: absent
+    with_items: "{{ ceph_osd_docker_devices }}"
+
   - name: remove ceph osd service
     file:
         path: /etc/systemd/system/ceph-osd@.service
 
 - name: purge ceph mon cluster
 
+  vars:
+    mon_group_name: mons
+
   hosts:
-    - mons
+    - "{{ mon_group_name }}"
 
   become: true
 
   tasks:
+  - include_vars: roles/ceph-common/defaults/main.yml
+  - include_vars: roles/ceph-mon/defaults/main.yml
+  - include_vars: roles/ceph-restapi/defaults/main.yml
+  - include_vars: group_vars/all
+
   - name: disable ceph mon service
     service:
       name: "ceph-mon@{{ ansible_hostname }}"
 
 - name: remove installed packages
 
+  vars:
+    mon_group_name: mons
+    osd_group_name: osds
+    mds_group_name: mdss
+    rgw_group_name: rgws
+    nfs_group_name: nfss
+
   hosts:
-    - all
+    - "{{ mon_group_name }}"
+    - "{{ osd_group_name }}"
+    - "{{ mds_group_name }}"
+    - "{{ rgw_group_name }}"
+    - "{{ nfs_group_name }}"
 
   become: true
 
     with_pkg
 
   tasks:
+  - name: check if it is Atomic host
+    stat: path=/run/ostree-booted
+    register: stat_ostree
+
+  - name: set fact for using Atomic host
+    set_fact:
+      is_atomic: "{{ stat_ostree.stat.exists }}"
+
   - name: stop docker service
     service:
       name: docker
 
 - name: purge ceph directories
 
+  vars:
+    mon_group_name: mons
+    osd_group_name: osds
+    mds_group_name: mdss
+    rgw_group_name: rgws
+    nfs_group_name: nfss
+
   hosts:
-    - all
+    - "{{ mon_group_name }}"
+    - "{{ osd_group_name }}"
+    - "{{ mds_group_name }}"
+    - "{{ rgw_group_name }}"
+    - "{{ nfs_group_name }}"
+
+  gather_facts: false # Already gathered previously
 
   become: true
 
   hosts:
     - localhost
 
+  gather_facts: false
+
   tasks:
+  - include_vars: roles/ceph-common/defaults/main.yml
+  - include_vars: group_vars/all
+
   - name: purge fetch directory for localhost
     file:
       path: "{{ fetch_directory }}"