aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--foreman.ini1
-rwxr-xr-xforeman_ansible_inventory.py13
2 files changed, 9 insertions, 5 deletions
diff --git a/foreman.ini b/foreman.ini
index 42312da..f6baf9d 100644
--- a/foreman.ini
+++ b/foreman.ini
@@ -15,4 +15,5 @@ want_facts = True
[cache]
path = .
+filename = foreman_ansible_inventory
max_age = 60
diff --git a/foreman_ansible_inventory.py b/foreman_ansible_inventory.py
index df838e0..0d2acf0 100755
--- a/foreman_ansible_inventory.py
+++ b/foreman_ansible_inventory.py
@@ -153,11 +153,14 @@ class ForemanInventory(object):
cache_path = os.path.expanduser(config.get('cache', 'path'))
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
cache_path = '.'
- (script, ext) = os.path.splitext(os.path.basename(__file__))
- self.cache_path_cache = cache_path + "/%s.cache" % script
- self.cache_path_inventory = cache_path + "/%s.index" % script
- self.cache_path_params = cache_path + "/%s.params" % script
- self.cache_path_facts = cache_path + "/%s.facts" % script
+ try:
+ cache_filename = os.path.expanduser(config.get('cache', 'filename'))
+ except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
+ (cache_filename, ext) = os.path.splitext(os.path.basename(__file__))
+ self.cache_path_cache = cache_path + "/%s.cache" % cache_filename
+ self.cache_path_inventory = cache_path + "/%s.index" % cache_filename
+ self.cache_path_params = cache_path + "/%s.params" % cache_filename
+ self.cache_path_facts = cache_path + "/%s.facts" % cache_filename
try:
self.cache_max_age = config.getint('cache', 'max_age')
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):