Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
cchurch committed Feb 9, 2015
0 parents commit e18b414
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 0 deletions.
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Admin Users
===========

Manage admin users, authorized keys and sudo access.

Requirements
------------

None.

Role Variables
--------------

Define the following variables in your inventory or playbook to create, update
and remove admin users:

admin_users:
- username: joe
fullname: "Joe User"
pubkey: "ssh-rsa ..."
- username: jim
fullname: "Jim User"
pubkey: "ssh-rsa ..."

admin_users_sudo_nopasswd: yes

admin_users_to_remove:
- bob
- fred

Dependencies
------------

None.

Example Playbook
----------------

The following playbook updates admin users on dev and prod servers with
different options:

- hosts: dev-servers
roles:
- role: cchurch.admin-users
admin_users: dev_admin_users
- hosts: prod-servers
roles:
- role: cchurch.admin-users
admin_users: prod_admin_users
admin_users_sudo_nopasswd: no

License
-------

BSD

Author Information
------------------

Chris Church
[email protected]
12 changes: 12 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---

admin_users: []
# - username: joe
# fullname: "Joe User"
# pubkey: "ssh-rsa ..."

admin_users_sudo_nopasswd: yes

admin_users_to_remove: []
# - bob
# - fred
21 changes: 21 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---

galaxy_info:
author: Chris Church
description:
company: 'Nine More Minutes, Inc.'
license: BSD
min_ansible_version: 1.7
platforms:
- name: EL
versions: all
- name: Fedora
versions: all
- name: Ubuntu
versions: all
- name: Debian
versions: all
categories:
- system

dependencies: []
39 changes: 39 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---

- name: include os specific variables
include_vars: '{{ ansible_os_family }}.yml'

- name: create admin users
user:
name: '{{item.username}}'
comment: '{{item.fullname}}'
groups: '{{admin_users_sudo_group}}'
append: yes
with_items: admin_users

- name: remove admin users
user:
name: '{{item}}'
state: absent
with_items: admin_users_to_remove

- name: update authorized keys for admin users
authorized_key:
user: '{{item.username}}'
key: '{{item.pubkey}}'
with_items: admin_users

- name: 'enable sudo with no password for {{admin_users_sudo_group}} group'
template:
src: sudo_nopasswd
dest: /etc/sudoers.d/sudo_nopasswd
mode: 0440
owner: root
group: root
when: admin_users_sudo_nopasswd

- name: disable sudo with no password
file:
path: /etc/sudoers.d/sudo_nopasswd
state: absent
when: not admin_users_sudo_password
2 changes: 2 additions & 0 deletions templates/sudo_nopasswd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Enable password-less sudo for users in {{admin_users_sudo_group}} group.
%{{admin_users_sudo_group}} ALL=(ALL) NOPASSWD: ALL
3 changes: 3 additions & 0 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

admin_users_sudo_group: sudo
3 changes: 3 additions & 0 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

admin_users_sudo_group: wheel

0 comments on commit e18b414

Please sign in to comment.