From 6b7633976cd9c45ad3f2c698c79763d3e9490a75 Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman <rjeffman@redhat.com> Date: Tue, 3 Jan 2023 16:56:59 -0300 Subject: [PATCH] roles: Fix use of ansible.builtin.fail free-form message. ansible-lint warns to avoid using free-form when calling module actions and ansible-freeipa roles used this form with 'ansible.builtin.fail'. --- roles/ipabackup/tasks/backup.yml | 3 ++- .../tasks/copy_backup_from_server.yml | 6 ++++-- .../ipabackup/tasks/copy_backup_to_server.yml | 6 ++++-- roles/ipabackup/tasks/main.yml | 18 ++++++++++++------ roles/ipabackup/tasks/restore.yml | 6 ++++-- roles/ipaclient/tasks/install.yml | 17 +++++++++++------ roles/ipasmartcard_client/tasks/main.yml | 6 ++++-- roles/ipasmartcard_server/tasks/main.yml | 12 ++++++++---- 8 files changed, 49 insertions(+), 25 deletions(-) diff --git a/roles/ipabackup/tasks/backup.yml b/roles/ipabackup/tasks/backup.yml index b2f77817..5aa95dcc 100644 --- a/roles/ipabackup/tasks/backup.yml +++ b/roles/ipabackup/tasks/backup.yml @@ -26,7 +26,8 @@ label: "" - name: Fail on missing ipabackup_item - ansible.builtin.fail: msg="Failed to get ipabackup_item" + ansible.builtin.fail: + msg: "Failed to get ipabackup_item" when: ipabackup_item is not defined - name: Copy backup to controller diff --git a/roles/ipabackup/tasks/copy_backup_from_server.yml b/roles/ipabackup/tasks/copy_backup_from_server.yml index 516814b1..85c78e89 100644 --- a/roles/ipabackup/tasks/copy_backup_from_server.yml +++ b/roles/ipabackup/tasks/copy_backup_from_server.yml @@ -1,6 +1,7 @@ --- - name: Fail on invalid ipabackup_item - ansible.builtin.fail: msg="ipabackup_item {{ ipabackup_item }} is not valid" + ansible.builtin.fail: + msg: "ipabackup_item {{ ipabackup_item }} is not valid" when: ipabackup_item is not defined or ipabackup_item | length < 1 or (ipabackup_item.find("ipa-full-") == -1 and @@ -19,7 +20,8 @@ register: result_backup_stat - name: Fail on missing backup directory - ansible.builtin.fail: msg="Unable to find backup {{ ipabackup_item }}" + ansible.builtin.fail: + msg: "Unable to find backup {{ ipabackup_item }}" when: result_backup_stat.stat.isdir is not defined - name: Get backup files to copy for "{{ ipabackup_item }}" diff --git a/roles/ipabackup/tasks/copy_backup_to_server.yml b/roles/ipabackup/tasks/copy_backup_to_server.yml index 6fa20613..eb591508 100644 --- a/roles/ipabackup/tasks/copy_backup_to_server.yml +++ b/roles/ipabackup/tasks/copy_backup_to_server.yml @@ -1,6 +1,7 @@ --- - name: Fail on invalid ipabackup_name - ansible.builtin.fail: msg="ipabackup_name {{ ipabackup_name }} is not valid" + ansible.builtin.fail: + msg: "ipabackup_name {{ ipabackup_name }} is not valid" when: ipabackup_name is not defined or ipabackup_name | length < 1 or (ipabackup_name.find("ipa-full-") == -1 and @@ -30,7 +31,8 @@ become: no - name: Fail on missing backup to copy - ansible.builtin.fail: msg="Unable to find backup {{ ipabackup_name }}" + ansible.builtin.fail: + msg: "Unable to find backup {{ ipabackup_name }}" when: result_backup_stat.stat.isdir is not defined - name: Copy backup files to server for "{{ ipabackup_item }}" diff --git a/roles/ipabackup/tasks/main.yml b/roles/ipabackup/tasks/main.yml index 25d8c25c..7b323990 100644 --- a/roles/ipabackup/tasks/main.yml +++ b/roles/ipabackup/tasks/main.yml @@ -2,7 +2,8 @@ # tasks file for ipabackup - name: Check for empty vars - ansible.builtin.fail: msg="Variable {{ item }} is empty" + ansible.builtin.fail: + msg: "Variable {{ item }} is empty" when: "item in vars and not vars[item]" with_items: "{{ ipabackup_empty_var_checks }}" vars: @@ -23,11 +24,13 @@ when: ipabackup_online | bool and not ipabackup_data | bool - name: Fail if ipabackup_from_controller and ipabackup_to_controller are set - ansible.builtin.fail: msg="ipabackup_from_controller and ipabackup_to_controller are set" + ansible.builtin.fail: + msg: "ipabackup_from_controller and ipabackup_to_controller are set" when: ipabackup_from_controller | bool and ipabackup_to_controller | bool - name: Fail for given ipabackup_name if state is not copied, restored or absent - ansible.builtin.fail: msg="ipabackup_name is given and state is not copied, restored or absent" + ansible.builtin.fail: + msg: "ipabackup_name is given and state is not copied, restored or absent" when: state is not defined or (state != "copied" and state != "restored" and state != "absent") and ipabackup_name is defined @@ -40,7 +43,8 @@ when: state|default("present") == "present" - name: Fail on missing ipabackup_name - ansible.builtin.fail: msg="ipabackup_name is not set" + ansible.builtin.fail: + msg: "ipabackup_name is not set" when: (ipabackup_name is not defined or not ipabackup_name) and state is defined and (state == "copied" or state == "restored" or state == "absent") @@ -66,7 +70,8 @@ - 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" + ansible.builtin.fail: + msg: "ipabackup_name can not be all in this case" when: ipabackup_name is defined and ipabackup_name == "all" - name: Set ipabackup_names from ipabackup_name string @@ -114,7 +119,8 @@ # restore. - name: Fail to copy or restore more than one backup on the server - ansible.builtin.fail: msg="Only one backup can be copied to the server or restored" + ansible.builtin.fail: + msg: "Only one backup can be copied to the server or restored" when: state is defined and (state == "copied" or state == "restored") and ipabackup_from_controller | bool and ipabackup_names | length != 1 diff --git a/roles/ipabackup/tasks/restore.yml b/roles/ipabackup/tasks/restore.yml index 1a0794da..290ba249 100644 --- a/roles/ipabackup/tasks/restore.yml +++ b/roles/ipabackup/tasks/restore.yml @@ -26,7 +26,8 @@ register: result_backup_stat - name: Fail on missing backup directory - ansible.builtin.fail: msg="Unable to find backup {{ ipabackup_item }}" + ansible.builtin.fail: + msg: "Unable to find backup {{ ipabackup_item }}" when: result_backup_stat.stat.isdir is not defined - name: Stat header file in backup "{{ ipabackup_item }}" @@ -35,7 +36,8 @@ register: result_backup_header_stat - name: Fail on missing header file in backup - ansible.builtin.fail: msg="Unable to find backup {{ ipabackup_item }} header file" + ansible.builtin.fail: + msg: "Unable to find backup {{ ipabackup_item }} header file" when: result_backup_header_stat.stat.isreg is not defined - name: Get services from backup diff --git a/roles/ipaclient/tasks/install.yml b/roles/ipaclient/tasks/install.yml index 28998c56..922259b9 100644 --- a/roles/ipaclient/tasks/install.yml +++ b/roles/ipaclient/tasks/install.yml @@ -19,7 +19,8 @@ ipaclient_servers is not defined - name: Install - Check that either password or keytab is set - ansible.builtin.fail: msg="ipaadmin_password and ipaadmin_keytab cannot be used together" + ansible.builtin.fail: + msg: "ipaadmin_password and ipaadmin_keytab cannot be used together" when: ipaadmin_keytab is defined and ipaadmin_password is defined - name: Install - Set default principal if no keytab is given @@ -31,11 +32,13 @@ block: - name: Install - Fail on missing ipaclient_domain and ipaserver_domain - ansible.builtin.fail: msg="ipaclient_domain or ipaserver_domain is required for ipaclient_configure_dns_resolver" + ansible.builtin.fail: + msg: "ipaclient_domain or ipaserver_domain is required for ipaclient_configure_dns_resolver" when: ipaserver_domain is not defined and ipaclient_domain is not defined - name: Install - Fail on missing ipaclient_servers - ansible.builtin.fail: msg="ipaclient_dns_servers is required for ipaclient_configure_dns_resolver" + ansible.builtin.fail: + msg: "ipaclient_dns_servers is required for ipaclient_configure_dns_resolver" when: ipaclient_dns_servers is not defined - name: Install - Configure DNS resolver @@ -130,7 +133,7 @@ block: - name: Install - Keytab or password is required for getting otp ansible.builtin.fail: - msg: Keytab or password is required for getting otp + msg: "Keytab or password is required for getting otp" when: ipaadmin_keytab is undefined and ipaadmin_password is undefined - name: Install - Create temporary file for keytab @@ -194,11 +197,13 @@ block: - name: Install - Check if principal and keytab are set - ansible.builtin.fail: msg="Admin principal and client keytab cannot be used together" + ansible.builtin.fail: + msg: "Admin principal and client keytab cannot be used together" when: ipaadmin_principal is defined and ipaclient_keytab is defined - name: Install - Check if one of password or keytabs are set - ansible.builtin.fail: msg="At least one of password or keytabs must be specified" + ansible.builtin.fail: + msg: "At least one of password or keytabs must be specified" when: not result_ipaclient_test_keytab.krb5_keytab_ok and ipaadmin_password is undefined and ipaadmin_keytab is undefined diff --git a/roles/ipasmartcard_client/tasks/main.yml b/roles/ipasmartcard_client/tasks/main.yml index 54ced777..bdbfc801 100644 --- a/roles/ipasmartcard_client/tasks/main.yml +++ b/roles/ipasmartcard_client/tasks/main.yml @@ -2,7 +2,8 @@ # tasks file for ipasmartcard_client role - name: Uninstall smartcard client - ansible.builtin.fail: msg="Uninstalling smartcard for IPA is not supported" + ansible.builtin.fail: + msg: "Uninstalling smartcard for IPA is not supported" when: state|default('present') == 'absent' - name: Import variables specific to distribution @@ -36,7 +37,8 @@ # Fail on empty "ipasmartcard_client_ca_certs" - name: Fail on empty "ipasmartcard_client_ca_certs" - ansible.builtin.fail: msg="No CA certs given in 'ipasmartcard_client_ca_certs'" + ansible.builtin.fail: + msg: "No CA certs given in 'ipasmartcard_client_ca_certs'" when: ipasmartcard_client_ca_certs is not defined or ipasmartcard_client_ca_certs | length < 1 diff --git a/roles/ipasmartcard_server/tasks/main.yml b/roles/ipasmartcard_server/tasks/main.yml index 6f0fa28e..1c214d05 100644 --- a/roles/ipasmartcard_server/tasks/main.yml +++ b/roles/ipasmartcard_server/tasks/main.yml @@ -2,7 +2,8 @@ # tasks file for ipasmartcard_server role - name: Uninstall smartcard server - ansible.builtin.fail: msg="Uninstalling smartcard for IPA is not supported" + ansible.builtin.fail: + msg: "Uninstalling smartcard for IPA is not supported" when: state|default('present') == 'absent' - name: Import variables specific to distribution @@ -27,7 +28,8 @@ # Fail on empty "ipasmartcard_server_ca_certs" - name: Fail on empty "ipasmartcard_server_ca_certs" - ansible.builtin.fail: msg="No CA certs given in 'ipasmartcard_server_ca_certs'" + ansible.builtin.fail: + msg: "No CA certs given in 'ipasmartcard_server_ca_certs'" when: ipasmartcard_server_ca_certs is not defined or ipasmartcard_server_ca_certs | length < 1 @@ -70,7 +72,8 @@ register: result_ipa_server_show - name: Fail if not an IPA server - ansible.builtin.fail: msg="Not an IPA server" + ansible.builtin.fail: + msg: "Not an IPA server" when: result_ipa_server_show.failed - name: Get Domain from server-find server name @@ -83,7 +86,8 @@ register: result_get_ipaca_records - name: Fail if ipa-ca records are not resolvable - ansible.builtin.fail: msg="ipa-ca records are not resolvable" + ansible.builtin.fail: + msg: "ipa-ca records are not resolvable" when: result_get_ipaca_records.failed or result_get_ipaca_records.stdout | length == 0 -- GitLab