aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Loman <jloman@redhat.com>2017-03-31 14:45:54 +0200
committerGuido G√ľnther <agx@sigxcpu.org>2017-05-04 11:39:02 +0200
commit626a02560d95061c126c851da86ac00e1d69247b (patch)
treef9a92f143960b715ebb9a8a20898b26acd799cdd
parentd4ae1fb5dba200e75e83fdcc1d55a3b0f34ba4c7 (diff)
Make cache file names configurableHEADmaster
-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):