Skip to content

Commit

Permalink
ansible: simplify saltbox_facts
Browse files Browse the repository at this point in the history
  • Loading branch information
saltydk committed Feb 3, 2024
1 parent 903b3fa commit 0cdd95b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
11 changes: 0 additions & 11 deletions filter_plugins/custom_filters.py

This file was deleted.

6 changes: 3 additions & 3 deletions library/saltbox_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def get_file_path(role):
def load_facts(file_path, instance, keys):
config = configparser.ConfigParser()
config.read(file_path)
facts = {key: config[instance].get(key) if config.has_option(instance, key) else "saltbox_fact_missing" for key in keys}
facts = {key: config[instance].get(key) for key in keys if config.has_option(instance, key)}
return facts

def save_facts(file_path, instance, keys):
Expand All @@ -23,7 +23,7 @@ def save_facts(file_path, instance, keys):
with open(file_path, 'w') as configfile:
config.write(configfile)

def delete_facts(file_path, delete_type, role, instance, keys):
def delete_facts(file_path, delete_type, instance, keys):
config = configparser.ConfigParser()
config.read(file_path)
if delete_type == 'role':
Expand Down Expand Up @@ -85,7 +85,7 @@ def run_module():
module.fail_json(msg="Instance is required for delete_type 'instance'.")
elif delete_type == 'key' and (not keys):
module.fail_json(msg="Keys are required for delete_type 'key'.")
result['changed'] = delete_facts(file_path, delete_type, role, instance, keys)
result['changed'] = delete_facts(file_path, delete_type, instance, keys)
elif method == 'load':
if not instance:
module.fail_json(msg="Instance is required for method 'load'.")
Expand Down

0 comments on commit 0cdd95b

Please sign in to comment.