From 966797dbee3848030653e972e94d3b450bb928ea Mon Sep 17 00:00:00 2001 From: Thomas Woerner <twoerner@redhat.com> Date: Mon, 17 Apr 2023 16:49:22 +0200 Subject: [PATCH] utils/build-galaxy-release.sh: Create module action group The module action group <collection-prefix>.modules is created automatically while building the galaxy release. The action group can be used for module_defaults in this way: module_defauls: group/<collection-prefix>.modules: ipaadmin_password: SomeADMINpassword Example: module_defaults: group/freeipa.ansible_freeipa.modules: ipaadmin_password: SomeADMINpassword ipaapi_context: "{{ ipa_context | default(omit) }}" collections: - freeipa.ansible_freeipa --- utils/build-galaxy-release.sh | 2 ++ utils/create_action_group.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 utils/create_action_group.py diff --git a/utils/build-galaxy-release.sh b/utils/build-galaxy-release.sh index bbce0122..e3eb0b9c 100755 --- a/utils/build-galaxy-release.sh +++ b/utils/build-galaxy-release.sh @@ -114,6 +114,8 @@ echo -e "\033[ACreating CHANGELOG.rst... \033[32;1mDONE\033[0m" sed -i -e "s/ansible.module_utils.ansible_freeipa_module/ansible_collections.${collection_prefix}.plugins.module_utils.ansible_freeipa_module/" plugins/modules/*.py +python utils/create_action_group.py "meta/runtime.yml" "$collection_prefix" + (cd plugins/module_utils && { ln -sf ../../roles/*/module_utils/*.py . }) diff --git a/utils/create_action_group.py b/utils/create_action_group.py new file mode 100644 index 00000000..6f6cec26 --- /dev/null +++ b/utils/create_action_group.py @@ -0,0 +1,24 @@ +import sys +import yaml +from facts import MANAGEMENT_MODULES + + +def create_action_group(yml_file, project_prefix): + yaml_data = None + with open(yml_file) as f_in: + yaml_data = yaml.safe_load(f_in) + + yaml_data.setdefault("action_groups", {})[ + "%s.modules" % project_prefix + ] = MANAGEMENT_MODULES + + with open(yml_file, 'w') as f_out: + yaml.safe_dump(yaml_data, f_out, default_flow_style=False, + explicit_start=True) + + +if len(sys.argv) != 3: + print("Usage: %s <runtime file> <collection prefix>" % sys.argv[0]) + sys.exit(-1) + +create_action_group(sys.argv[1], sys.argv[2]) -- GitLab