Skip to content

Commit

Permalink
Don't strip last part of inventory_path if it's already a dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferry Boender committed Nov 13, 2017
1 parent 78d359b commit 7bad79c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/ansiblecmdb/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,13 @@ def _parse_hostvar_dir(self, inventory_path):
"""
Parse host_vars dir, if it exists.
"""
path = os.path.join(os.path.dirname(inventory_path), 'host_vars')
# inventory_path could point to a `hosts` file, or to a dir. So we
# construct the location to the `host_vars` differently.
if os.path.isdir(inventory_path):
path = os.path.join(inventory_path, 'host_vars')
else:
path = os.path.join(os.path.dirname(inventory_path, 'host_vars'))

self.log.debug("Parsing host vars (dir): {0}".format(path))
if not os.path.exists(path):
self.log.warning("No such dir {0}".format(path))
Expand Down Expand Up @@ -193,7 +199,13 @@ def _parse_groupvar_dir(self, inventory_path):
"""
Parse group_vars dir, if it exists. Encrypted vault files are skipped.
"""
path = os.path.join(os.path.dirname(inventory_path), 'group_vars')
# inventory_path could point to a `hosts` file, or to a dir. So we
# construct the location to the `group_vars` differently.
if os.path.isdir(inventory_path):
path = os.path.join(inventory_path, 'group_vars')
else:
path = os.path.join(os.path.dirname(inventory_path), 'group_vars')

self.log.debug("Parsing group vars (dir): {0}".format(path))
if not os.path.exists(path):
self.log.warning("No such dir {0}".format(path))
Expand Down

0 comments on commit 7bad79c

Please sign in to comment.