Skip to content
Open
Show file tree
Hide file tree
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
604 changes: 604 additions & 0 deletions library/ini_file_ansible_29.py

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions meta/collection-requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
---
collections:
- name: ansible.posix
version: '>=2.1.0,<2.2.0'
- name: community.general
version: '>=6.6.0,<12.0.0'
- name: fedora.linux_system_roles
193 changes: 185 additions & 8 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,39 @@
path: "{{ __ad_integration_sssd_conf }}"
register: __ad_sssd_conf_stat

# ansible 2.9 (ansible-engine) uses the vendored ini_file_ansible_29 module,
# since community.general cannot be installed there; other systems use the
# bare ini_file name, which redirects to the latest community.general.ini_file.
- name: Remove duplicate sections - ansible 2.9
ini_file_ansible_29:
path: "{{ __ad_integration_sssd_conf }}"
state: absent
section: "{{ item }}"
owner: root
group: root
mode: u=rw,g=,o=
loop: "{{ __ad_matching_section_names }}"
when:
- ansible_version.full is version('2.10', '<')
- __ad_sssd_conf_stat.stat.exists
notify: Handler for ad_integration to restart services - sssd

# Bare module name (not FQCN): on ansible 2.9 the collection is not
# installable and an unresolvable FQCN aborts play parsing even for a task
# skipped by "when". The bare name resolves to the ansible 2.9 builtin
# (skipped here) and redirects to the latest collection module elsewhere.
- name: Remove duplicate sections
community.general.ini_file:
ini_file: # noqa fqcn
path: "{{ __ad_integration_sssd_conf }}"
state: absent
section: "{{ item }}"
owner: root
group: root
mode: u=rw,g=,o=
loop: "{{ __ad_matching_section_names }}"
when: __ad_sssd_conf_stat.stat.exists
when:
- ansible_version.full is version('2.10', '>=')
- __ad_sssd_conf_stat.stat.exists
notify: Handler for ad_integration to restart services - sssd

- name: Build Command - Join to a specific Domain Controller
Expand Down Expand Up @@ -287,8 +310,32 @@
register: __ad_sssd_conf_content
when: __ad_sssd_conf_stat.stat.exists

# ansible 2.9 (ansible-engine) uses the vendored ini_file_ansible_29 module,
# since community.general cannot be installed there; other systems use the
# bare ini_file name, which redirects to the latest community.general.ini_file.
- name: Consolidate options from duplicate sections - ansible 2.9
ini_file_ansible_29:
path: "{{ __ad_integration_sssd_conf }}"
state: present
section: "{{ __ad_section_to_use }}"
option: "{{ item.key }}"
value: "{{ item.value }}"
create: true
owner: root
group: root
mode: u=rw,g=,o=
loop: "{{ (__ad_integration_matching_sections_before | d({})).values() | map('dict2items') | flatten | list }}"
notify: Handler for ad_integration to restart services - sssd
when:
- ansible_version.full is version('2.10', '<')
- ad_integration_sssd_merge_duplicate_sections | bool

# Bare module name (not FQCN): on ansible 2.9 the collection is not
# installable and an unresolvable FQCN aborts play parsing even for a task
# skipped by "when". The bare name resolves to the ansible 2.9 builtin
# (skipped here) and redirects to the latest collection module elsewhere.
- name: Consolidate options from duplicate sections
community.general.ini_file:
ini_file: # noqa fqcn
path: "{{ __ad_integration_sssd_conf }}"
state: present
section: "{{ __ad_section_to_use }}"
Expand All @@ -300,10 +347,35 @@
mode: u=rw,g=,o=
loop: "{{ (__ad_integration_matching_sections_before | d({})).values() | map('dict2items') | flatten | list }}"
notify: Handler for ad_integration to restart services - sssd
when: ad_integration_sssd_merge_duplicate_sections | bool
when:
- ansible_version.full is version('2.10', '>=')
- ad_integration_sssd_merge_duplicate_sections | bool

# ansible 2.9 (ansible-engine) uses the vendored ini_file_ansible_29 module,
# since community.general cannot be installed there; other systems use the
# bare ini_file name, which redirects to the latest community.general.ini_file.
- name: Configure SSSD settings - ansible 2.9
ini_file_ansible_29:
path: "{{ __ad_integration_sssd_conf }}"
state: "{{ item.state | default('present') }}"
section: sssd
option: "{{ item.key }}"
value: "{{ item.value }}"
create: true
owner: root
group: root
mode: u=rw,g=,o=
loop: "{{ ad_integration_sssd_settings }}"
notify: Handler for ad_integration to restart services - sssd
when:
- ansible_version.full is version('2.10', '<')

# Bare module name (not FQCN): on ansible 2.9 the collection is not
# installable and an unresolvable FQCN aborts play parsing even for a task
# skipped by "when". The bare name resolves to the ansible 2.9 builtin
# (skipped here) and redirects to the latest collection module elsewhere.
- name: Configure SSSD settings
community.general.ini_file:
ini_file: # noqa fqcn
path: "{{ __ad_integration_sssd_conf }}"
state: "{{ item.state | default('present') }}"
section: sssd
Expand All @@ -315,9 +387,60 @@
mode: u=rw,g=,o=
loop: "{{ ad_integration_sssd_settings }}"
notify: Handler for ad_integration to restart services - sssd
when:
- ansible_version.full is version('2.10', '>=')

