-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.yml
39 lines (34 loc) · 1.31 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
- hosts: localhost
tasks:
- name: Find all available modules directories except those that starts with an underscore
find:
paths: "{{ playbook_dir }}/modules"
file_type: directory
patterns: "^[^_]*$"
use_regex: yes
register: modules
- name: Find all available command directories
find:
paths: "{{ modules.files | map(attribute='path') | list }}"
patterns: 'commands'
file_type: directory
register: command_dirs
- name: "Store given module {{ command }} command"
set_fact:
target_command_dirs: "{{ command_dirs.files | map(attribute='path') | select('match', '.*/' + module + '/commands') | list }}"
when: module is defined
- name: "Store all modules {{ command }} commands"
set_fact:
target_command_dirs: "{{ command_dirs.files | map(attribute='path') | list }}"
when: module is undefined
- name: "Find all available {{ command }} tasks"
find:
paths: "{{ target_command_dirs }}"
patterns: "{{ command }}.yml"
register: command_tasks
- name: Include tasks files from all available modules
include_tasks: "{{ playbook_tasks }}"
loop: "{{ command_tasks.files | map(attribute='path') | list }}"
loop_control:
loop_var: playbook_tasks