diff --git a/changelogs/fragments/feature_folder_inside_file.yml b/changelogs/fragments/feature_folder_inside_file.yml new file mode 100644 index 00000000..ab311b6e --- /dev/null +++ b/changelogs/fragments/feature_folder_inside_file.yml @@ -0,0 +1,4 @@ +--- +minor_changes: + - provide folder structure inside files folder for custom config files + diff --git a/doc/role-icinga2/objects.md b/doc/role-icinga2/objects.md index 871f0f4a..0ecbd270 100644 --- a/doc/role-icinga2/objects.md +++ b/doc/role-icinga2/objects.md @@ -75,6 +75,17 @@ icinga2_custom_config: path: zones.d/main/myown_command.conf order: 10 ``` +The config files can also be structured in subfolders to provide a better overview within the files folder. In this case, the source folder below files must be specified via the "src_folder" parameter. + +If we have a file `myown_command_inside_folder.conf` under **files/main/** we can use this as follows + +``` +icinga2_custom_config: + - name: myown_command_inside_folder.conf + path: zones.d/main/myown_command.conf + src_folder: main/ + order: 10 +``` ## Parser Rules diff --git a/roles/icinga2/tasks/objects.yml b/roles/icinga2/tasks/objects.yml index 58ac18b7..a4920224 100644 --- a/roles/icinga2/tasks/objects.yml +++ b/roles/icinga2/tasks/objects.yml @@ -43,6 +43,6 @@ owner: root group: root mode: 0644 - src: "files/{{ item.name }}" + src: "files/{{ item.src_folder|default('') }}{{ item.name }}" dest: "{{ icinga2_fragments_path }}/{{ item.path }}/{{ item.order|default('20')|string }}_{{ item.name }}" loop: "{{ icinga2_custom_config }}"