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

I would like to ask if ansible.eda.alertmanager can successfully trigger ‘run_playbook’? #722

Open
3 tasks done
adiooooos opened this issue Nov 14, 2024 · 1 comment

Comments

@adiooooos
Copy link

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

Hi, I would like to ask if ansible.eda.alertmanager can successfully trigger ‘run_playbook’?
Because when we use ansible.eda.alertmanager to send alert to EDA, EDA can receive the alert message and find the action's run_playbook. but the subsequent playbook cannot be executed. 、

Environment

Enviroment:
1:AAP2.5
2:ansible-rulebook --version
1.1.1
Executable location = /usr/bin/ansible-rulebook
Drools_jpy version = 0.3.9
Java home = /usr/lib/jvm/java-17-openjdk-17.0.13.0.11-3.el9.x86_64
Java version = 17.0.13
Python version = 3.11.7 (main, Aug 23 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)]
3:

Steps to reproduce

when we use ansible.eda.alertmanager to send alert to EDA, EDA can receive the alert message and find the action's run_playbook. but the subsequent playbook cannot be executed. The alert error message is shown below:

024-11-12 15:27:32,290 - ansible_rulebook.action.run_playbook - DEBUG - ruleset: Automatic Remediation of a server, rule: CPU full on server
2024-11-12 15:27:32,290 - ansible_rulebook.action.run_playbook - DEBUG - private data dir /tmp/eda1j9oxmh6
2024-11-12 15:27:32,293 - ansible_rulebook.action.run_playbook - DEBUG - project_data_file: None
2024-11-12 15:27:32,295 - ansible_rulebook.action.run_playbook - DEBUG - Calling Ansible runner
[WARNING]: Could not match supplied host pattern, ignoring: 10.71.19.192
ERROR! Specified inventory, host pattern and/or --limit leaves us with no hosts to target.
2024-11-12 15:27:32,888 - ansible_rulebook.action.runner - DEBUG - Cancel Queue reading task
2024-11-12 15:27:32,889 - ansible_rulebook.action.runner - INFO - Ansible runner Queue task cancelled
2024-11-12 15:27:32,890 - ansible_rulebook.action.run_playbook - INFO - Ansible runner rc: 1, status: failed
2024-11-12 15:27:32,891 - ansible_rulebook.action.run_playbook - ERROR - [WARNING]: Could not match supplied host pattern, ignoring: 10.71.19.192
ERROR! Specified inventory, host pattern and/or --limit leaves us with no hosts to target.

Then I switched things up and put this playbook in the Automation Controller template. Using

ansible-rulebook --rulebook prometheus. yml --controller-url https://10.71.18.35 --controller-username admin --controller-password redhat --controller-ssl-verify no --print-event -v

And it worked.
So back to my question: Why does ansible.eda.alertmanager CAN'T successfully trigger ‘run_playbook’?

Actual results

when we use ansible.eda.alertmanager to send alert to EDA, EDA can receive the alert message and find the action's run_playbook. but the subsequent playbook cannot be executed. The alert error message is shown below:

024-11-12 15:27:32,290 - ansible_rulebook.action.run_playbook - DEBUG - ruleset: Automatic Remediation of a server, rule: CPU full on server
2024-11-12 15:27:32,290 - ansible_rulebook.action.run_playbook - DEBUG - private data dir /tmp/eda1j9oxmh6
2024-11-12 15:27:32,293 - ansible_rulebook.action.run_playbook - DEBUG - project_data_file: None
2024-11-12 15:27:32,295 - ansible_rulebook.action.run_playbook - DEBUG - Calling Ansible runner
[WARNING]: Could not match supplied host pattern, ignoring: 10.71.19.192
ERROR! Specified inventory, host pattern and/or --limit leaves us with no hosts to target.
2024-11-12 15:27:32,888 - ansible_rulebook.action.runner - DEBUG - Cancel Queue reading task
2024-11-12 15:27:32,889 - ansible_rulebook.action.runner - INFO - Ansible runner Queue task cancelled
2024-11-12 15:27:32,890 - ansible_rulebook.action.run_playbook - INFO - Ansible runner rc: 1, status: failed
2024-11-12 15:27:32,891 - ansible_rulebook.action.run_playbook - ERROR - [WARNING]: Could not match supplied host pattern, ignoring: 10.71.19.192
ERROR! Specified inventory, host pattern and/or --limit leaves us with no hosts to target.

Expected results

we expected the EDA could run the playbook

Additional information

N/A

@Alex-Izquierdo
Copy link
Contributor

Hello @adiooooos
The plugin attempts to parse the host from the alert and pass it to the --limit option. The error occurs because the host does not match any value in your inventory, causing the ansible-playbook command to fail. When running the rulebook to trigger a local playbook with the run_playbook action, your inventory must define the host referenced in the alert.

Alternatively, you can configure the option data_host_path option in ansible.eda.alertmanager to either disable the host or specify a new location. You can also override the content of event.meta.hosts using insert_hosts_to_meta filter, as described here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants