From 00a1e377871a20cd0e3a8d394b21cc2686c509ab Mon Sep 17 00:00:00 2001 From: Adrien Cunin Date: Wed, 29 Nov 2017 10:49:29 +0100 Subject: [PATCH] Added ability to cleanup venv tgz, use find module cleanup-venvs.yml now removes older venv tgz, in addition to older venvs directories. It now uses the more appropriate and efficient find module instead of the shell module. Change-Id: Iab98039a84bb4b0e787c439d67fa81b7e108c3ff --- ansible_tools/playbooks/cleanup-venvs.yml | 35 +++++++++++++++++------ 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/ansible_tools/playbooks/cleanup-venvs.yml b/ansible_tools/playbooks/cleanup-venvs.yml index 2c4d817c..3d904d9e 100644 --- a/ansible_tools/playbooks/cleanup-venvs.yml +++ b/ansible_tools/playbooks/cleanup-venvs.yml @@ -13,17 +13,34 @@ # See the License for the specific language governing permissions and # limitations under the License. ---- - name: Remove older venvs hosts: all tasks: - - name: List older venvs directories - shell: "ls -1 /openstack/venvs | grep -v '{{ venv_tag }}$'" - register: files - when: venv_tag is defined - failed_when: files.rc == 2 - - name: Delete directories + - name: List venvs directories + find: + paths: /openstack/venvs + file_type: directory + patterns: '.*(?