Skip to content

Instantly share code, notes, and snippets.

@bitsandbooks
Last active July 1, 2018 21:06
Show Gist options
  • Save bitsandbooks/2e2bafdcd799400f547c042c9cf4f917 to your computer and use it in GitHub Desktop.
Save bitsandbooks/2e2bafdcd799400f547c042c9cf4f917 to your computer and use it in GitHub Desktop.
---
- name: ensure presence of user
user:
name: "{{ item.username }}"
uid: "{{ item.username }}"
password: "{{ item.passwd }}"
comment: "{{ item.comment }}"
shell: "{{ item.shell }}"
group: "{{ item.group }}"
groups: "{{ item.groups }}""
- name: ensure presence of user's ssh key
authorized_key:
user: "{{ item.username }}"
state: present
key: "{{ item.public_key }}"
- name: os-specific tasks for user
include: 'os-{{ ansible_distribution }}.yml'
humanuser1:
username: humanuser1
comment: "Human User 1"
passwd: "shadow-password"
public_key: "public-key-here"
uid: 1501
group: humans
groups:
- sudo
- mygroup1
shell: "/bin/bash"
apt_packages:
- nodejs
- mongodb
appuser1:
username: appuser1
comment: "App User 1"
passwd: "shadow-password"
public_key: "public-key-here"
uid: 1601
group: apps
groups:
- docker
- mysql
shell: "/usr/sbin/nologin"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment