diff options
author | Stepan Andrushko <stepanx.andrushko@intel.com> | 2018-04-16 14:17:54 +0300 |
---|---|---|
committer | Stepan Andrushko <stepanx.andrushko@intel.com> | 2018-04-17 19:50:11 +0300 |
commit | 535aeeb3e3ccffecd0591ef388dbbfea4b51e4c3 (patch) | |
tree | 9e2535f37300c8e056b1e7b98b27c4f9cbaca468 /ansible/roles/infra_destroy_previous_configuration/tasks/main.yml | |
parent | f3f75ea39678b6da24e5ed6a61f77586f71d0128 (diff) |
OpenStack deployment: delete RS or all VMs
New parameter is added to shell script to delete data for VMs either from
input file or all.
Added disk images removal as per new input parameter.
JIRA: YARDSTICK-1123
Change-Id: I8d2cee4a3a7ad7147f4d59303bab656d80370221
Signed-off-by: Stepan Andrushko <stepanx.andrushko@intel.com>
Diffstat (limited to 'ansible/roles/infra_destroy_previous_configuration/tasks/main.yml')
-rw-r--r-- | ansible/roles/infra_destroy_previous_configuration/tasks/main.yml | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/ansible/roles/infra_destroy_previous_configuration/tasks/main.yml b/ansible/roles/infra_destroy_previous_configuration/tasks/main.yml index e6c2c0229..6c4aa33cf 100644 --- a/ansible/roles/infra_destroy_previous_configuration/tasks/main.yml +++ b/ansible/roles/infra_destroy_previous_configuration/tasks/main.yml @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. --- -- name: Include +- name: Include input file include_vars: file: "{{ rs_file }}" name: infra_deploy_vars @@ -25,16 +25,40 @@ virt: command=list_vms register: virt_vms +- set_fact: + deploy_vms: "{{ deploy_vms | default([]) + [item.hostname] }}" + with_items: "{{ infra_deploy_vars.nodes }}" + +- name: Define old disk images to delete + shell: virsh domblklist {{ item }} | awk '/\/.*/ { print $2 }' + when: clean_up | bool or item in deploy_vms + with_items: "{{ virt_vms.list_vms }}" + register: virt_img + +- set_fact: + images: "{{ images | default([]) + item.stdout_lines }}" + when: item.stdout_lines is defined and item.stdout_lines | length > 0 + with_items: "{{ virt_img.results }}" + - name: Destroy old VMs include_tasks: delete_vm.yml - extra_vars: "{{ virt_vms }}" loop_control: - loop_var: node_item - with_items: "{{ infra_deploy_vars.nodes }}" + loop_var: vmhost_item + with_items: "{{ virt_vms.list_vms }}" + +- set_fact: + deploy_nets: "{{ deploy_nets | default([]) + [item.name] }}" + with_items: "{{ infra_deploy_vars.networks }}" - name: Delete old networks include_tasks: delete_network.yml - extra_vars: "{{ virt_nets }}" loop_control: loop_var: network_item - with_items: "{{ infra_deploy_vars.networks }}" + with_items: "{{ virt_nets.list_nets }}" + +- name: Delete old disk images + file: + path: "{{ item }}" + state: absent + when: images is defined and images | length > 0 + with_items: "{{ images }}" |