Change heketi-tear-down to run on nodes instead of localhost delegate_to

This commit is contained in:
Simon Li 2018-07-27 16:33:43 +01:00 committed by Sascha Marcel Schmidt
parent 8ac57201a7
commit d284961d47
No known key found for this signature in database
GPG key ID: D1D6CE184437796D
3 changed files with 12 additions and 17 deletions

View file

@ -1,4 +1,9 @@
--- ---
- hosts: localhost - hosts: kube-master[0]
roles: roles:
- { role: tear-down } - { role: tear-down }
- hosts: heketi-node
become: yes
roles:
- { role: tear-down-disks }

View file

@ -1,6 +1,5 @@
--- ---
- name: "Install lvm utils (RedHat)" - name: "Install lvm utils (RedHat)"
delegate_to: "{{ node }}"
become: true become: true
yum: yum:
name: "lvm2" name: "lvm2"
@ -8,34 +7,31 @@
when: "ansible_os_family == 'RedHat'" when: "ansible_os_family == 'RedHat'"
- name: "Install lvm utils (Debian)" - name: "Install lvm utils (Debian)"
delegate_to: "{{ node }}"
become: true become: true
apt: apt:
name: "lvm2" name: "lvm2"
state: "present" state: "present"
when: "ansible_os_family == 'Debian'" when: "ansible_os_family == 'Debian'"
- name: "Get volume group information." - name: "Get volume group information."
delegate_to: "{{ node }}"
become: true become: true
shell: "pvs {{ disk }} --option vg_name | tail -n+2" shell: "pvs {{ disk_volume_device_1 }} --option vg_name | tail -n+2"
vars: { disk: "{{ hostvars[node]['disk_volume_device_1'] }}" }
register: "volume_groups" register: "volume_groups"
ignore_errors: true ignore_errors: true
changed_when: false changed_when: false
- name: "Remove volume groups." - name: "Remove volume groups."
delegate_to: "{{ node }}"
become: true become: true
command: "vgremove {{ volume_group }} --yes" command: "vgremove {{ volume_group }} --yes"
with_items: "{{ volume_groups.stdout_lines }}" with_items: "{{ volume_groups.stdout_lines }}"
loop_control: { loop_var: "volume_group" } loop_control: { loop_var: "volume_group" }
- name: "Remove physical volume from cluster disks." - name: "Remove physical volume from cluster disks."
delegate_to: "{{ node }}"
become: true become: true
command: "pvremove {{ disk }} --yes" command: "pvremove {{ disk_volume_device_1 }} --yes"
vars: { disk: "{{ hostvars[node]['disk_volume_device_1'] }}" }
ignore_errors: true ignore_errors: true
- name: "Remove lvm utils (RedHat)" - name: "Remove lvm utils (RedHat)"
delegate_to: "{{ node }}"
become: true become: true
yum: yum:
name: "lvm2" name: "lvm2"
@ -43,7 +39,6 @@
when: "ansible_os_family == 'RedHat'" when: "ansible_os_family == 'RedHat'"
- name: "Remove lvm utils (Debian)" - name: "Remove lvm utils (Debian)"
delegate_to: "{{ node }}"
become: true become: true
apt: apt:
name: "lvm2" name: "lvm2"

View file

@ -49,8 +49,3 @@
command: "{{ bin_dir }}/kubectl delete secret {{ secrets.stdout|from_json|json_query(storage_query) }}" command: "{{ bin_dir }}/kubectl delete secret {{ secrets.stdout|from_json|json_query(storage_query) }}"
when: "storage_query is defined" when: "storage_query is defined"
ignore_errors: true ignore_errors: true
- name: "Prepare cluster disks."
include_tasks: "disks.yml"
with_items: "{{ groups['heketi-node'] }}"
loop_control:
loop_var: "node"