Merge pull request #1016 from t-woerner/galaxyfy_ansible_builtin

utils files: Support builtins with ansible.builtin. prefix
This commit is contained in:
Rafael Guterres Jeffman
2023-01-09 17:54:23 -03:00
committed by GitHub
2 changed files with 8 additions and 4 deletions

View File

@@ -39,13 +39,14 @@ def galaxyfy_playbook(project_prefix, collection_prefix, lines):
if stripped.startswith("- name:") or \
stripped.startswith("- block:"):
changeable = True
elif stripped in ["set_fact:", "vars:"]:
elif stripped in ["set_fact:", "ansible.builtin.set_fact:", "vars:"]:
changeable = False
include_role = False
elif stripped == "roles:":
changeable = True
include_role = False
elif stripped.startswith("include_role:"):
elif (stripped.startswith("include_role:") or
stripped.startswith("ansible.builtin.include_role:")):
include_role = True
elif include_role and stripped.startswith("name:"):
line = po2.sub(pattern2, line)

View File

@@ -27,7 +27,9 @@ def get_plugins_from_playbook(playbook):
task = task.split(".")[-1]
if task == "block":
_result.update(get_tasks(tasks["block"]))
elif task in ["include_tasks", "import_tasks"]:
elif task in ["include_tasks", "import_tasks"
"ansible.builtin.include_tasks",
"ansible.builtin.import_tasks"]:
parent = os.path.dirname(playbook)
include_task = tasks[task]
if isinstance(include_task, dict):
@@ -37,7 +39,8 @@ def get_plugins_from_playbook(playbook):
else:
include_file = os.path.join(parent, include_task)
_result.update(get_plugins_from_playbook(include_file))
elif task == "include_role":
elif task in ["include_role",
"ansible.builtin.include_role"]:
_result.add(f"_{tasks[original_task]['name']}")
elif task.startswith("ipa"):
# assume we are only interested in 'ipa*' modules/roles