Skip to content

Commit

Permalink
Remove on-demand yaml import.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferry Boender committed Sep 8, 2017
1 parent b97ff52 commit 2125fa3
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/ansiblecmdb/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,13 @@ def _parse_hostvar_file(self, hostname, path):

def _parse_groupvar_dir(self, inventory_path):
"""
Parse group_vars dir, if it exists. This requires the yaml module, which
is imported on-demand, since it's not a default module.
Parse group_vars dir, if it exists.
"""
self.log.debug("Parsing group vars (dir): {0}".format(os.path.join(inventory_path, 'group_vars')))
path = os.path.join(os.path.dirname(inventory_path), 'group_vars')
if not os.path.exists(path):
return

try:
import yaml
except ImportError:
import yaml3 as yaml

for (dirpath, dirnames, filenames) in os.walk(path):
for filename in filenames:
f_path = os.path.join(path, filename)
Expand Down

0 comments on commit 2125fa3

Please sign in to comment.