fix(runtime): migrate roles to nested system fields
This commit is contained in:
@@ -5,11 +5,11 @@
|
||||
{{ "sudo" if is_debian | bool else "wheel" }}
|
||||
configuration_useradd_cmd: >-
|
||||
{{ chroot_command }} /usr/sbin/useradd --create-home --user-group
|
||||
--groups {{ configuration_user_group }} {{ user_name }}
|
||||
--password {{ user_password | password_hash('sha512') }} --shell /bin/bash
|
||||
--groups {{ configuration_user_group }} {{ system_cfg.user.name }}
|
||||
--password {{ system_cfg.user.password | password_hash('sha512') }} --shell /bin/bash
|
||||
configuration_root_cmd: >-
|
||||
{{ chroot_command }} /usr/sbin/usermod --password
|
||||
'{{ root_password | password_hash('sha512') }}' root --shell /bin/bash
|
||||
'{{ system_cfg.root.password | password_hash('sha512') }}' root --shell /bin/bash
|
||||
ansible.builtin.command: "{{ item }}"
|
||||
loop:
|
||||
- "{{ configuration_useradd_cmd }}"
|
||||
@@ -18,19 +18,19 @@
|
||||
changed_when: configuration_user_result.rc == 0
|
||||
|
||||
- name: Ensure .ssh directory exists
|
||||
when: user_public_key | length > 0
|
||||
when: system_cfg.user.public_key | length > 0
|
||||
ansible.builtin.file:
|
||||
path: /mnt/home/{{ user_name }}/.ssh
|
||||
path: /mnt/home/{{ system_cfg.user.name }}/.ssh
|
||||
state: directory
|
||||
owner: 1000
|
||||
group: 1000
|
||||
mode: "0700"
|
||||
|
||||
- name: Add SSH public key to authorized_keys
|
||||
when: user_public_key | length > 0
|
||||
when: system_cfg.user.public_key | length > 0
|
||||
ansible.builtin.lineinfile:
|
||||
path: /mnt/home/{{ user_name }}/.ssh/authorized_keys
|
||||
line: "{{ user_public_key }}"
|
||||
path: /mnt/home/{{ system_cfg.user.name }}/.ssh/authorized_keys
|
||||
line: "{{ system_cfg.user.public_key }}"
|
||||
owner: 1000
|
||||
group: 1000
|
||||
mode: "0600"
|
||||
|
||||
Reference in New Issue
Block a user