Gestione utenti con sudoers.d.

This commit is contained in:
Emiliano Vavassori 2015-04-20 03:22:20 +02:00
parent 08efa36d0b
commit 214fdaab70
2 changed files with 4 additions and 14 deletions

View File

@ -3,21 +3,8 @@
- name: Creazione account di gestione Ansible
user: name=amgmt comment="Ansible Management User" group=wheel state=present password=$6$rounds=100000$XvHuMoXtpCksx379$nhlfUn38.oBB7JrDrtwfUisw8T0Bg5InzFq1fw31mcEmGZ2AYFkFK2zC2g04lSfw.kpdSgqH3Dl5q9r1fY6.k.
- name: Creo copia di backup di sudoers
shell: test -f {{ item }} || cp -fv /etc/sudoers {{ item }}
with_items:
- /etc/sudoers.bak
- /etc/sudoers.tmp
register: copylog
changed_when: "'/etc/sudoers' in copylog.stdout"
- name: Concessione diritti all'utente di gestione Ansible
lineinfile: dest=/etc/sudoers.tmp regexp="^amgmt.*NOPASSWD" line="amgmt ALL=(ALL:ALL) NOPASSWD:ALL" state=present
register: sudotmp
- name: Applicazione diritti utente Ansible
shell: visudo -q -c -f /etc/sudoers.tmp && cp -f /etc/sudoers.tmp /etc/sudoers
when: sudotmp|changed
template: src=sudoers.d dest=/etc/sudoers.d/amgmt mode="u=r,g=r" validate="visudo -cf %s"
- name: Installazione chiave privata PC locale
authorized_key: user=amgmt key="{{ lookup('file', admin_sshkey) }}" state=present

View File

@ -0,0 +1,3 @@
# {{ ansible_managed }}
# Autorizzazione di gestione per l'utente di ansible
amgmt ALL=(ALL:ALL) NOPASSWD:ALL