Skip to content

Commit

Permalink
Merge pull request #1013 from t-woerner/unnamed-tasks
Browse files Browse the repository at this point in the history
yamllint: All tasks need to be named
  • Loading branch information
rjeffman authored Jan 11, 2023
2 parents f8b5851 + 2a1ecdb commit 82e176a
Show file tree
Hide file tree
Showing 41 changed files with 172 additions and 92 deletions.
3 changes: 2 additions & 1 deletion roles/ipabackup/tasks/backup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
{{ "--log-file="+ipabackup_log_file if ipabackup_log_file is defined else "" }}
register: result_ipabackup

- block:
- name: Handle backup
block:
- name: Get ipabackup_item from stderr or stdout output
ansible.builtin.set_fact:
ipabackup_item: "{{ item | regex_search('\n.*/([^\n]+)','\\1') | first }}"
Expand Down
12 changes: 8 additions & 4 deletions roles/ipabackup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
state is defined and
(state == "copied" or state == "restored" or state == "absent")

- block:
- name: Get all backup names for copy to controller
block:
- name: Get list of all backups on IPA server
ansible.builtin.shell:
find . -name "ipa-full-*" -o -name "ipa-data-*" | cut -d"/" -f 2
Expand All @@ -62,7 +63,8 @@
state == "absent") and
ipabackup_name is defined and ipabackup_name == "all"

- block:
- name: Set ipabackup_names from ipabackup_name
block:
- name: Fail on ipabackup_name all
ansible.builtin.fail: msg="ipabackup_name can not be all in this case"
when: ipabackup_name is defined and ipabackup_name == "all"
Expand All @@ -83,7 +85,8 @@
ipabackup_names: []
when: ipabackup_names is not defined and ipabackup_name is not defined

- block:
- name: Process "{{ ipabackup_names }}"
block:
- name: Copy backup from IPA server
ansible.builtin.include_tasks: "{{ role_path }}/tasks/copy_backup_from_server.yml"
vars:
Expand Down Expand Up @@ -117,7 +120,8 @@

# Use only first item in ipabackup_names for copy to server and for restore.

- block:
- name: Process "{{ ipabackup_names[0] }}"
block:
- name: Copy backup to server
ansible.builtin.include_tasks: "{{ role_path }}/tasks/copy_backup_to_server.yml"

Expand Down
6 changes: 4 additions & 2 deletions roles/ipabackup/tasks/restore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@

### INSTALL PACKAGES

- block:
- name: Package installation
block:
- name: Ensure that IPA server packages are installed
ansible.builtin.package:
name: "{{ ipaserver_packages }}"
Expand Down Expand Up @@ -80,7 +81,8 @@

### START FIREWALLD

- block:
- name: Firewall configuration
block:
- name: Ensure that firewalld is running
ansible.builtin.systemd:
name: firewalld
Expand Down
32 changes: 19 additions & 13 deletions roles/ipaclient/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
ipaadmin_principal: admin
when: ipaadmin_principal is undefined and ipaclient_keytab is undefined

- name: Install - Configure DNS resolver Block
- name: Install - DNS resolver configuration
block:

- name: Install - Fail on missing ipaclient_domain and ipaserver_domain
Expand Down Expand Up @@ -72,7 +72,8 @@
| default(ipasssd_enable_dns_updates) }}"
register: result_ipaclient_test

- block:
- name: Install - Client deployment
block:
- name: Install - Cleanup leftover ccache
ansible.builtin.file:
path: "/etc/ipa/.dns_ccache"
Expand Down Expand Up @@ -125,7 +126,8 @@
# to create a OneTime Password
# If a keytab is specified in the hostent, then the hostent will be disabled
# if ipaclient_use_otp is set.
- block:
- name: Install - Obtain OTP
block:
- name: Install - Keytab or password is required for getting otp
ansible.builtin.fail:
msg: Keytab or password is required for getting otp
Expand Down Expand Up @@ -188,14 +190,8 @@
ipaadmin_password: "{{ ipaclient_otp }}"
when: ipaclient_otp is defined

- block:
# This block is executed only when
# not (not ipaclient_on_master | bool and
# not result_ipaclient_join.changed and
# not ipaclient_allow_repair | bool and
# (result_ipaclient_test_keytab.krb5_keytab_ok or
# (result_ipaclient_join.already_joined is defined and
# result_ipaclient_join.already_joined)))
- name: Install - Check keytab, principal and keytab
block:

