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 #37524 - feat: enable ansible events for webhooks #721

Merged
merged 2 commits into from
Aug 28, 2024

Conversation

gardar
Copy link
Contributor

@gardar gardar commented May 31, 2024

Enables the following events:

  • ansible_variable_created.event.foreman
  • ansible_variable_updated.event.foreman
  • ansible_variable_destroyed.event.foreman
  • ansible_role_created.event.foreman
  • ansible_role_updated.event.foreman
  • ansible_role_destroyed.event.foreman

Which can then be used with foreman_webhooks

image

https://projects.theforeman.org/issues/37524

@gardar
Copy link
Contributor Author

gardar commented Aug 8, 2024

cc @nofaralfasi

@nofaralfasi
Copy link
Contributor

It's a bit challenging for me to review this PR due to the lack of tests and detailed steps to follow.
Also, should we add this to the available webhook events in the docs https://docs.theforeman.org/nightly/Administering_Project/index-foreman-el.html#webhooks-available-events_admin?

@nofaralfasi
Copy link
Contributor

I found a community post that clarifies things a bit more: Adding New Custom Webhook Subscriptions.

@gardar
Copy link
Contributor Author

gardar commented Aug 22, 2024

Yes that's a post by me.

I'm fond of having CI tests for everything, but my knowledge of foreman and the tests done here are not deep enough for me to decide how and if this should be automatically tested.

But basically what this PR does is enabling events for updates to ansible roles or variables in foreman, those events can then be used with the foreman webhooks plugin.
As I mentioned in the forum post then I'm using the webhook when a ansible variable is updated/created in foreman (satellite actually) to trigger a pipeline in gitlab which then executes a script that exports the ansible variable override to a repository in gitlab.

Copy link
Member

@ofedoren ofedoren left a comment

Choose a reason for hiding this comment

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

Thanks, @gardar, I've tested it with foreman_webhooks and it works:
Snapshot_2024-08-23_14-59-43

In case you want to add some test to cover this, you might inspire by https://github.com/theforeman/foreman/blob/develop/test/models/hosts/managed_test.rb#L126

@gardar
Copy link
Contributor Author

gardar commented Aug 23, 2024

Great, glad you were able to test it successfully!
I probably won't have any time to add any tests to cover this any time soon, unless it's a strict requirement for this PR moving forward.

@ofedoren
Copy link
Member

unless it's a strict requirement for this PR moving forward.

I'd say it's not, but I'm not a maintainer here :)

@nofaralfasi
Copy link
Contributor

I’m generally in favor of having tests, but we can skip them this time.

@nofaralfasi nofaralfasi merged commit cacd476 into theforeman:master Aug 28, 2024
27 of 28 checks passed
@nofaralfasi
Copy link
Contributor

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

Successfully merging this pull request may close these issues.

3 participants