feat(role): add ansible-lint, fix ansible-lint issues
All checks were successful
checks-test / Lint (push) Successful in 53s
checks-test / molecule (rockylinux9) (push) Successful in 2m59s
checks-test / molecule (debian11) (push) Successful in 3m10s
checks-test / molecule (ubuntu2204) (push) Successful in 3m24s

This commit is contained in:
2024-01-14 19:21:16 +02:00
parent e776a43962
commit f3b6072eb6
6 changed files with 18 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
---
- name: "Create group `{{ group }}`"
become: true
group:
ansible.builtin.group:
name: "{{ group }}"
gid: "{{ users_groups[group].get('gid', None) }}"

View File

@@ -1,10 +1,12 @@
---
- include_tasks: group.yml
- name: Create groups
ansible.builtin.include_tasks: group.yml
with_items: "{{ users_groups.keys() }}"
loop_control:
loop_var: group
- include_tasks: user.yml
- name: Create users
ansible.builtin.include_tasks: user.yml
when: ansible_default_ipv4.address in users[username]['passwords'] or users[username]['passwords'].get('default')
with_items: "{{ users.keys() }}"
loop_control:

View File

@@ -1,5 +1,5 @@
---
- name: "create user `{{ username }}`"
- name: "Create user `{{ username }}`"
ansible.builtin.user:
name: "{{ username }}"
append: true
@@ -7,22 +7,22 @@
shell: "{{ users[username].get('shell', '/bin/bash') }}"
uid: "{{ users[username].get('uid', None) }}"
- name: "set specific password for user `{{ username }}`"
- name: "Set specific password for user `{{ username }}`"
ansible.builtin.user:
name: "{{ username }}"
password: "{{ users[username]['passwords'].get(ansible_default_ipv4.address) }}"
when: "ansible_default_ipv4.address in users[username]['passwords'] and
users[username]['passwords'].get(ansible_default_ipv4.address) != 'default'"
- name: "set default password for user `{{ username }}`"
- name: "Set default password for user `{{ username }}`"
ansible.builtin.user:
name: "{{ username }}"
password: "{{ users[username]['passwords'].get('default') }}"
when: "ansible_default_ipv4.address not in users[username]['passwords'] or
users[username]['passwords'].get(ansible_default_ipv4.address) == 'default'"
- name: "setup ssh key for user `{{ username }}`"
ansible.builtin.authorized_key:
- name: "Setup ssh key for user `{{ username }}`"
ansible.posix.authorized_key:
user: "{{ username }}"
state: "{{ users[username]['authorized_keys'][item].get('state', 'present') }}"
key: "{{ users[username]['authorized_keys'][item].get('key') }}"