ceph-ansible/infrastructure-playbooks/purge-iscsi-gateways.yml

90 lines
2.3 KiB
YAML
Raw Normal View History

---
- name: Confirm removal of the iSCSI gateway configuration
hosts: localhost
vars_prompt:
- name: purge_config
prompt: Which configuration elements should be purged? (all, lio or abort)
default: 'abort'
private: no
tasks:
- name: Exit playbook if user aborted the purge
fail:
msg: >
"You have aborted the purge of the iSCSI gateway configuration"
when: purge_config == 'abort'
- set_fact:
igw_purge_type: "{{ purge_config }}"
- name: stopping the gateways
hosts:
- iscsigws
become: yes
vars:
- igw_purge_type: "{{hostvars['localhost']['igw_purge_type']}}"
tasks:
- name: stopping and disabling iscsi daemons
service:
name: "{{ item }}"
state: stopped
enabled: no
with_items:
- rbd-target-gw
- rbd-target-api
- tcmu-runner
- name: removing the gateway configuration
hosts:
- iscsigws
become: yes
vars:
- igw_purge_type: "{{ hostvars['localhost']['igw_purge_type'] }}"
tasks:
- name: igw_purge | deleting configured rbd devices
igw_purge: mode="disks"
when: igw_purge_type == 'all'
run_once: true
- name: igw_purge | purging the gateway configuration
igw_purge: mode="gateway"
run_once: true
- name: restart and enable iscsi daemons
when: igw_purge_type == 'lio'
service:
name: "{{ item }}"
state: started
enabled: yes
with_items:
- tcmu-runner
- rbd-target-api
- rbd-target-gw
- name: remove the gateways from the ceph dashboard
hosts: mons
become: true
tasks:
- import_role:
name: ceph-defaults
- name: iscsi gateways with ceph dashboard
when: dashboard_enabled | bool
run_once: true
block:
- import_role:
name: ceph-facts
- name: get iscsi gateway list
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} dashboard iscsi-gateway-list -f json"
changed_when: false
register: gateways
- name: remove iscsi gateways
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} dashboard iscsi-gateway-rm {{ item }}"
with_items: '{{ (gateways.stdout | from_json)["gateways"] }}'