Refactor Ansible tasks to use fully qualified module names and improve code consistency
- Updated all tasks to use fully qualified module names (e.g., ansible.builtin.shell, ansible.builtin.copy) for clarity and to avoid ambiguity. - Replaced deprecated 'yum' module with 'dnf' for package management on RedHat-based systems. - Improved formatting and consistency in task definitions, including the use of double quotes for strings and consistent indentation. - Removed unnecessary comments and whitespace to enhance readability. - Ensured that conditions and loops are consistently formatted across all tasks.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
---
|
||||
|
||||
#- name: (sudoers.yml) include variables
|
||||
# - name: (sudoers.yml) include variables
|
||||
# include_vars: "{{ item }}"
|
||||
# with_first_found:
|
||||
# - "sudoers-{{ inventory_hostname }}.yml"
|
||||
@@ -11,28 +10,28 @@
|
||||
# - sudoers-remove
|
||||
# - sudoers-file-configuration
|
||||
# - sudoers-global-configuration
|
||||
|
||||
|
||||
- name: (sudoers.yml) Remove user entries in file /etc/sudoers
|
||||
lineinfile:
|
||||
ansible.builtin.lineinfile:
|
||||
dest: /etc/sudoers
|
||||
state: absent
|
||||
regexp: '^{{ item }}'
|
||||
regexp: "^{{ item }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0440
|
||||
mode: "0440"
|
||||
validate: visudo -cf %s
|
||||
with_items: '{{ sudoers_remove_user }}'
|
||||
with_items: "{{ sudoers_remove_user }}"
|
||||
tags:
|
||||
- sudoers-remove
|
||||
|
||||
- name: (sudoers.yml) update specific sudoers configuration files (/etc/sudoers.d/)
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: etc/sudoers.d/50-user.j2
|
||||
dest: /etc/sudoers.d/50-user
|
||||
#validate: visudo -cf %s
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0440
|
||||
mode: "0440"
|
||||
tags:
|
||||
- sudoers-file-configuration
|
||||
|
||||
@@ -48,10 +47,10 @@
|
||||
# - sudoers-global-configuration
|
||||
|
||||
- name: (sudoers.yml) Ensure all sudo_users are in sudo group
|
||||
user:
|
||||
ansible.builtin.user:
|
||||
name: "{{ item }}"
|
||||
groups: sudo
|
||||
append: yes
|
||||
append: true
|
||||
with_items: "{{ sudo_users }}"
|
||||
tags:
|
||||
- sudo-users
|
||||
|
||||
Reference in New Issue
Block a user