36 lines
865 B
YAML
36 lines
865 B
YAML
|
---
|
||
|
# create user and group
|
||
|
|
||
|
- name: "Ensure group {{ group_name }} exists"
|
||
|
become: yes
|
||
|
group:
|
||
|
name: "{{ group_name }}"
|
||
|
|
||
|
- name: "create {{ user_name }} user and {{ group_name }} group"
|
||
|
become: yes
|
||
|
user:
|
||
|
name: "{{ user_name }}"
|
||
|
comment: "Login user generate by ansible"
|
||
|
groups:
|
||
|
- debian
|
||
|
- "{{ group_name }}"
|
||
|
|
||
|
- name: "create directory .ssh for public key"
|
||
|
become: yes
|
||
|
file:
|
||
|
path: "/home/{{ user_name }}/.ssh"
|
||
|
owner: "{{ user_name }}"
|
||
|
group: "{{ group_name }}"
|
||
|
state: directory
|
||
|
mode: '0755'
|
||
|
when: ssh_public_key is defined and ssh_public_key != ""
|
||
|
|
||
|
- name: "setup ssh key"
|
||
|
become: yes
|
||
|
copy:
|
||
|
content: "{{ ssh_public_key }}"
|
||
|
dest: "/home/{{ user_name }}/.ssh/authorized_keys"
|
||
|
owner: "{{ user_name }}"
|
||
|
group: "{{ group_name }}"
|
||
|
when: ssh_public_key is defined and ssh_public_key != ""
|