Unlink proper path to ansible cache

os.listdir returns dirents relative to the dir being listed. We need to
give full path to these entries when unlinking them. Do this by joining
the inventory_cache_dir path to each inventory_cache file.

Change-Id: I78376cfa3b2aa92641f2685b08616660f523dfaf
This commit is contained in:
Clark Boylan 2018-08-27 12:33:51 -07:00
parent 53e54af451
commit 8627e4e06d
1 changed files with 1 additions and 1 deletions

View File

@ -141,7 +141,7 @@ def bootstrap_server(server, key, name, volume_device, keep,
# Zero the ansible inventory cache so that next run finds the new server
inventory_cache_dir = '/var/cache/ansible/inventory'
for inventory_cache in os.listdir(inventory_cache_dir):
os.unlink(inventory_cache)
os.unlink(os.path.join(inventory_cache_dir, inventory_cache))
with JobDir(keep) as jobdir:
# Update the generated-groups file globally and incorporate it