-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Create ansible user for use by pull mode
- Loading branch information
1 parent
b4dc0bf
commit 1e0a48e
Showing
3 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
- hosts: all | ||
tasks: | ||
- group_by: key=user_{{ ansible_user_id }} | ||
changed_when: False | ||
|
||
# Invoked as root user | ||
- hosts: user_root | ||
gather_facts: no | ||
sudo: no | ||
roles: | ||
- install_ansible_pull | ||
|
||
# Invoked as non-root user, requires sudo | ||
- hosts: "!user_root" | ||
gather_facts: no | ||
sudo: yes | ||
roles: | ||
- install_ansible_pull |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
|
||
# Install (or maintain) ansible pull mode | ||
|
||
- name: Create ansible user | ||
user: state="present" name="ansible" system="yes" createhome="yes" generate_ssh_key="yes" comment="Ansible Configuration Management" | ||
|
||
- name: Add warning comment to ansible sudoers file | ||
lineinfile: state="present" dest="/etc/sudoers.d/ansible" create="yes" insertbefore="BOF" regexp="^#" line="## Automatically Managed by Ansible, Manual Changes Will Be Lost!" | ||
|
||
- name: Disable requiretty restriction on ansible user | ||
# NB: Full line in quotes due to : char, see ansible YAML disclaimer | ||
lineinfile: 'state="present" dest="/etc/sudoers.d/ansible" create="yes" regexp="^Defaults" line="Defaults: ansible !requiretty"' | ||
|
||
- name: Allow ansible user full sudo privs | ||
# NB: Full line in quotes due to : char, see ansible YAML disclaimer | ||
lineinfile: 'state="present" dest="/etc/sudoers.d/ansible" create="yes" regexp="^ansible" line="ansible ALL=(ALL) NOPASSWD: ALL"' |