mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Optimized performance by moving multiple similar when includes to own tasks file
This commit is contained in:
48
roles/user-administrator/tasks/01_core.yml
Normal file
48
roles/user-administrator/tasks/01_core.yml
Normal file
@@ -0,0 +1,48 @@
|
||||
- name: create administrator
|
||||
user:
|
||||
name: administrator
|
||||
update_password: on_create
|
||||
password: "{{ users.administrator.password | password_hash('sha512') }}"
|
||||
create_home: yes
|
||||
generate_ssh_key: yes
|
||||
ssh_key_type: rsa
|
||||
ssh_key_bits: 8192
|
||||
|
||||
- name: "set correct rights for {{path_administrator_home}}"
|
||||
file:
|
||||
path: "{{path_administrator_home}}"
|
||||
state: directory
|
||||
owner: administrator
|
||||
group: administrator
|
||||
mode: 0700
|
||||
|
||||
- name: "create {{path_administrator_scripts}}"
|
||||
file:
|
||||
path: "{{path_administrator_home}}scripts"
|
||||
state: directory
|
||||
owner: administrator
|
||||
group: administrator
|
||||
mode: 0700
|
||||
|
||||
- name: create {{path_administrator_home}}.ssh/authorized_keys
|
||||
copy:
|
||||
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'
|
||||
|
||||
- name: grant administrator sudo rights with password
|
||||
copy:
|
||||
src: "administrator"
|
||||
dest: /etc/sudoers.d/administrator
|
||||
mode: '0644'
|
||||
owner: root
|
||||
group: root
|
||||
notify: sshd restart
|
||||
|
||||
- name: "embed user routines for {{ role_path | basename }}"
|
||||
include_role:
|
||||
name: user
|
||||
vars:
|
||||
user_name: "administrator"
|
@@ -1,59 +1,4 @@
|
||||
- name: create administrator
|
||||
user:
|
||||
name: administrator
|
||||
update_password: on_create
|
||||
password: "{{ users.administrator.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: "set correct rights for {{path_administrator_home}}"
|
||||
file:
|
||||
path: "{{path_administrator_home}}"
|
||||
state: directory
|
||||
owner: administrator
|
||||
group: administrator
|
||||
mode: 0700
|
||||
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
|
||||
|
||||
- name: create {{path_administrator_home}}.ssh/authorized_keys
|
||||
copy:
|
||||
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
|
||||
notify: sshd restart
|
||||
when: run_once_user_administrator is not defined
|
||||
|
||||
- name: "embed user routines for {{ role_path | basename }}"
|
||||
include_role:
|
||||
name: user
|
||||
vars:
|
||||
user_name: "administrator"
|
||||
when: run_once_user_administrator is not defined
|
||||
|
||||
- name: run the user_administrator tasks once
|
||||
set_fact:
|
||||
run_once_user_administrator: true
|
||||
- block:
|
||||
- include_tasks: 01_core.yml
|
||||
- include_tasks: utils/run_once.yml
|
||||
when: run_once_user_administrator is not defined
|
Reference in New Issue
Block a user