# ansible 2.9 (ansible-engine) uses the vendored ini_file_ansible_29 module,
# since community.general cannot be installed there; other systems use the
# bare ini_file name, which redirects to the latest community.general.ini_file.
- name: Configure dynamic DNS updates - ansible 2.9
ini_file_ansible_29:
path: "{{ __ad_integration_sssd_conf }}"
state: present
section: "{{ __ad_section_to_use }}"
option: "{{ item.key }}"
value: "{{ item.value }}"
create: true
owner: root
group: root
mode: u=rw,g=,o=
loop:
- key: dyndns_update
value: "{{ ad_dyndns_update | string }}"
- key: dyndns_ttl
value: "{{ ad_dyndns_ttl | int }}"
- key: dyndns_iface
value: "{{ ad_dyndns_iface | string
if ad_dyndns_iface is not none else '' }}"
- key: dyndns_refresh_interval
value: "{{ ad_dyndns_refresh_interval | int }}"
- key: dyndns_update_ptr
value: "{{ ad_dyndns_update_ptr | string }}"
- key: dyndns_force_tcp
value: "{{ ad_dyndns_force_tcp | string }}"
- key: dyndns_auth
value: "{{ ad_dyndns_auth | string if ad_dyndns_auth else '' }}"
- key: dyndns_server
value: "{{ ad_dyndns_server | string
if ad_dyndns_server is not none else '' }}"
# For dynamic dns to work the machine either needs fqdn in hostname
# or ad_hostname needs to be defined.
- key: ad_hostname
value: "{{ ansible_facts['hostname'] + '.' + ad_integration_realm | lower
| string if '.' not in ansible_facts['hostname'] else '' }}"
when:
- ansible_version.full is version('2.10', '<')
- ad_dyndns_update | bool
- item.value is not none
- item.value != ''
notify: Handler for ad_integration to restart services - sssd

# Bare module name (not FQCN): on ansible 2.9 the collection is not
# installable and an unresolvable FQCN aborts play parsing even for a task
# skipped by "when". The bare name resolves to the ansible 2.9 builtin
# (skipped here) and redirects to the latest collection module elsewhere.
- name: Configure dynamic DNS updates
community.general.ini_file:
ini_file: # noqa fqcn
path: "{{ __ad_integration_sssd_conf }}"
state: present
section: "{{ __ad_section_to_use }}"
Expand Down Expand Up @@ -352,13 +475,37 @@
value: "{{ ansible_facts['hostname'] + '.' + ad_integration_realm | lower
| string if '.' not in ansible_facts['hostname'] else '' }}"
when:
- ansible_version.full is version('2.10', '>=')
- ad_dyndns_update | bool
- item.value is not none
- item.value != ''
notify: Handler for ad_integration to restart services - sssd

# ansible 2.9 (ansible-engine) uses the vendored ini_file_ansible_29 module,
# since community.general cannot be installed there; other systems use the
# bare ini_file name, which redirects to the latest community.general.ini_file.
- name: Configure custom SSSD settings - ansible 2.9
ini_file_ansible_29:
path: "{{ __ad_integration_sssd_conf }}"
state: "{{ item.state | default('present') }}"
section: "{{ __ad_section_to_use }}"
option: "{{ item.key }}"
value: "{{ item.value }}"
create: true
owner: root
group: root
mode: u=rw,g=,o=
loop: "{{ ad_integration_sssd_custom_settings }}"
notify: Handler for ad_integration to restart services - sssd
when:
- ansible_version.full is version('2.10', '<')

# Bare module name (not FQCN): on ansible 2.9 the collection is not
# installable and an unresolvable FQCN aborts play parsing even for a task
# skipped by "when". The bare name resolves to the ansible 2.9 builtin
# (skipped here) and redirects to the latest collection module elsewhere.
- name: Configure custom SSSD settings
community.general.ini_file:
ini_file: # noqa fqcn
path: "{{ __ad_integration_sssd_conf }}"
state: "{{ item.state | default('present') }}"
section: "{{ __ad_section_to_use }}"
Expand All @@ -370,12 +517,41 @@
mode: u=rw,g=,o=
loop: "{{ ad_integration_sssd_custom_settings }}"
notify: Handler for ad_integration to restart services - sssd
when:
- ansible_version.full is version('2.10', '>=')

