aboutsummaryrefslogtreecommitdiff
path: root/foreman_ansible_inventory.py
diff options
context:
space:
mode:
authorWayne Witzel III <wayne@riotousliving.com>2016-04-05 11:03:53 -0400
committerWayne Witzel III <wayne@riotousliving.com>2016-04-05 14:28:27 -0400
commitabf235f1f4d274c846ce0f0cbe587006fcd8090f (patch)
tree152764ab0ef7066cca84cceee14cdd7a38fb446a /foreman_ansible_inventory.py
parent085db1429da054c5c7f7e26a7b3fbbbce1a358f7 (diff)
read foreman.ini from environment if set
Diffstat (limited to 'foreman_ansible_inventory.py')
-rwxr-xr-xforeman_ansible_inventory.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/foreman_ansible_inventory.py b/foreman_ansible_inventory.py
index e2a53c3..bece7c7 100755
--- a/foreman_ansible_inventory.py
+++ b/foreman_ansible_inventory.py
@@ -87,9 +87,16 @@ class ForemanInventory(object):
""" Reads the settings from the foreman.ini file """
config = ConfigParser.SafeConfigParser()
- config.read(
- ["/etc/ansible/foreman.ini",
- os.path.dirname(os.path.realpath(__file__)) + '/foreman.ini'])
+ config_paths = [
+ "/etc/ansible/foreman.ini",
+ os.path.dirname(os.path.realpath(__file__)) + '/foreman.ini',
+ ]
+
+ env_value = os.environ.get('FOREMAN_INI_PATH')
+ if env_value is not None:
+ config_paths.append(os.path.expanduser(os.path.expandvars(env_value)))
+
+ config.read(config_paths)
# Foreman API related
self.foreman_url = config.get('foreman', 'url')