2017-10-08 21:54:36 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
- 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'
|
|
|
|
|
2020-10-02 19:38:04 +08:00
|
|
|
- name: set_fact igw_purge_type
|
|
|
|
set_fact:
|
2017-10-08 21:54:36 +08:00
|
|
|
igw_purge_type: "{{ purge_config }}"
|
|
|
|
|
2019-05-12 06:23:37 +08:00
|
|
|
- name: stopping the gateways
|
2018-08-20 21:53:03 +08:00
|
|
|
hosts:
|
|
|
|
- iscsigws
|
2018-05-25 08:13:20 +08:00
|
|
|
become: yes
|
2017-10-08 21:54:36 +08:00
|
|
|
vars:
|
2020-10-02 19:05:01 +08:00
|
|
|
- igw_purge_type: "{{ hostvars['localhost']['igw_purge_type'] }}"
|
2017-10-08 21:54:36 +08:00
|
|
|
|
|
|
|
tasks:
|
2019-05-12 06:23:37 +08:00
|
|
|
- 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'] }}"
|
2017-10-08 21:54:36 +08:00
|
|
|
|
2019-05-12 06:23:37 +08:00
|
|
|
tasks:
|
2017-10-08 21:54:36 +08:00
|
|
|
- name: igw_purge | deleting configured rbd devices
|
|
|
|
igw_purge: mode="disks"
|
|
|
|
when: igw_purge_type == 'all'
|
2019-05-12 06:23:37 +08:00
|
|
|
run_once: true
|
2017-10-08 21:54:36 +08:00
|
|
|
|
2019-05-12 06:23:37 +08:00
|
|
|
- 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'
|
2018-09-13 04:37:44 +08:00
|
|
|
service:
|
2018-11-09 05:38:08 +08:00
|
|
|
name: "{{ item }}"
|
2019-05-12 06:23:37 +08:00
|
|
|
state: started
|
|
|
|
enabled: yes
|
2018-11-09 05:38:08 +08:00
|
|
|
with_items:
|
2019-05-12 06:23:37 +08:00
|
|
|
- tcmu-runner
|
2018-11-09 05:38:08 +08:00
|
|
|
- rbd-target-api
|
|
|
|
- rbd-target-gw
|
2020-01-07 04:22:51 +08:00
|
|
|
|
|
|
|
- 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
|
2020-01-10 22:31:26 +08:00
|
|
|
tasks_from: container_binary
|
|
|
|
|
|
|
|
- name: set_fact container_exec_cmd
|
|
|
|
set_fact:
|
2021-03-03 22:43:50 +08:00
|
|
|
container_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ ansible_facts['hostname'] }}"
|
2020-01-10 22:31:26 +08:00
|
|
|
when: containerized_deployment | bool
|
2020-01-07 04:22:51 +08:00
|
|
|
|
|
|
|
- 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"] }}'
|