computer-playbook/roles/user-administrator/tasks/main.yml

52 lines
1.5 KiB
YAML
Raw Normal View History

- name: create administrator
user:
name: administrator
update_password: on_create
password: "{{ user_administrator_initial_password | password_hash('sha512') }}"
create_home: yes
generate_ssh_key: yes
ssh_key_type: rsa
ssh_key_bits: 8192
when: run_once_user_administrator is not defined
- name: "create {{path_administrator_scripts}}"
file:
path: "{{path_administrator_home}}scripts"
state: directory
owner: administrator
group: administrator
mode: 0700
when: run_once_user_administrator is not defined
2023-04-26 14:38:02 +02:00
- name: create {{path_administrator_home}}.ssh/authorized_keys
copy:
2023-04-26 14:38:02 +02:00
src: "{{ inventory_dir }}/files/{{ inventory_hostname }}{{path_administrator_home}}.ssh/authorized_keys"
dest: "{{path_administrator_home}}.ssh/authorized_keys"
owner: administrator
group: administrator
mode: '0644'
when: run_once_user_administrator is not defined
- name: grant administrator sudo rights with password
copy:
src: "administrator"
dest: /etc/sudoers.d/administrator
mode: '0644'
owner: root
group: root
2021-01-10 19:37:44 +01:00
notify: sshd restart
when: run_once_user_administrator is not defined
2021-10-18 18:46:58 +02:00
2023-04-26 14:38:02 +02:00
- name: "create {{path_administrator_home}}volumes/"
2021-10-18 18:46:58 +02:00
file:
2023-04-26 14:38:02 +02:00
path: "{{path_administrator_home}}volumes"
2021-10-18 18:46:58 +02:00
state: directory
owner: administrator
group: administrator
mode: 0700
when: run_once_user_administrator is not defined
- name: run the user_administrator tasks once
set_fact:
run_once_user_administrator: true
when: run_once_user_administrator is not defined