- name: Install - Check if principal and keytab are set
ansible.builtin.fail: msg="Admin principal and client keytab cannot be used together"
Expand Down Expand Up @@ -252,7 +248,16 @@
(not result_ipaclient_test_keytab.krb5_keytab_ok or
ipaclient_force_join)

- block:
- name: Install - Allow repair checks
block:
# This block is executed only when
# not (not ipaclient_on_master | bool and
# not result_ipaclient_join.changed and
# not ipaclient_allow_repair | bool and
# (result_ipaclient_test_keytab.krb5_keytab_ok or
# (result_ipaclient_join.already_joined is defined and
# result_ipaclient_join.already_joined)))

- name: krb5 configuration not correct
ansible.builtin.fail:
msg: >
Expand All @@ -275,7 +280,8 @@
(result_ipaclient_join.already_joined is defined and
result_ipaclient_join.already_joined))

- block:
- name: Install - Configuration
block:
- name: Install - Configure IPA default.conf
ipaclient_ipa_conf:
servers: "{{ result_ipaclient_test.servers }}"
Expand Down
9 changes: 6 additions & 3 deletions roles/ipareplica/tasks/install.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
# tasks file for ipareplica

- block:
- name: Package installation
block:

- name: Install - Ensure IPA replica packages are installed
ansible.builtin.package:
Expand All @@ -28,7 +29,8 @@

when: ipareplica_install_packages | bool

- block:
- name: Firewall configuration
block:
- name: Firewalld service - Ensure that firewalld is running
ansible.builtin.systemd:
name: firewalld
Expand Down Expand Up @@ -101,7 +103,8 @@
no_dnssec_validation: "{{ ipareplica_no_dnssec_validation }}"
register: result_ipareplica_test

- block:
- name: Install - Deploy replica
block:
# This block is executed only when
# not ansible_check_mode and
# not (result_ipareplica_test.client_already_configured is defined or
Expand Down
18 changes: 12 additions & 6 deletions roles/ipaserver/tasks/install.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
# tasks file for ipaserver

- block:
- name: Install - Package installation
block:
- name: Install - Ensure that IPA server packages are installed
ansible.builtin.package:
name: "{{ ipaserver_packages }}"
Expand All @@ -27,7 +28,8 @@

when: ipaserver_install_packages | bool

- block:
- name: Install - Firewall configuration
block:
- name: Firewalld service - Ensure that firewalld is running
ansible.builtin.systemd:
name: firewalld
Expand All @@ -51,7 +53,8 @@

when: ipaserver_setup_firewalld | bool

- ansible.builtin.include_tasks: "{{ role_path }}/tasks/copy_external_cert.yml"
- name: Include tasks "{{ role_path }}/tasks/copy_external_cert.yml"
ansible.builtin.include_tasks: "{{ role_path }}/tasks/copy_external_cert.yml"
with_items: "{{ ipaserver_external_cert_files_from_controller }}"
when: ipaserver_external_cert_files_from_controller is defined and
ipaserver_external_cert_files_from_controller|length > 0 and
Expand Down Expand Up @@ -127,14 +130,16 @@
### additional ###
register: result_ipaserver_test

- block:
- name: Install - Deploy server
block:
# This block is executed only when
# not ansible_check_mode and
# not (not result_ipaserver_test.changed and
# (result_ipaserver_test.client_already_configured is defined or
# result_ipaserver_test.server_already_configured is defined)

- block:
- name: Install - Obtain master password
block:
- name: Install - Master password creation
no_log: yes
ipaserver_master_password:
Expand Down Expand Up @@ -315,7 +320,8 @@
when: result_ipaserver_setup_ca.csr_generated | bool and
ipaserver_copy_csr_to_controller | bool

- block:
- name: Install - Configure services
block:
- name: Install - Setup otpd
ipaserver_setup_otpd:
realm: "{{ result_ipaserver_test.realm }}"
Expand Down
6 changes: 4 additions & 2 deletions roles/ipasmartcard_client/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
# If neither distro nor family is supported, try a default configuration.
- "vars/default.yml"

- block:
- name: Client configuration
block:

# CA CERTS

Expand Down Expand Up @@ -99,7 +100,8 @@

# Ensure /etc/sssd/pki exists

- block:
- name: Prepare for authselect
block:
- name: Ensure /etc/sssd/pki exists
ansible.builtin.file:
path: /etc/sssd/pki
Expand Down
9 changes: 6 additions & 3 deletions roles/ipasmartcard_server/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
# If neither distro nor family is supported, try a default configuration.
- "vars/default.yml"

- block:
- name: Server configuration
block:

# CA CERTS

Expand Down Expand Up @@ -162,7 +163,8 @@

# HTTPD IFP

- block:
- name: Allow HTTPD ifp
block:

# Allow Apache to access SSSD IFP

Expand Down Expand Up @@ -190,7 +192,8 @@

# Ensure /etc/sssd/pki exists

- block:
- name: Prepare for authselect
block:
- name: Ensure /etc/sssd/pki exists
ansible.builtin.file:
path: /etc/sssd/pki
Expand Down
3 changes: 2 additions & 1 deletion tests/automount/test_automountkey.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
key: NewKeyName
state: absent

- block:
- name: Execute Automount Key tests
block:
### test the key creation, and modification
- name: ensure key TestKey is present
ipaautomountkey:
Expand Down
3 changes: 2 additions & 1 deletion tests/automount/test_automountmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
state: present

# TESTS
- block:
- name: Execute Automount Map tests
block:
- name: ensure map TestMap is present
ipaautomountmap:
ipaadmin_password: SomeADMINpassword
Expand Down
18 changes: 12 additions & 6 deletions tests/config/test_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
gather_facts: false

tasks:
- ansible.builtin.include_tasks: ../env_freeipa_facts.yml
- name: Include tasks ../env_freeipa_facts.yml
ansible.builtin.include_tasks: ../env_freeipa_facts.yml

- block:
- name: Execute config tests
block:
# Retrieve current configuration.
- name: return current values of the global configuration options
ipaconfig:
Expand Down Expand Up @@ -56,7 +58,8 @@
ipaapi_context: "{{ ipa_context | default(omit) }}"
pac_type: ""

- block:
- name: Execute tests if ipa_version >= 4.8.0
block:
- name: set maxhostname to 255
ipaconfig:
ipaadmin_password: SomeADMINpassword
Expand Down Expand Up @@ -221,7 +224,8 @@
register: result
failed_when: result.changed or result.failed

- block:
- name: Execute tests if ipa_version >= 4.8.0
block:
- name: set maxhostname to 77
ipaconfig:
ipaadmin_password: SomeADMINpassword
Expand Down Expand Up @@ -410,7 +414,8 @@
register: result
failed_when: not result.changed or result.failed

- block:
- name: Execute tests if ipa_version >= 4.8.0
block:
- name: reset maxhostname
ipaconfig:
ipaadmin_password: SomeADMINpassword
Expand Down Expand Up @@ -445,7 +450,8 @@
register: result
failed_when: result.changed or result.failed

- block:
- name: Execute tests if ipa_version >= 4.8.0
block:
- name: reset maxhostname
ipaconfig:
ipaadmin_password: SomeADMINpassword
Expand Down
3 changes: 2 additions & 1 deletion tests/config/test_config_sid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
register: previous

# TESTS
- block:
- name: Test config sid
block:
- name: Check if SID is enabled.
ipaconfig:
ipaadmin_password: SomeADMINpassword
Expand Down
3 changes: 2 additions & 1 deletion tests/dnsconfig/test_dnsconfig_forwarders_ports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
gather_facts: no

tasks:
- block:
- name: Test dnsconfig forwarders ports
block:
# Setup.
- name: Ensure forwarder with custom port is absent.
ipadnsconfig:
Expand Down
3 changes: 2 additions & 1 deletion tests/env_freeipa_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
ipa_host_is_client: "{{ (output.stdout_lines[-1] == 'CLIENT') | bool }}"
trust_test_is_supported: no

- block:
- name: Ensure ipaserver_domain is set
block:
- name: Get Domain from server name
ansible.builtin.set_fact:
ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}"
Expand Down
Loading

0 comments on commit 82e176a

Please sign in to comment.