Skip to content

Commit

Permalink
created dynamic var for role path, this makes role nesting possible
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-speedboat committed Sep 17, 2024
1 parent b453638 commit 4f6536c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 0 additions & 1 deletion tasks/include-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@
- "{{ vars['task_dir_' + role_name|split('.')|last] }}/shared/{{ include_file_name }}"
loop_control:
loop_var: include_file_path

...
14 changes: 12 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
set_fact:
ansible_distribution_combine: dummy

- name: Create rhelAll fact if needed when AlmaLinux, Rocky, RHEL
- name: Create rhelAll fact, useful when AlmaLinux, Rocky, RHEL, ... all use the same Ansible code base
set_fact:
ansible_distribution_combine: rhelAll
when: >
Expand Down Expand Up @@ -57,6 +57,11 @@
register: found_task_dirs
no_log: True

- name: show tasks directory var
debug:
msg: "{{ 'task_dir_' + role_name|split('.')|last }}: {{ found_task_dirs.files[0].path|dirname }}"
verbosity: 1

- name: define tasks directory
set_fact:
"{{ 'task_dir_' + role_name|split('.')|last }}": "{{ found_task_dirs.files[0].path|dirname }}"
Expand Down Expand Up @@ -86,6 +91,11 @@
set_fact:
include_file_names: "{{ include_file_names | unique | sort }}"

- name: show playbooks
debug:
msg: "include_file_names: {{ include_file_names | unique | sort }}"
verbosity: 1

######## END: Get playbooks to run ########


Expand All @@ -97,4 +107,4 @@
with_items:
- "{{ include_file_names }}"
######## END: Execution part ########

...

0 comments on commit 4f6536c

Please sign in to comment.