18 lines
937 B
YAML
18 lines
937 B
YAML
---
|
|
- name: Prepare and configure user "deploy"
|
|
hosts: all
|
|
become: yes
|
|
tasks:
|
|
- name: Add deploy user
|
|
user: name=deploy comment="Deploy User" groups=adm,sudo,www-data shell=/bin/bash
|
|
- name: Adding authorized key to deploy user
|
|
authorized_key: user=deploy key="{{item}}"
|
|
with_file:
|
|
- ../files/authorized_keys.deploy.pub
|
|
- name: Ensure /etc/sudoers.d is scanned by sudo
|
|
# A mistake use pkexec visudo
|
|
action: lineinfile dest=/etc/sudoers regexp="#includedir\s+/etc/sudoers.d" line="#includedir /etc/sudoers.d" validate="visudo -cf %s"
|
|
- name: Add deploy user to the sudoers
|
|
action: 'lineinfile dest=/etc/sudoers.d/deploy state=present create=yes regexp="deploy .*" line="deploy ALL=(ALL) NOPASSWD: ALL" validate="visudo -cf %s"'
|
|
- name: Ensure /etc/sudoers.d/deploy file has correct permissions
|
|
action: file path=/etc/sudoers.d/deploy mode=0440 state=file owner=root group=root |