--- - name: Confirm removal of the iSCSI gateway configuration hosts: localhost vars_prompt: - name: purge_config # noqa: name[casing] prompt: Which configuration elements should be purged? (all, lio or abort) default: 'abort' private: false tasks: - name: Exit playbook if user aborted the purge ansible.builtin.fail: msg: > "You have aborted the purge of the iSCSI gateway configuration" when: purge_config == 'abort' - name: Set_fact igw_purge_type ansible.builtin.set_fact: igw_purge_type: "{{ purge_config }}" - name: Stopping the gateways hosts: - iscsigws become: true tasks: - name: Stopping and disabling iscsi daemons ansible.builtin.service: name: "{{ item }}" state: stopped enabled: false with_items: - rbd-target-gw - rbd-target-api - tcmu-runner - name: Removing the gateway configuration hosts: - iscsigws become: true 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' ansible.builtin.service: name: "{{ item }}" state: started enabled: true with_items: - tcmu-runner - rbd-target-api - rbd-target-gw - name: Remove the gateways from the ceph dashboard hosts: mons become: true tasks: - name: Import ceph-defaults role ansible.builtin.import_role: name: ceph-defaults - name: Iscsi gateways with ceph dashboard when: dashboard_enabled | bool run_once: true block: - name: Import ceph-facts role ansible.builtin.import_role: name: ceph-facts tasks_from: container_binary - name: Set_fact container_exec_cmd ansible.builtin.set_fact: container_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ ansible_facts['hostname'] }}" when: containerized_deployment | bool - name: Get iscsi gateway list ansible.builtin.command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} dashboard iscsi-gateway-list -f json" changed_when: false register: gateways - name: Remove iscsi gateways ansible.builtin.command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} dashboard iscsi-gateway-rm {{ item }}" with_items: '{{ (gateways.stdout | from_json)["gateways"] }}' changed_when: false