From a330660cea8e6fd9b7096dd4852c784bd9684760 Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Sat, 13 Apr 2024 21:35:14 +0200 Subject: [PATCH] Refactor and require user to manage 'become' --- slococo/playground/roles/local_accounts/README.md | 2 +- slococo/playground/roles/local_accounts/defaults/main.yml | 2 +- slococo/playground/roles/local_accounts/handlers/main.yml | 2 +- .../playground/roles/local_accounts/meta/argument_specs.yml | 4 ++-- slococo/playground/roles/local_accounts/meta/main.yml | 2 +- slococo/playground/roles/local_accounts/tasks/main.yml | 3 +-- slococo/playground/roles/local_accounts/tests/inventory | 1 - slococo/playground/roles/local_accounts/tests/test.yml | 1 + 8 files changed, 8 insertions(+), 9 deletions(-) diff --git a/slococo/playground/roles/local_accounts/README.md b/slococo/playground/roles/local_accounts/README.md index 8c30c32..7dd8776 100644 --- a/slococo/playground/roles/local_accounts/README.md +++ b/slococo/playground/roles/local_accounts/README.md @@ -20,7 +20,7 @@ Example Playbook ```yaml - hosts: servers vars: - local_users: + accounts: - name: test_user1 shell: /bin/bash userid: 1001 diff --git a/slococo/playground/roles/local_accounts/defaults/main.yml b/slococo/playground/roles/local_accounts/defaults/main.yml index 26d8306..09bff2d 100644 --- a/slococo/playground/roles/local_accounts/defaults/main.yml +++ b/slococo/playground/roles/local_accounts/defaults/main.yml @@ -1,2 +1,2 @@ --- -local_users: [] \ No newline at end of file +accounts: [] diff --git a/slococo/playground/roles/local_accounts/handlers/main.yml b/slococo/playground/roles/local_accounts/handlers/main.yml index 73b314f..ed97d53 100644 --- a/slococo/playground/roles/local_accounts/handlers/main.yml +++ b/slococo/playground/roles/local_accounts/handlers/main.yml @@ -1 +1 @@ ---- \ No newline at end of file +--- diff --git a/slococo/playground/roles/local_accounts/meta/argument_specs.yml b/slococo/playground/roles/local_accounts/meta/argument_specs.yml index 4f03604..a201ca2 100644 --- a/slococo/playground/roles/local_accounts/meta/argument_specs.yml +++ b/slococo/playground/roles/local_accounts/meta/argument_specs.yml @@ -3,7 +3,7 @@ argument_specs: main: short_description: Ansible Role to create local users options: - local_users: + accounts: type: list required: true elements: dict @@ -34,4 +34,4 @@ argument_specs: type: list required: false default: "" - description: The primary group for the local user. \ No newline at end of file + description: The primary group for the local user. diff --git a/slococo/playground/roles/local_accounts/meta/main.yml b/slococo/playground/roles/local_accounts/meta/main.yml index 59c9a91..4780e85 100644 --- a/slococo/playground/roles/local_accounts/meta/main.yml +++ b/slococo/playground/roles/local_accounts/meta/main.yml @@ -4,6 +4,6 @@ galaxy_info: company: cloudWerkstatt license: MIT min_ansible_version: 2.12.0 - galaxy_tags: ['users'] + galaxy_tags: ['users', 'creation'] dependencies: [] diff --git a/slococo/playground/roles/local_accounts/tasks/main.yml b/slococo/playground/roles/local_accounts/tasks/main.yml index f6d7f7e..bb89fed 100644 --- a/slococo/playground/roles/local_accounts/tasks/main.yml +++ b/slococo/playground/roles/local_accounts/tasks/main.yml @@ -8,5 +8,4 @@ home: "{{ item.home | default(omit) }}" groups: "{{ item.groups | default(omit) }}" generate_ssh_key: yes - loop: "{{ local_users }}" - become: true + loop: "{{ accounts }}" diff --git a/slococo/playground/roles/local_accounts/tests/inventory b/slococo/playground/roles/local_accounts/tests/inventory index 878877b..2fbb50c 100644 --- a/slococo/playground/roles/local_accounts/tests/inventory +++ b/slococo/playground/roles/local_accounts/tests/inventory @@ -1,2 +1 @@ localhost - diff --git a/slococo/playground/roles/local_accounts/tests/test.yml b/slococo/playground/roles/local_accounts/tests/test.yml index 3ad87db..22bbbe5 100644 --- a/slococo/playground/roles/local_accounts/tests/test.yml +++ b/slococo/playground/roles/local_accounts/tests/test.yml @@ -3,6 +3,7 @@ hosts: localhost connection: local gather_facts: no + become: true vars: local_users: