Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to use nested directories for config #313

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

Donien
Copy link
Collaborator

@Donien Donien commented Jul 31, 2024

Using icinga2_custom_config allows deploying custom configuration files. They are read in from the files directory. This change allows for the use of nested directories instead of relying on just one directory level.

Fixes #309

Using `icinga2_custom_config` allows deploying custom configuration
files. They are read in from the `files` directory. This change allows
for the use of nested directories instead of relying on just one
directory level.

Fixes #309
@mkayontour
Copy link
Member

I tried that the file name should be appended at the path. I guess a simple {{ item.name | basename }} could already solving this issue right?

@Donien
Copy link
Collaborator Author

Donien commented Nov 14, 2024

The basename approach works fine when we don't want to merge files from different levels within the directory hierarchy.

given:

icinga2_custom_config:
  - name: myown_command.conf
    path: zones.d/main/myown_command.conf
    order: 10
  - name: A/myown_command.conf
    path: zones.d/main/myown_command.conf
    order: 10
  - name: C/myown_command.conf
    path: zones.d/main/myown_command.conf
    order: 10
  - name: B/myown_command.conf
    path: zones.d/main/myown_command.conf
    order: 20

In this case only C and B would end up in the file within /etc/icinga2/zones.d/main/myown_command.conf.
And that's because they use different orders. "root" (no subdir) is overridden by A, which is overridden by C. B writes a new temporary file since it has different order.

Imagine A, B and C to hold different groups of hosts that should still end up in the same file. That would only work if order was set explicitly and uniquely.

The temporary files are these:

  • 10_myown_command.conf (this is C)
  • 20_myown_command.conf (this is B)

With the current PR's approach we get these temporary files instead:

  • 10_A_myown_command.conf
  • 10_C_myown_command.conf
  • 10_myown_command.conf
  • 20_B_myown_command.conf

It is only more complicated so that we don't lose any information without noticing (also more flexibility).

@mkayontour
Copy link
Member

Thinks is legit, I'll approve. Documentation wise I think this is good to go without further explanation.

@Donien Donien merged commit 6e2b632 into main Dec 5, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

icinga2_custom_config not working with files in subfolders...
2 participants