From 8d1f8e4eda9e9c997756c6996c3f5e6848260207 Mon Sep 17 00:00:00 2001 From: jkilpatr Date: Wed, 2 Aug 2017 07:34:43 -0400 Subject: [PATCH] Cleanup temporary files from the gather script The permissions rules for /tmp say that only the process that created a file can delete it, this creates issues rerunning our gather script because we need to overwrite the temporary files as a different process. I'm at a loss as to why we didn't see this before though, maybe the permissions on /tmp in the images we ship have changed recently. Regardless instead of needlessly slapping become: true on every task this patch adds a handler to the common role to go and clean up files before the ansible process exits. Change-Id: I9e8c1a8b030da8319941dea6eb129fa59e6c2d48 --- ansible/gather/roles/common/handlers/main.yml | 15 +++++++++++++++ ansible/gather/roles/common/tasks/main.yml | 3 +++ 2 files changed, 18 insertions(+) create mode 100644 ansible/gather/roles/common/handlers/main.yml diff --git a/ansible/gather/roles/common/handlers/main.yml b/ansible/gather/roles/common/handlers/main.yml new file mode 100644 index 000000000..39b73aba3 --- /dev/null +++ b/ansible/gather/roles/common/handlers/main.yml @@ -0,0 +1,15 @@ +--- +# Cleanup for gather common +# Required to prevent perms issues + +- name: cleanup script + file: + path: /tmp/openstack-config-parser.py + state: absent + become: true + +- name: cleanup varsfile + file: + path: /tmp/out.yml + state: absent + become: true diff --git a/ansible/gather/roles/common/tasks/main.yml b/ansible/gather/roles/common/tasks/main.yml index b7c510c4a..022ebe29c 100644 --- a/ansible/gather/roles/common/tasks/main.yml +++ b/ansible/gather/roles/common/tasks/main.yml @@ -1,6 +1,9 @@ --- - name: Copy config parser script to remote copy: src=openstack-config-parser.py dest=/tmp/openstack-config-parser.py + notify: + - cleanup script + - cleanup varsfile - name: Determine if docker is running shell: docker ps | wc -l