Optimise the destroy role by script module

Ansible provide script module to run shell script, The local script at
path will be transferred to the remote node and then executed, so no
need to copy script to remote node and use shell moulde to run it.
this patch optimise it.

Change-Id: If774502b66652f25593cda137cc8a5baefbd9695
This commit is contained in:
caoyuan 2018-01-16 12:58:17 +08:00
parent 95cd334707
commit 8f2256d299
6 changed files with 12 additions and 50 deletions

@ -1,3 +1,3 @@
---
- name: Destroying all Kolla containers and volumes
command: /tmp/kolla-cleanup/tools/cleanup-containers
script: ../tools/cleanup-containers

@ -1,17 +1,12 @@
---
- name: Destroying Kolla host configuration
become: true
command: >
env enable_haproxy={{ enable_haproxy }}
enable_swift={{ enable_swift }}
glance_file_datadir_volume={{ glance_file_datadir_volume }}
kolla_internal_vip_address={{ kolla_internal_vip_address }}
kolla_external_vip_address={{ kolla_external_vip_address }}
kolla_dev_repos_directory={{ kolla_dev_repos_directory }}
destroy_include_dev={{ destroy_include_dev }}
/tmp/kolla-cleanup/tools/cleanup-host
- name: Destroying kolla-cleanup folder
file:
path: /tmp/kolla-cleanup
state: absent
script: ../tools/cleanup-host
environment:
enable_haproxy: "{{ enable_haproxy }}"
enable_swift: "{{ enable_swift }}"
glance_file_datadir_volume: "{{ glance_file_datadir_volume }}"
kolla_internal_vip_address: "{{ kolla_internal_vip_address }}"
kolla_external_vip_address: "{{ kolla_external_vip_address }}"
kolla_dev_repos_directory: "{{ kolla_dev_repos_directory }}"
destroy_include_dev: "{{ destroy_include_dev }}"

@ -1,5 +1,5 @@
---
- name: Removing Kolla images
command: /tmp/kolla-cleanup/tools/cleanup-images --all
script: ../tools/cleanup-images --all
when:
- destroy_include_images | bool

@ -1,31 +0,0 @@
---
- name: Creating /kolla-cleanup/tools directory on node
file:
state: directory
path: /tmp/kolla-cleanup/tools
- name: Copying validate-docker-execute.sh file
copy:
src: ../tools/validate-docker-execute.sh
dest: /tmp/kolla-cleanup/tools
mode: 0755
- name: Copying cleanup-containers file
copy:
src: ../tools/cleanup-containers
dest: /tmp/kolla-cleanup/tools
mode: 0755
- name: Copying cleanup-host file
copy:
src: ../tools/cleanup-host
dest: /tmp/kolla-cleanup/tools
mode: 0755
- name: Copying cleanup-images file
copy:
src: ../tools/cleanup-images
dest: /tmp/kolla-cleanup/tools
mode: 0755
when:
- destroy_include_images | bool

@ -1,6 +1,4 @@
---
- include: copy_tools.yml
- include: validate_docker_execute.yml
- include: cleanup_containers.yml

@ -1,3 +1,3 @@
---
- name: Ensure the docker service is running
command: /tmp/kolla-cleanup/tools/validate-docker-execute.sh
script: ../tools/validate-docker-execute.sh