-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-as-root.yml
More file actions
executable file
·18 lines (15 loc) · 981 Bytes
/
Copy pathrun-as-root.yml
File metadata and controls
executable file
·18 lines (15 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
---
- name: Enable user Ansible on system
hosts: devserver
user: root
tasks:
- user: name=ansible shell=/bin/bash comment="I&O Ansible Service account" password=$6$rounds=656000$pEbr4HWdkilFYnQe$TDrF4eW.8ysERYbQ7YKyCIFSEYoqNJMv83Um/d27HGoCLKevXLalTGxx7u3EEw1HmtszqGaRFy8uN8m5Coe2n0
- shell: groupadd allowedgrp
- shell: groupadd symmetry
- user: name=ansible groups=allowedgrp append=yes
# - name: placing ssh public key
# The id_rsa.pub file has to be generated 1st using ssh-keygen command, the command below will generate the authorised keys
#authorized_key: user=ansible key="{{ lookup('file', '/home/ansible/.ssh/id_rsa.pub') }}"
- command: cp -f /etc/sudoers /etc/sudoers.tmp
- lineinfile: "dest=/etc/sudoers.tmp state=present regexp='^root' insertafter='^root' line='ansible ALL=(ALL) NOPASSWD: ALL'"
- shell: visudo -q -c -f /etc/sudoers.tmp && cp -f /etc/sudoers.tmp /etc/sudoers