-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmeu_usuario.yaml
47 lines (37 loc) · 979 Bytes
/
meu_usuario.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
- hosts: all
user: root
connection: ssh
#become_user: root
#become: yes
#become_method: su
#connection: paramiko
gather_facts: true
vars:
pwd: "{{ lookup('password', '/dev/null length=17 chars=ascii_letters') }}"
chave_dir_ori: ../chaves
chave_arq_ori: charles.a.pub
tasks:
- set_fact:
my_pass: "{{ pwd }}"
- name: Adcionar Usuarios charles
user:
name: charles.a
password: "{{ my_pass }}"
state: present
shell: /bin/bash
update_password: on_create
system: no
createhome: yes
home: /home/charles.a
- name: Set up authorized_keys for the deploy user
authorized_key:
user=charles.a
key="{{ lookup('file', '{{ chave_dir_ori }}/{{ chave_arq_ori }}') }}"
- name: Add user to sudoers file
lineinfile:
backup: yes
path: /etc/sudoers
regexp: '^charles.a'
line: 'charles.a ALL=(ALL) NOPASSWD: ALL'
validate: 'visudo -cf %s'