2675 Commits

Author SHA1 Message Date
Rafael Guterres Jeffman
4d22e917df Merge pull request #1376 from t-woerner/backup_test_ansible_2_19
test_backup.yml: Fix evaluation of 'list = False' and 'list = True'
2025-08-13 09:54:35 -03:00
Thomas Woerner
a04a357b6a test_backup.yml: Fix evaluation of 'list = False' and 'list = True'
ansible-core 2.19 is not automatically converting empty and non empty lists
to bool values. Conditionals must have a boolean result.

The solution is to evaluate the length of the lists instead.
2025-08-13 14:17:32 +02:00
Thomas Woerner
2081a1a8dd Merge pull request #1369 from rjeffman/prepare_ansible_2_19
Prepare playbooks for ansible core 2.19
2025-08-12 14:30:47 +02:00
Rafael Guterres Jeffman
d1dfdc38c9 tests service: Fixes evaluation of 'Keytab = True'
In ansible-core 2.19 there's no automatic coercion from None or empty
strings to the boolean value "false", so we need to compare the result
of the filter 'regex_search' to 'None' and the empty string to evaluate
if any match occurred.

In fixing this issue, it was found that the tests were incorrectly
evaluating the results, and the comparisons were fixed.

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
2025-08-12 08:25:17 -03:00
Varun Mylaraiah
9fc1b043c1 Merge pull request #1375 from t-woerner/ipaclient_client_dns_new_arg_statestore
ipaclient: client_dns has new statestore arg with IPA change e6445b8
v1.15.1
2025-07-31 18:24:22 +05:30
Thomas Woerner
bdf1efde80 ipaclient: client_dns has new statestore arg with IPA change e6445b8
The new argument was introduced with the IPA change e6445b8 to disable
the previous Unbound configuration before setting up new configuration
for DNS over TLS.

Related: https://pagure.io/freeipa/issue/9814
2025-07-31 11:12:52 +02:00
Varun Mylaraiah
513d5ee46b Merge pull request #1371 from t-woerner/dns_over_tls
ipaserver, ipareplica and ipaclient roles: Add DNS over TLS support
v1.15.0
2025-07-21 21:27:58 +05:30
Thomas Woerner
cd440a2049 ipareplica: Add support for DNS over TLS
This change adds support for DNS over TLS to the ipareplica role.

New variables

ipareplica_dot_forwarders
    List of DNS over TLS forwarders. Required if ipareplica_dns_over_tls
    is enabled. (list of strings)
    required: false
ipareplica_dns_over_tls | ipaclient_dns_over_tls
    Configure DNS over TLS. Requires FreeIPA version 4.12.5 or later.
    (bool, default: false)
    required: false
ipareplica_dns_over_tls_cert
    Certificate to use for DNS over TLS. If empty, a new certificate will
    be requested from IPA CA. (string)
    required: false
ipareplica_dns_over_tls_key
    Key for certificate specified in ipareplica_dns_over_tls_cert. (string)
    required: false
ipareplica_dns_policy
    Encrypted DNS policy. Only usable if `ipareplica_dns_over_tls` is
    enabled. (choice: relaxed, enforced, default: relaxed)
    required: false

New distribution specific variable

ipareplica_packages_dot
    List of IPA packages needed for DNS over TLS.
2025-07-21 13:38:36 +02:00
Thomas Woerner
e2317f304c ipaserver: Add support for DNS over TLS
This change adds support for DNS over TLS to the ipaserver role.

New variables

ipaserver_dot_forwarders
    List of DNS over TLS forwarders. Required if ipaserver_dns_over_tls
    is enabled. (list of strings)
    required: false
ipaserver_dns_over_tls | ipaclient_dns_over_tls
    Configure DNS over TLS. Requires FreeIPA version 4.12.5 or later.
    (bool, default: false)
    required: false
ipaserver_dns_over_tls_cert
    Certificate to use for DNS over TLS. If empty, a new certificate will
    be requested from IPA CA. (string)
    required: false
ipaserver_dns_over_tls_key
    Key for certificate specified in ipaserver_dns_over_tls_cert. (string)
    required: false
ipaserver_dns_policy
    Encrypted DNS policy. Only usable if `ipaserver_dns_over_tls` is
    enabled. (choice: relaxed, enforced, default: relaxed)
    required: false

New distribution specific variable

ipaserver_packages_dot
    List of IPA packages needed for DNS over TLS.
2025-07-21 13:37:50 +02:00
Thomas Woerner
7a23c668fc ipaclient: Add support for DNS over TLS
This change adds support for DNS over TLS to the ipaclient role.

New variables

ipaclient_dns_over_tls
    Configure DNS over TLS. Requires FreeIPA version 4.12.5 or later.
    (bool, default: false)
    required: false
ipaclient_no_dnssec_validation
    Disable DNSSEC validation for DNS over TLS. This turns off DNSSEC
    validation for unbound. Only usable if `ipaserver_dns_over_tls` is
    enabled. (bool, default: false)
    reqiured: false

New distribution specific variable

ipaclient_packages_dot
    List of IPA packages needed for DNS over TLS.

The resolver configuratoin for DNS over TLS is not part of this change
and will be added later on. Therefore it is needed to configure the
resolver for DNS over TLS before starting the deployment with ipaclient
role. This is essential for using an IPA DNS server with DoT and enforced
DNS policy so that only DoT is usable.
2025-07-21 11:00:50 +02:00
Thomas Woerner
91d818b334 Merge pull request #1329 from Nihlus/fix-stdout-caching
Cache sys.stdout instead of assuming it is equal to sys.__stdout__
2025-07-14 15:52:36 +02:00
Jarl Gullberg
902d8b7238 Cache sys.stdout instead of assuming it is equal to sys.__stdout__
When running under Mitogen, ipa_server and ipa_replica breaks execution
by overwriting sys.stdout with sys.stdout.

With Mitogen, sys.stdout != sys.stdout at this point in the code, and
changing it in this manner results in access to closed file descriptors
for future invocations. Generally, it is recommended not to use
sys.stdout and instead explicitly cache the current value of sys.stdout.
2025-07-04 18:39:46 +02:00
Rafael Guterres Jeffman
d553f9a0b1 Merge pull request #1360 from t-woerner/drop_misspelled_ipassd_compat_vars
ipaclient: Drop misspelled ipassd_ compat vars
2025-07-03 09:41:20 -03:00
Thomas Woerner
9cfe835b03 Merge pull request #1367 from rjeffman/rhel_79820
ipaidrange: Require usage of range id parameters
2025-07-03 14:39:49 +02:00
Rafael Guterres Jeffman
668830fc94 ansible-core 2.19: 'upper' and 'lower' make lists into strings
As ansible-core 2.19 'upper' and 'lower' filters make lists into strings
and these strings are not interpreted as lists when running the plugins,
it is needed to use 'map(<filter>)' to apply the filter to all entries
of a list.

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
2025-06-14 11:45:30 -03:00
Rafael Guterres Jeffman
5ae39ec9de ansible-core 2.19: Templates and expressions must use trusted sources
In ansible-core, templates and expressions must use trusted sources,
such as playbooks or roles, and module results are considered untrusted
sources.

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
2025-06-14 11:45:26 -03:00
Rafael Guterres Jeffman
3f59332d99 ansible-core 2.19: when clause don't automatically convert to bool
In ansible-core 2.19, when clauses (when, failed_when, etc) do not
convert values to bool automatically, also, templating with "|bool" does
not work too, so an actual value comparison is required.

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
2025-06-14 11:45:21 -03:00
Rafael Guterres Jeffman
30c405cb36 Merge pull request #1364 from t-woerner/infra_image_service_refinement
infra/image: Make fixnet and fixipaip services active by default
2025-06-04 16:04:19 -03:00
Rafael Guterres Jeffman
7275bbf6a3 Merge pull request #1365 from t-woerner/infra_image_start_hosts_safer_removal
infra/image/shcontainer: Safer host removal from /etc/hosts
2025-06-04 15:52:02 -03:00
Rafael Guterres Jeffman
6df89ad7db ipaidrange: Require usage of range id parameters
When adding a new idrange of type 'ipa-local', the 'base_id',
'range_size', 'rid_base' and 'secondary_rid_base' are required so that
range entries are correctly set when SID are enabled.

