Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Add amtool configuration on alertmanager host #135

Merged
merged 1 commit into from
Jul 21, 2020

Conversation

till
Copy link
Contributor

@till till commented Jul 15, 2020

I can rebase that on the other PR. :)

@github-actions github-actions bot added area/jinja Templates area/tasks Logic behind ansible role area/vars Ansible variables used in role labels Jul 15, 2020
@till
Copy link
Contributor Author

till commented Jul 16, 2020

@paulfantom I think this is done! Thoughts?

@@ -113,3 +113,8 @@ alertmanager_route: {}
# - match:
# owner: team-Y
# receiver: team-Y-pager

amtool_config_dir: '/etc/amtool'
Copy link
Member

Choose a reason for hiding this comment

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

For consistency this should be prefixed with alertmanager_

Copy link
Member

@paulfantom paulfantom Jul 16, 2020

Choose a reason for hiding this comment

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

This should default to /etc/alertmanager/amtool/ as this is one of default locations for amtool config.

Or even better to {{ alertmanager_config_dir }}/amtool/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@paulfantom I can prefix the vars.


As for the location. When I move to /etc/alertmanager/amtool then it doesn't find the configuration.

I used this:
https://github.com/prometheus/alertmanager#configuration

Copy link
Member

Choose a reason for hiding this comment

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

I read old docs, sorry for that. /etc/amtool sounds good, but it still needs to be created and this is currently lacking in role :)

Does amtool_config_dir need to be configurable? I would like to prevent issues when people put some value and later find out that configuration is not picked up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DOH. 🤦 Sorry, I will add directory creation.

Does amtool_config_dir need to be configurable? I would like to prevent issues when people put some value and later find out that configuration is not picked up.

Probably not. I mean, you could role out per user in $HOME. But no idea if that is "needed". I can add a comment and a link to prometheus/alertmanager so people check that before configuring something else?

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking about either moving amtool_config_dir to vars/ or removing completely.

@@ -11,6 +11,16 @@
notify:
- restart alertmanager

- name: copy amtool config
Copy link
Member

@paulfantom paulfantom Jul 16, 2020

Choose a reason for hiding this comment

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

I think this should be executed before copy alertmanager config task as amtool is already used there for config validation.

Copy link
Member

@paulfantom paulfantom left a comment

Choose a reason for hiding this comment

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

I wonder if after implementing this, validation from https://github.com/cloudalchemy/ansible-alertmanager/blob/master/tasks/configure.yml#L10 should be fixed not to use --alertmanager.url=?

@till till requested a review from paulfantom July 16, 2020 15:28
@till till force-pushed the configure-amtool branch 2 times, most recently from c9f928f to 4f429be Compare July 20, 2020 18:23
template:
force: true
src: "{{ alertmanager_amtool_config_file }}"
dest: "{{ alertmanager_amtool_config_dir }}/config.yml"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
dest: "{{ alertmanager_amtool_config_dir }}/config.yml"
dest: "{{ _alertmanager_amtool_config_dir }}/config.yml"

tasks/configure.yml Outdated Show resolved Hide resolved
Copy link
Member

@paulfantom paulfantom left a comment

Choose a reason for hiding this comment

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

CI complains about:

fatal: [bionic]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'alertmanager_amtool_config_dir' is undefined\n\nThe error appears to have been in '/home/travis/build/cloudalchemy/ansible-alertmanager/tasks/configure.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: copy amtool config\n ^ here\n"}

Few issues with variable names.

Also could you add entries about new variables from defaults/main.yml to README.md?

I think when those are fixed we are ready to merge it :)

@github-actions github-actions bot added the area/docs Improvements or additions to documentation label Jul 21, 2020
@till
Copy link
Contributor Author

till commented Jul 21, 2020

Worst PR ever. 🤪 But I think it's done.

@paulfantom paulfantom changed the title Configure amtool Add amtool configuration on alertmanager host Jul 21, 2020
@paulfantom paulfantom merged commit ff3f1e7 into cloudalchemy:master Jul 21, 2020
@robbyq92
Copy link

i try to configure my playbook for alertmanager to choose a cluster. i configure the services with
-cluster.peer=IP_Node2:Port and in second server --cluster.peer=IP_Node1:port but i need put this in playbook, any know ?

@till
Copy link
Contributor Author

till commented Jul 28, 2021

@robbyq92 https://github.com/cloudalchemy/ansible-alertmanager/blob/master/defaults/main.yml#L48-L55

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/docs Improvements or additions to documentation area/jinja Templates area/tasks Logic behind ansible role area/vars Ansible variables used in role
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants