From a26be8a0539033be4cce45ebb548fad3888c26a4 Mon Sep 17 00:00:00 2001 From: Marcus Burghardt Date: Fri, 2 Dec 2022 11:07:01 +0100 Subject: [PATCH] Improve the arguments for Ansible command module It was used the awk command in a task and the delimiter character was ":". This has likely been worked around in the past, but not in the most compatible way, causing the Playbook a fatal error on some systems with different versions of Ansible. Relevant tasks have been improved to be more robust and compatible. --- .../ansible/shared.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/linux_os/guide/system/accounts/accounts-restrictions/password_expiration/accounts_password_set_max_life_existing/ansible/shared.yml b/linux_os/guide/system/accounts/accounts-restrictions/password_expiration/accounts_password_set_max_life_existing/ansible/shared.yml index 8066145006f..8651bba6d0b 100644 --- a/linux_os/guide/system/accounts/accounts-restrictions/password_expiration/accounts_password_set_max_life_existing/ansible/shared.yml +++ b/linux_os/guide/system/accounts/accounts-restrictions/password_expiration/accounts_password_set_max_life_existing/ansible/shared.yml @@ -6,8 +6,8 @@ {{{ ansible_instantiate_variables("var_accounts_maximum_age_login_defs") }}} - name: Collect users with not correct maximum time period between password changes - ansible.builtin.command: > - awk -F: '$5 > {{ var_accounts_maximum_age_login_defs }} || $5 == "" {print $1}' /etc/shadow + ansible.builtin.command: + cmd: awk -F':' '$5 > {{ var_accounts_maximum_age_login_defs }} || $5 == "" {print $1}' /etc/shadow register: user_names - name: Change the maximum time period between password changes @@ -16,8 +16,8 @@ user: '{{ item }}' password_expire_max: '{{ var_accounts_maximum_age_login_defs }}' {{% else %}} - ansible.builtin.command: > - chage -M {{ var_accounts_maximum_age_login_defs }} {{ item }} + ansible.builtin.command: + cmd: chage -M {{ var_accounts_maximum_age_login_defs }} {{ item }} {{% endif %}} with_items: '{{ user_names.stdout_lines }}' when: user_names.stdout_lines | length > 0