diff options
author | Romain Gonçalves <me@rgoncalves.se> | 2024-02-08 13:32:37 +0100 |
---|---|---|
committer | Romain Gonçalves <me@rgoncalves.se> | 2024-02-08 13:33:36 +0100 |
commit | adfb09b9e19f7a31632eab01171693cb81ec75ef (patch) | |
tree | 7b05135581ff49e7a5655ab07af7bba2ada43585 /roles/sshd_keys | |
parent | 5c5b0fbf68dca224b7f92f5de0913fd684e7d3d9 (diff) | |
download | rules-adfb09b9e19f7a31632eab01171693cb81ec75ef.tar.gz |
refactor(roles): new variable naming standard
Diffstat (limited to 'roles/sshd_keys')
-rw-r--r-- | roles/sshd_keys/defaults/main.yml | 13 | ||||
-rw-r--r-- | roles/sshd_keys/meta/main.yml | 16 | ||||
-rw-r--r-- | roles/sshd_keys/tasks/main.yml | 23 |
3 files changed, 10 insertions, 42 deletions
diff --git a/roles/sshd_keys/defaults/main.yml b/roles/sshd_keys/defaults/main.yml index 1b97a4a..d0b5466 100644 --- a/roles/sshd_keys/defaults/main.yml +++ b/roles/sshd_keys/defaults/main.yml @@ -1,13 +1,4 @@ --- -sshd_keys_users: null -sshd_keys_dir: files/keys -sshd_keys_paths: "[ - {% if sshd_keys_users is none %} - '{{ sshd_keys_dir }}', - {% else %} - {% for user in sshd_keys_users %} - '{{ sshd_keys_dir }}/{{ user }}', - {% endfor %} - {% endif %} - ]" +sshd_keys__users: null +sshd_keys__dir: null diff --git a/roles/sshd_keys/meta/main.yml b/roles/sshd_keys/meta/main.yml index e790d71..ccf16eb 100644 --- a/roles/sshd_keys/meta/main.yml +++ b/roles/sshd_keys/meta/main.yml @@ -1,27 +1,17 @@ --- -dependencies: - - role: sshd - tags: dependency - argument_specs: main: - short_description: sshd_keys main entrypoint. + short_description: sshd__keys main entrypoint. options: - sshd_keys_users: + sshd_keys__users: type: list elements: str required: true description: Users to be synced - sshd_keys_dir: + sshd_keys__dir: type: path required: true description: Local directory with public keys - - sshd_keys_paths: - type: list - elements: path - required: true - description: Local directory with public keys diff --git a/roles/sshd_keys/tasks/main.yml b/roles/sshd_keys/tasks/main.yml index 5d45e34..168f64d 100644 --- a/roles/sshd_keys/tasks/main.yml +++ b/roles/sshd_keys/tasks/main.yml @@ -2,34 +2,21 @@ - name: get ssh keys for all users ansible.builtin.find: - paths: "{{ sshd_keys_paths }}" + paths: "{{ sshd__keys_paths }}" file_type: link recurse: true delegate_to: localhost run_once: true - register: sshd_keys_result_find + register: sshd__keys_result_find -- name: set sshd_keys_found_users variable +- name: set sshd__keys_found_users variable ansible.builtin.set_fact: - sshd_keys_found_users: "{{ sshd_keys_result_find.files + sshd__keys_found_users: "{{ sshd__keys_result_find.files | map(attribute='path') | map('dirname') | map('basename') | unique }}" -- name: create groups for users with ssh keys - ansible.builtin.group: - name: "{{ item }}" - state: present - loop: "{{ sshd_keys_found_users }}" - -- name: create users with ssh keys - ansible.builtin.user: - name: "{{ item }}" - group: "{{ item }}" - state: present - loop: "{{ sshd_keys_found_users }}" - - name: synchronize ssh keys ansible.posix.authorized_key: user: "{{ item.path | dirname | basename }}" @@ -37,5 +24,5 @@ key: "{{ lookup('file', item.path) }}" loop_control: label: "{{ item.path }}: {{ item.path | dirname | basename }}" - loop: "{{ sshd_keys_result_find.files }}" + loop: "{{ sshd__keys_result_find.files }}" failed_when: false |