81398e847e
- 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.
57 lines
1.4 KiB
YAML
57 lines
1.4 KiB
YAML
---
|
|
# - name: (sudoers.yml) include variables
|
|
# include_vars: "{{ item }}"
|
|
# with_first_found:
|
|
# - "sudoers-{{ inventory_hostname }}.yml"
|
|
# - "sudoers-{{ ansible_distribution_release }}.yml"
|
|
# - "sudoers-{{ ansible_distribution | lower }}.yml"
|
|
# - "sudoers-default.yml"
|
|
# tags:
|
|
# - sudoers-remove
|
|
# - sudoers-file-configuration
|
|
# - sudoers-global-configuration
|
|
|
|
- name: (sudoers.yml) Remove user entries in file /etc/sudoers
|
|
ansible.builtin.lineinfile:
|
|
dest: /etc/sudoers
|
|
state: absent
|
|
regexp: "^{{ item }}"
|
|
owner: root
|
|
group: root
|
|
mode: "0440"
|
|
validate: visudo -cf %s
|
|
with_items: "{{ sudoers_remove_user }}"
|
|
tags:
|
|
- sudoers-remove
|
|
|
|
- name: (sudoers.yml) update specific sudoers configuration files (/etc/sudoers.d/)
|
|
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"
|
|
tags:
|
|
- sudoers-file-configuration
|
|
|
|
#- name: (sudoers.yml) update global sudoers configuration file
|
|
# template:
|
|
# src: etc/sudoers.j2
|
|
# dest: /etc/sudoers
|
|
# owner: root
|
|
# group: root
|
|
# mode: 0440
|
|
# #validate: visudo -cf %s
|
|
# tags:
|
|
# - sudoers-global-configuration
|
|
|
|
- name: (sudoers.yml) Ensure all sudo_users are in sudo group
|
|
ansible.builtin.user:
|
|
name: "{{ item }}"
|
|
groups: sudo
|
|
append: true
|
|
with_items: "{{ sudo_users }}"
|
|
tags:
|
|
- sudo-users
|