Fixes: https://issues.redhat.com/browse/RHEL-79820

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
2025-06-03 21:46:15 -03:00
Thomas Woerner
c5fa54f2cf infra/image: Make fixnet and fixipaip services active by default
The services are now active by default and do not need to be activated
after IPA has been deployed.

The fixnet service is always activated and removes all lines containing
the hostname from /etc/hosts and adds a new line with the IP and the
hostname with and without domain. If IPA is deployed with DNS (the
config file /etc/named.conf exists and there is a '^dyndb "ipa"' line
in /etc/named.conf) then /etc/resolv.conf is also changed to use the
local DNS server.

The fixipaip service is now also always activated, but only started IF
IPA has been deployed and the ipa service was started before.

infra/image/build.sh is not actvating the services anymore, the services
are now actiavted in alll dockerfiles.
2025-05-30 15:59:11 +02:00
Thomas Woerner
8e3102270d infra/image/shcontainer: Safer host removal from /etc/hosts
The sed command for host removal from PR #1364 is used now. This makes
sure that only full matches are removed and not substring matches.
2025-05-30 15:55:29 +02:00
Rafael Guterres Jeffman
89cfb5f4c4 Merge pull request #1361 from t-woerner/infra_image_start_fix_hosts
infra/image/shcontainer: Add host entry in container_start
2025-05-27 19:53:18 -03:00
Thomas Woerner
5fb22581bb infra/image/shcontainer: Add host entry in container_start
The management of hosts is deactivated in container_create to not copy
all entries from the host system to the container. The host entry is now
created in container_start to fix IPA deployment using this container.
2025-05-27 20:41:49 +02:00
Thomas Woerner
6976ef57eb ipaclient: Drop misspelled ipassd_ compat vars
This change finally drops the misspelled ipassd_ compat vars from the
ipaclient role. The PR #147 from 2019 already renamed the ipassd_
variables to ipasssd_.

Related: #1346 - ipaclient role install sssd options broken
2025-05-27 11:48:21 +02:00
Rafael Guterres Jeffman
0d9b164358 Merge pull request #1359 from t-woerner/turn_on_update_dns_for_test_host_removal
tests/service/env_cleanup.yml: Turn on update_dns for test host removal
2025-05-26 09:07:26 -03:00
Thomas Woerner
8b03e4d007 tests/service/env_cleanup.yml: Turn on update_dns for test host removal
The tests hosts are generated with IP addresses in env_setup, but
removed without update_dns turned on. Therefore the IP addresses are not
removed from DNS.

This results in a failure if the host test test_host_ipaddresses is run
afterwards.
2025-05-26 13:18:27 +02:00
Thomas Woerner
ef73a85320 Merge pull request #1357 from jangel97/hotfix_sssd_dns_over_tls
ipaclient: Fix AttributeError by defaulting dns_over_tls to False
v1.14.7
2025-05-21 17:12:15 +02:00
Jose Angel Morena
5b3a4729f0 ipaclient: Fix AttributeError by defaulting dns_over_tls to False
This change addresses https://github.com/freeipa/ansible-freeipa/issues/1356#issuecomment-2891804763 by explicitly setting `options.dns_over_tls = False` to ensure the attribute is always defined when running ipaclient ansible role.

