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

test: use ipaserver role from collection if it exists #256

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 51 additions & 2 deletions tests/tasks/setup_ipa.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
- name: Set __is_beaker_env
set_fact:
__is_beaker_env: "{{ lookup('env', 'BEAKERLIB') | length > 0 }}"
__is_beaker_env: "{{ lookup('env', 'BEAKERLIB') | length > 0
and lookup('env', 'TESTING_FARM_GIT_URL') | length == 0 }}"

- name: Determine if system is ostree and set flag
when: not __certificate_is_ostree is defined
Expand Down Expand Up @@ -71,6 +72,30 @@
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
when: ansible_facts.os_family == "RedHat"

- name: Sanitize /etc/hosts
ansible.builtin.lineinfile:
path: /etc/hosts
regexp: "{{ ansible_default_ipv4.address }}"
state: absent
owner: root
group: root
mode: "0644"
when: not __is_beaker_env
become: true

- name: Add host to /etc/hosts
ansible.builtin.lineinfile:
path: /etc/hosts
line: "{{ ansible_default_ipv4.address }} ipaserver.test.local"
state: present
insertafter: EOF
create: True
owner: root
group: root
mode: "0644"
when: not __is_beaker_env
become: true

- name: Run IPA server install
vars:
ipaserver_setup_dns: false
Expand All @@ -79,11 +104,27 @@
ipadm_password: SomeDMpassword
ipaserver_domain: test.local
ipaserver_realm: TEST.LOCAL
ipaserver_hostname: ipaserver.test.local
ipaserver_no_host_dns: true
local_log_dir: "{{ lookup('env', 'TEST_ARTIFACTS') | d('/tmp', true) }}"
role_collection_path: >-
/usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/roles/ipaserver
role_collection_name: freeipa.ansible_freeipa.ipaserver
block:
- name: See if collection exists
stat:
path: "{{ role_collection_path }}"
register: __ipa_collection
delegate_to: localhost

- name: Set name of ipa server role
set_fact:
__ipa_server_role: "{{ role_collection_name
if __ipa_collection.stat.exists else 'ipaserver' }}"

- name: Include ipaserver role
include_role:
name: ipaserver
name: "{{ __ipa_server_role }}"
rescue:
- name: FAILURE - check entropy
command: cat /proc/sys/kernel/random/entropy_avail
Expand All @@ -98,6 +139,14 @@
$( [[ -e ipaclient-install.log ]] && echo ipaclient-install.log ) \
$( [[ -e pki ]] && echo pki )
chmod '0644' /tmp/ipalogs.tgz
echo "==========================="
echo " ipaserver-install.log"
echo "==========================="
cat ipaserver-install.log
echo "==========================="
echo " /var/log/messages"
echo "==========================="
cat /var/log/messages
Comment on lines +142 to +149
Copy link
Collaborator

Choose a reason for hiding this comment

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

@richm Is this the debug message that should be removed? I'm fine with simlpy removing it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

May I suggest commenting out that line? It is great to have the indication, no the code, on how to reenable it.

Copy link
Collaborator

@rjeffman rjeffman Feb 13, 2025

Choose a reason for hiding this comment

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

Something like:

diff --git a/.github/workflows/tft.yml b/.github/workflows/tft.yml
index ede80c4..68e5729 100644
--- a/.github/workflows/tft.yml
+++ b/.github/workflows/tft.yml
@@ -169,8 +169,8 @@ jobs:
             ARTIFACTS_DIR=${{ steps.set_vars.outputs.ARTIFACTS_DIR }};\
             TEST_LOCAL_CHANGES=false;\
             LINUXSYSTEMROLES_USER=${{ vars.LINUXSYSTEMROLES_USER }};\
-            ARTIFACTS_URL=${{ steps.set_vars.outputs.ARTIFACTS_URL }};\
-            LSR_ANSIBLE_VERBOSITY='-vvv'"
+            ARTIFACTS_URL=${{ steps.set_vars.outputs.ARTIFACTS_URL }};"
+          # To increase ansible verbosity add to variables: LSR_ANSIBLE_VERBOSITY='-vvv'
           # Note that LINUXSYSTEMROLES_SSH_KEY must be single-line, TF doesn't read multi-line variables fine.
           secrets: "LINUXSYSTEMROLES_DOMAIN=${{ secrets.LINUXSYSTEMROLES_DOMAIN }};\
             LINUXSYSTEMROLES_SSH_KEY=${{ secrets.LINUXSYSTEMROLES_SSH_KEY }}"

changed_when: false
- name: FAILURE - grab archive
fetch:
Expand Down
Loading