# If dyndns_iface and/or dyndns_server previously had a configured value but are
# now being set to `none` or `''`, remove the options form sssd.conf so sssd
# will determine the default values.
# ansible 2.9 (ansible-engine) uses the vendored ini_file_ansible_29 module,
# since community.general cannot be installed there; other systems use the
# bare ini_file name, which redirects to the latest community.general.ini_file.
- name: Cleanup dynamic DNS configuration options - ansible 2.9
ini_file_ansible_29:
path: "{{ __ad_integration_sssd_conf }}"
state: absent
section: "{{ __ad_section_to_use }}"
option: "{{ item.key }}"
owner: root
group: root
mode: u=rw,g=,o=
loop:
- key: dyndns_iface
value: "{{ '' if ad_dyndns_iface is none else ad_dyndns_iface }}"
- key: dyndns_server
value: "{{ '' if ad_dyndns_server is none else ad_dyndns_server }}"
when:
- ansible_version.full is version('2.10', '<')
- ad_dyndns_update | bool
- item.value is none or item.value == ''
notify: Handler for ad_integration to restart services - sssd

# Bare module name (not FQCN): on ansible 2.9 the collection is not
# installable and an unresolvable FQCN aborts play parsing even for a task
# skipped by "when". The bare name resolves to the ansible 2.9 builtin
# (skipped here) and redirects to the latest collection module elsewhere.
- name: Cleanup dynamic DNS configuration options
community.general.ini_file:
ini_file: # noqa fqcn
path: "{{ __ad_integration_sssd_conf }}"
state: absent
section: "{{ __ad_section_to_use }}"
Expand All @@ -389,6 +565,7 @@
- key: dyndns_server
value: "{{ '' if ad_dyndns_server is none else ad_dyndns_server }}"
when:
- ansible_version.full is version('2.10', '>=')
- ad_dyndns_update | bool
- item.value is none or item.value == ''
notify: Handler for ad_integration to restart services - sssd
Expand Down
1 change: 1 addition & 0 deletions tests/library/ini_file_ansible_29.py
67 changes: 65 additions & 2 deletions tests/tests_dyndns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,41 @@
ad_dyndns_auth: GSS-TSIG
ad_dyndns_update: true

# ansible 2.9 (ansible-engine) uses the vendored ini_file_ansible_29
# module, since community.general cannot be installed there; other
# systems use the bare ini_file name, which redirects to the latest
# community.general.ini_file.
- name: Check custom dyndns settings - ansible 2.9
ini_file_ansible_29:
path: "{{ __ad_integration_sssd_conf }}"
state: present
section: domain/{{ ad_integration_realm }}
option: "{{ item.key }}"
value: "{{ item.value }}"
create: true
owner: root
group: root
mode: u=rw,g=,o=
loop:
- key: dyndns_update
value: "True"
- key: dyndns_iface
value: TESTING
- key: dyndns_auth
value: GSS-TSIG
- key: dyndns_server
value: 127.0.0.1
register: __result
failed_when: __result is changed
when: ansible_version.full is version('2.10', '<')

# Bare module name (not FQCN): on ansible 2.9 the collection is not
# installable and an unresolvable FQCN aborts play parsing even for a
# task skipped by "when". The bare name resolves to the ansible 2.9
# builtin (skipped here) and redirects to the latest collection module
# elsewhere.
- name: Check custom dyndns settings
community.general.ini_file:
ini_file: # noqa fqcn
path: "{{ __ad_integration_sssd_conf }}"
state: present
section: domain/{{ ad_integration_realm }}
Expand All @@ -67,6 +100,7 @@
value: 127.0.0.1
register: __result
failed_when: __result is changed
when: ansible_version.full is version('2.10', '>=')

- name: Search /var/log/sssd/sssd.log for [sss_ini_call_validators]
command: grep -i sss_ini_call_validators /var/log/sssd/sssd.log
Expand All @@ -92,8 +126,36 @@
state: restarted
when: not __ad_integration_test_sssd_config_only | d(false)

# ansible 2.9 (ansible-engine) uses the vendored ini_file_ansible_29
# module, since community.general cannot be installed there; other
# systems use the bare ini_file name, which redirects to the latest
# community.general.ini_file.
- name: Check custom dyndns settings are removed - ansible 2.9
ini_file_ansible_29:
path: "{{ __ad_integration_sssd_conf }}"
state: absent
section: domain/{{ ad_integration_realm }}
option: "{{ item.key }}"
create: true
owner: root
group: root
mode: u=rw,g=,o=
loop:
- key: dyndns_iface
value: null
- key: dyndns_server
value: null
register: __result
failed_when: __result is changed
when: ansible_version.full is version('2.10', '<')

# Bare module name (not FQCN): on ansible 2.9 the collection is not
# installable and an unresolvable FQCN aborts play parsing even for a
# task skipped by "when". The bare name resolves to the ansible 2.9
# builtin (skipped here) and redirects to the latest collection module
# elsewhere.
- name: Check custom dyndns settings are removed
community.general.ini_file:
ini_file: # noqa fqcn
path: "{{ __ad_integration_sssd_conf }}"
state: absent
section: domain/{{ ad_integration_realm }}
Expand All @@ -109,6 +171,7 @@
value: null
register: __result
failed_when: __result is changed
when: ansible_version.full is version('2.10', '>=')

- name: Test - Verify IPv4 DNS records were created
when: not __ad_integration_test_sssd_config_only | d(false)
Expand Down
Loading
Loading