On RHEL 9 systems (or any environment where `ipasssd_enable_dns_updates: true`), the `ipaclient` python module references `dns_over_tls` without first checking its existence, which results in the following `AttributeError: 'installer_obj' object has no attribute 'dns_over_tls'`:

  TASK \[freeipa.ansible\_freeipa.ipaclient : Install - Configure SSSD] \*\*\*\*\*\*\*\*\*\*\*\*
  An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError:
  'installer\_obj' object has no attribute 'dns\_over\_tls'
  fatal: \[vm-test-rhel9]: FAILED! => {"changed": false, "module\_stderr": "Traceback (most recent call last):\n  File "
 <stdin>", line 107, in <module>\n  File "<stdin>", line 99, in \_ansiballz\_main\n  File "<stdin>", line 47, in invoke\_module\n
  File "/usr/lib64/python3.9/runpy.py", line 225, in run\_module\n    return \_run\_module\_code(code, init\_globals,
  run\_name, mod\_spec)\n  File "/usr/lib64/python3.9/runpy.py", line 97, in \_run\_module\_code\n    \_run\_code(code,
  mod\_globals, init\_globals,\n  File "/usr/lib64/python3.9/runpy.py", line 87, in \_run\_code\n    exec(code, run\_globals)\n
  File "/tmp/ansible\_freeipa.ansible\_freeipa.ipaclient\_setup\_sssd\_payload\_zkyct7sn/ansible\_freeipa.ansible\_freeipa.ipacli. ent\_setup\_sssd\_payload.zip/ansible\_collections/freeipa/ansible\_freeipa/plugins/modules/ipaclient\_setup\_sssd.py",
  line 190, in <module>\n  File "/tmp/ansible\_freeipa.ansible\_freeipa.ipaclient\_setup\_sssd\_payload\_zkyct7sn/ansible\_freeipa.ansible\_freeipa.ipacli. ent\_setup\_sssd\_payload.zip/ansible\_collections/freeipa/ansible\_freeipa/plugins/modules/ipaclient\_setup\_sssd.py",
  line 181, in main\n  File "/usr/lib/python3.9/site-packages/ipaclient/install/client.py", line 1005, in configure\_sssd\_conf\n
  if options.dns\_over\_tls:\nAttributeError: 'installer\_obj' object has no attribute 'dns\_over\_tls'\n", "module\_stdout": "",
  "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

To prevent this, the attribute `options.dns_over_tls` is now initialised to false in `roles/ipaclient/library/ipaclient_setup_sssd.py`.This fix is inspired by a similar pattern in [[PR #1340](https://github.com/freeipa/ansible-freeipa/pull/1340/files)](https://github.com/freeipa/ansible-freeipa/pull/1340/files).

This failure has been observed in versions `1.14.6` and `1.14.5` of the [ansible_freeipa collection](https://galaxy.ansible.com/ui/repo/published/freeipa/ansible_freeipa/) from Ansible Galaxy.

Signed-off-by: Jose Angel Morena <jmorenas@redhat.com>
2025-05-21 15:38:52 +02:00
Rafael Guterres Jeffman
7245339934 Merge pull request #1351 from t-woerner/infra_image_start_debug
infra/image/shdefaults: Add SYS_PTRACE to CAP_DEFAULTS
v1.14.6
2025-04-17 11:53:02 -03:00
Thomas Woerner
638422e113 infra/image/shcontainer: Fix processing of multi item CAP_DEFAULTS
readarray expects to get an item per line to be added to the array.

Printing one item per line with printf fixes this to get the proper
formatting for "${CAP_DEFAULTS[@]}" as a valid input for readarray.
2025-04-17 16:46:12 +02:00
Thomas Woerner
432376524c infra/image/shdefaults: Add SYS_PTRACE to CAP_DEFAULTS
Debugging is now enabled by default in the containers that are
generated with container_create. "+SYS_PTRACE" has been added to
CAP_DEFAULTS in shdefaults for this.
2025-04-17 15:00:39 +02:00
Thomas Woerner
86701caf8b Merge pull request #1350 from freeipa/remove_pkg_resources
ipareplica: Don't rely on pkg_resources whenever possible
2025-04-17 14:50:43 +02:00
Thomas Woerner
d1857c18ac Merge pull request #1352 from freeipa/fix_sssd_on_test_container
test container: Add DAC_READ_SEARCH capability
2025-04-17 14:49:49 +02:00
Thomas Woerner
edbdd3af79 Merge pull request #1348 from abbra/fix-cert-iteration
Fix CA certificates iteration
2025-04-17 14:48:51 +02:00
Rafael Guterres Jeffman
2d3da2d72c test container: Add DAC_READ_SEARCH capability
SSSD 2.10+ runs under non-privileged user 'sssd' and relies on system
capabilities to get access to certain resources like /etc/krb5.keytab.
Not having these capabilities result in SSSD not starting.

Podman has reduced the capabilities granted to containers, and to be
able to start SSSD it is needed to add DAC_READ_SEARCH back.

This patch adds file infra/images/shdefaults to store the defaults used
by ansible-freeipa shell utilities in a contral location.

See:  https://github.com/containers/podman/discussions/24904#discussioncomment-11718823

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
2025-04-17 09:44:01 -03:00
Thomas Woerner
329c16f742 Merge pull request #1355 from freeipa/fix_container_tee_message
infra/image/shcontainer: Fix log message in container_tee
2025-04-17 14:15:50 +02:00
Rafael Guterres Jeffman
66c0be06d0 infra/image/shcontainer: Fix log message in container_tee
Fix a log message in function container_tee and quote the temporary
filename.

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
2025-04-16 16:25:29 -03:00
Rafael Guterres Jeffman
f04c90f4db Merge pull request #1354 from t-woerner/extended_infra_image_container_functions
infra/image/shcontainer: Volume support and new container_tee
2025-04-16 12:06:10 -03:00
Thomas Woerner
dfa4bcb68f infra/image/shcontainer: Volume support and new container_tee
This change adds support for volumes to container_create. Now it can be
used like in this example:

    container_create "${name}" "${local_image}" "hostname=${hostname}" \
        "${capabilities:+capabilities=$capabilities}" \
        volume=$PWD:/root/src

The new function container_tee has been added to enable creation of
fiiles with content from stdin like in this example:

    cat <<EOF | container_tee "${name}" "/root/.gdbinit"
    set debuginfod enabled on
    set follow-fork-mode child
    EOF
2025-04-16 16:11:14 +02:00
Rafael Guterres Jeffman
b1328ba7d5 ipareplica: Don't rely on pkg_resources whenever possible
Python's module "pkg_resources" API has been deprecated in Python 3.12
and will be removed in a future release, and recent FreeIPA versions
provide a replacement for pkg_resources.parse_version.

To remove ansible-freeipa dependency on pkg_resources and not add a
dependency on the 'packaging' module, which is not available in the
standard Python distribution, we'll try to import the funcion used in
FreeIPA to parse versions, and fallback to pkg_resources when it fails.

As an equivalent class is needed, a fallback function is not provided
and execution will fail if neither the FreeIPA nor the pkg_resources
parse_version function are available.

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
2025-04-08 11:31:05 -03:00
Rafael Guterres Jeffman
fe58f3a8ba Merge pull request #1301 from t-woerner/try_ubuntu_24.04_1
Use ubuntu 24.04 for testing
2025-04-02 12:30:43 -03:00
Thomas Woerner
4dc6192640 infra/image/shcontainer: Ensure '/ect/shadow' is readable
The shadow file in a Fedora or CentOS Stream container is not readable
any more using Ubuntu 24.04.

An extra call to ensure that the shadow file is readable again has been
added to container_start.
2025-04-02 17:21:35 +02:00
Thomas Woerner
e9435410b2 utils/setup_test_container.sh: Wait till systemd-journald is running
This ensures that systemctl list-jobs could be executed and it will
be waited till the list of jobs is empty.
2025-04-02 17:21:35 +02:00
Thomas Woerner
de6a0429a0 Merge pull request #1349 from freeipa/fix_flake8_7_2_0
Fix flake8 7 2 0
2025-04-02 17:10:18 +02:00
Rafael Guterres Jeffman
40d85f83e4 Fix linter issues related to 'global'
This patch fixes an issue reported by flake8 7.2.0 and enables a pylint
test that was disable, both related to the use of 'global'.

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
2025-04-02 11:59:30 -03:00
Rafael Guterres Jeffman
678927f35c Unpin flake8 version from requirements-dev.txt
Upstream flake8 lint test is executed with the latest available version
in pip, but the requirements-dev.txt had a pinned version, making flake8
error to be found too late.

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
2025-04-02 11:56:47 -03:00
Rafael Guterres Jeffman
f0e6d0c89f pre-commit: Bump flake8 version to 7.2.0
Bump pre-commit version to the latest available.

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
2025-04-02 11:55:19 -03:00
Thomas Woerner
c095c24950 Use ubuntu 24.04 for testing 2025-04-02 12:55:23 +02:00
Alexander Bokovoy
34dc75802c Fix CA certificates iteration
FreeIPA fix for https://pagure.io/freeipa/issue/9652 now produces five
elements tuple when iterating over CA certificate list, the last element
being the serial number. We do not need it, so extract only the first
four elements (certificate, nickname, trusted, EKU).

The regression was introduced by FreeIPA commit
f91b677ada376034b25d50e78475237c5976770e.

Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2025-03-30 13:01:35 +03:00