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

Fixes / extends configuration of the positions file #39

Merged
merged 4 commits into from
Dec 25, 2020

Conversation

funkyfuture
Copy link
Contributor

here's a proposal for handling the positions file configuration.

@patrickjahns patrickjahns added the semver:minor Change leading to a minor level version bump label Dec 14, 2020
Comment on lines 33 to 43
- name: Create config and data directories
file:
path: "{{ item }}"
state: directory
owner: root
group: "{{ promtail_system_group }}"
mode: 0770
with_items:
loop:
- "{{ promtail_config_dir }}"
- "{{ promtail_config_file_sd_dir }}"
- "{{ promtail_positions_path | dirname }}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposed change would modify any existing directory - i.e. promtail_positions_path: /tmp/positions.yml.

I currently use promtail_config_positions to specify the filename directly :

promtail_config_positions:
  filename: /tmp/positions.yaml

This would not pick up the specified filename and still create a unnecessary directory.

Instead of creating a directory - I propose to rather create the file directly (promtail_positions_path .filename) with correct permissions for loki

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, i can't come up with something else than to create the directory conditionally when non-existing to cover both cases - using a common or a distinct directory.

@patrickjahns
Copy link
Owner

Thank you very much for submitting the PR

I was working on moving the CI over to github actions - would it be possible that you rebase your work and push it freshly so we have a clean CI run?
Could you also then please extend the test cases in https://github.com/patrickjahns/ansible-role-loki-canary/blob/master/molecule/default/tests/test_default.py and https://github.com/patrickjahns/ansible-role-loki-canary/blob/master/molecule/latest/tests/test_latest.py

defaults/main.yml Outdated Show resolved Hide resolved
@funkyfuture
Copy link
Contributor Author

a'ight, i added the changes w/o squashing commits.

# filename: /tmp/positions.yaml
promtail_positions_path: /var/lib/promtail/positions.yml
promtail_config_positions:
filename: "{{ promtail_positions_path }}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
filename: "{{ promtail_positions_path }}"
filename: "{{ promtail_positions_path }}/positions.yml"

promtail_config_positions: {}
# promtail_config_positions:
# filename: /tmp/positions.yaml
promtail_positions_path: /var/lib/promtail/positions.yml
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
promtail_positions_path: /var/lib/promtail/positions.yml
promtail_positions_path: /var/lib/promtail

state: directory
owner: root
group: "{{ promtail_system_group }}"
mode: ug=rwx,o=
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mode: ug=rwx,o=
mode: 0770

Let's please use the same syntax for all tasks. I am open to adjusting all tasks with a different syntax if there is any benefit to it 👍

@patrickjahns
Copy link
Owner

Thanks for looking further into this - highly appreciated!
When looking at the most recent changes - I have my concerns with the conditional create. When a user of this role changes the group under which promtail is supposed to run - we are not going to adjust the folder and ensure that it is correctly working.

After having given this some thought - what about the following suggestion:

The path variable only defines the path that is managed by this role (see the suggested change) and we document that this path will be created/managed by the role. That way do not need to conditionally create something - but rather inform the user of the role how it shall be used.
What's your thought on this suggestion?

@funkyfuture
Copy link
Contributor Author

The path variable only defines the path that is managed by this role (see the suggested change) and we document that this path will be created/managed by the role. That way do not need to conditionally create something - but rather inform the user of the role how it shall be used.
What's your thought on this suggestion?

i'm fine with that. am i getting correctly by your suggested changes that userscould only change the containing directory, but not the filename (unless using promtail_config_positions)? i'm fine with that too, just asking b/c you didn't mention it explicitly in your summary.

@patrickjahns
Copy link
Owner

i'm fine with that. am i getting correctly by your suggested changes that userscould only change the containing directory, but not the filename (unless using promtail_config_positions)? i'm fine with that too, just asking b/c you didn't mention it explicitly in your summary.

Exactly - that was my thought. Thanks for picking up on that and please excuse for not being explicit.
If you are comfortable with that suggestion, let's adjust it and publish your change 👍

@funkyfuture
Copy link
Contributor Author

a'ight, i amended accordingly.

@funkyfuture
Copy link
Contributor Author

unfortunately, i can't see what is causing the ci failure.

@patrickjahns
Copy link
Owner

The failure is strange - taking a look

@patrickjahns
Copy link
Owner

#44 should fix the failing CI - will re-run the pipelines after it is merged and then review the PR

@patrickjahns patrickjahns merged commit 17a6712 into patrickjahns:master Dec 25, 2020
@github-actions github-actions bot mentioned this pull request Dec 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:minor Change leading to a minor level version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants