Skip to content

Commit

Permalink
Fix ansible tests by using proxy for connecting to ansible-galaxy (#1…
Browse files Browse the repository at this point in the history
…7467)

Signed-off-by: Gaurav Talreja <gtalreja@redhat.com>
(cherry picked from commit 31724af)
  • Loading branch information
Gauravtalreja1 authored and web-flow committed Jan 31, 2025
1 parent 5ff4e47 commit bc69afd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
14 changes: 11 additions & 3 deletions tests/foreman/api/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,17 @@ def test_fetch_and_sync_ansible_playbooks(self, target_sat):
:customerscenario: true
"""
target_sat.execute(
"ansible-galaxy collection install -p /usr/share/ansible/collections "
"xprazak2.forklift_collection"
http_proxy = (
f'HTTPS_PROXY={settings.http_proxy.HTTP_PROXY_IPv6_URL} '
if settings.server.is_ipv6
else ''
)
assert (
target_sat.execute(
f'{http_proxy}ansible-galaxy collection install -p /usr/share/ansible/collections '
'xprazak2.forklift_collection'
).status
== 0
)
proxy_id = target_sat.nailgun_smart_proxy.id
playbook_fetch = target_sat.api.AnsiblePlaybooks().fetch(data={'proxy_id': proxy_id})
Expand Down
12 changes: 11 additions & 1 deletion tests/foreman/cli/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,17 @@ def _finalize():
proxy_id = target_sat.nailgun_smart_proxy.id

for path in ['/etc/ansible/collections', '/usr/share/ansible/collections']:
target_sat.execute(f'ansible-galaxy collection install -p {path} {SELECTED_COLLECTION}')
http_proxy = (
f'HTTPS_PROXY={settings.http_proxy.HTTP_PROXY_IPv6_URL} '
if settings.server.is_ipv6
else ''
)
assert (
target_sat.execute(
f'{http_proxy}ansible-galaxy collection install -p {path} {SELECTED_COLLECTION}'
).status
== 0
)
target_sat.cli.Ansible.roles_sync({'role-names': SELECTED_ROLE, 'proxy-id': proxy_id})
result = target_sat.cli.Host.ansible_roles_assign(
{'id': target_host.id, 'ansible-roles': f'{SELECTED_ROLE}'}
Expand Down

0 comments on commit bc69afd

Please sign in to comment.