Skip to content

Add foreman_ansible - #444

Open
ehelms wants to merge 9 commits into
theforeman:masterfrom
ehelms:add-foreman-ansible
Open

Add foreman_ansible#444
ehelms wants to merge 9 commits into
theforeman:masterfrom
ehelms:add-foreman-ansible

Conversation

@ehelms

@ehelms ehelms commented Apr 2, 2026

Copy link
Copy Markdown
Member

No description provided.

Comment thread src/features.yaml Outdated
@ehelms

ehelms commented Apr 6, 2026

Copy link
Copy Markdown
Member Author

This relies on theforeman/foreman-oci-images#25 first

Comment thread .github/workflows/test.yml Outdated
@ehelms

ehelms commented Apr 8, 2026

Copy link
Copy Markdown
Member Author

I started adding this to help ensure the IoP use-case could work out of the box by having ansible support for remediation. There is more nuance and testing for this feature that needs to happen to be complete.

When I test this locally with the updated containers built locally, I run into the hammer sync failing with no clear reason why. That will need investigation, i.e.:

hammer ansible roles sync

Comment thread tests/foreman_ansible_test.py Outdated
Comment thread tests/feature/ansible/base_test.py

@adamruzicka adamruzicka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ehelms what are your plans with this?

Comment thread src/roles/foreman_proxy/templates/settings.d/ansible.yml.j2 Outdated
@ehelms
ehelms force-pushed the add-foreman-ansible branch 4 times, most recently from ba72146 to b1c30e7 Compare July 24, 2026 01:00
@evgeni
evgeni force-pushed the add-foreman-ansible branch 2 times, most recently from 594cbd5 to f3de969 Compare July 28, 2026 14:58
Comment thread tests/feature/ansible/base_test.py Outdated
Comment thread tests/feature/ansible/base_test.py Outdated
Comment thread tests/feature/ansible/base_test.py Outdated
Comment thread src/features.yaml Outdated
Comment thread tests/feature/ansible/base_test.py Outdated
@evgeni
evgeni force-pushed the add-foreman-ansible branch 3 times, most recently from 4321df6 to 6a330e3 Compare July 29, 2026 08:44
@evgeni

evgeni commented Jul 29, 2026

Copy link
Copy Markdown
Member

@adamruzicka I cleaned up what I disliked, but would now require someone with Ansible knowledge to look at this :)

@adamruzicka adamruzicka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems to work well (ad-hoc rex-like jobs, role management, role application, reports from roles). Some minor suggestions inline


- name: Create ansible roles directory
ansible.builtin.file:
path: /var/lib/foreman-proxy/ansible/roles

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Previously we relied on /etc/ansible/roles for "user roles" (and s/role/collection/g). Having everthing in /var/lib would be cleaner, but also make the migration harder. Personally I'd be willing to make that tradeoff, but still worth calling out.

Comment on lines +41 to +42
Volume=/var/lib/foreman-proxy/ansible/roles:/etc/ansible/roles:rw,Z,U
Volume=/var/lib/foreman-proxy/ansible/collections:/etc/ansible/collections:rw,Z,U

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why rw? I'd expect the proxy to only consume the content that's there.

Also til about U, nice.

export ANSIBLE_LOCAL_TEMP="/tmp"
export ANSIBLE_HOST_KEY_CHECKING="False"
export ANSIBLE_ROLES_PATH="/etc/ansible/roles:/usr/share/ansible/roles"
export ANSIBLE_COLLECTIONS_PATHS="/etc/ansible/collections:/usr/share/ansible/collections"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[DEPRECATION WARNING]:
ANSIBLE_COLLECTIONS_PATHS option, does not fit var naming standard, use the singular form ANSIBLE_COLLECTIONS_PATH instead. This feature will be removed from ansible-core in version 2.19. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

Suggested change
export ANSIBLE_COLLECTIONS_PATHS="/etc/ansible/collections:/usr/share/ansible/collections"
export ANSIBLE_COLLECTIONS_PATH="/etc/ansible/collections:/usr/share/ansible/collections"

@@ -0,0 +1,13 @@
export ANSIBLE_CALLBACK_WHITELIST="theforeman.foreman.foreman"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Iirc whitelist was replaced with the one below in ansible 2.15. It should be safe to drop this one.

Suggested change
export ANSIBLE_CALLBACK_WHITELIST="theforeman.foreman.foreman"

Comment thread tests/feature/ansible/base_test.py Outdated
ROLE_NAME = "theforeman.foremanctltest"


def test_foreman_ansible_plugin_installed(foremanapi):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

that's a shiny mirror you have there. where did you get it?

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@evgeni
evgeni force-pushed the add-foreman-ansible branch from f7c4467 to 2f0f2c4 Compare July 30, 2026 15:44
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.

6 participants