-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateansibleuser.yml
73 lines (65 loc) · 1.98 KB
/
createansibleuser.yml
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
- name: Create Ansible User with rights
hosts: all
become: true
tasks:
- name: Create Ansible user
user:
name: ansible
comment: "User for Ansible Tower access"
shell: /bin/bash
system: yes
- name: Create devops file
file:
path: /etc/sudoers.d/devops
state: touch
mode: 0644
when:
- ansible_distribution == "RedHat"
- ansible_distribution_major_version > "5"
- name: Create content in sudo file
lineinfile:
path: /etc/sudoers.d/devops
line: 'ansible ALL=(ALL) NOPASSWD:ALL'
when:
- ansible_distribution == "RedHat"
- ansible_distribution_major_version > "5"
- name: Change devops file permission (RHEL6)
file:
path: /etc/sudoers.d/devops
mode: 0440
when:
- ansible_distribution == "RedHat"
- ansible_distribution_major_version == "6"
- name: Create content in sudo file (RHEL 5)
lineinfile:
path: /etc/sudoers
line: 'ansible ALL=(ALL) NOPASSWD:ALL'
when:
- ansible_distribution == "RedHat"
- ansible_distribution_major_version == "5"
- name: Create content in sudo file (RHEL6 and RHEL7)
lineinfile:
path: /etc/sudoers
line: '#includedir /etc/sudoers.d'
when:
- ansible_distribution == "RedHat"
- ansible_distribution_major_version >= "6"
- name: Create .ssh directory
file:
path: /home/ansible/.ssh
state: directory
owner: ansible
group: ansible
mode: 0700
- name: Create key file
file:
path: /home/ansible/.ssh/authorized_keys
state: touch
mode: 0600
owner: ansible
group: ansible
- name: Create content in sudo file
lineinfile:
path: /home/ansible/.ssh/authorized_keys
line: 'ssh-rsa AAAAB3NzaC1yc2EAAAddddddddddddfffffffffffffffffffffffffffffffffaaaaaaaaaaaaa'