Created
March 7, 2016 14:47
-
-
Save tuxnker/acda26e81c3feaca5a5c to your computer and use it in GitHub Desktop.
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
cat users-v2.yaml | |
- name: Add users from users dictionary | |
#action: user name={{ item.key }} password={{ item.value.password }} shell={{ item.value.shell }} state={{ item.value.state }} remove=yes update_password=on_create groups="{{ item.key }},{{ item.value.group }}" append=no | |
action: user name={{ item.key }} password={{ item.value.password }} shell={{ item.value.shell }} state={{ item.value.state }} remove=yes update_password=on_create groups="{{ item.value.group }}" append=yes | |
with_dict: users | |
ignore_errors: yes | |
- name: Add keys from users dictionary | |
action: authorized_key user={{ item.key }} key="{{ item.value.ssh_key }}" exclusive=yes | |
with_dict: users | |
########### | |
cat newuser-user.yaml | |
- hosts: all | |
# remote_user: ec2-user | |
sudo: yes | |
sudo_user: root | |
vars_files: | |
- newuser-users | |
tasks: | |
- copy: src=conf/custom-sudoers dest=/etc/sudoers.d/custom_sudoers owner=root group=root mode=644 | |
- group: name=default_group state=present | |
- include: users-v2.yaml | |
########## | |
cat newuser-users | |
users: | |
user1: | |
password: MD5HASH | |
shell: /bin/bash | |
ssh_key: "{{ lookup('file', 'user1.pub') }}" | |
state: present | |
group: default_group | |
user2: | |
password: MD5HASH | |
shell: /bin/bash | |
ssh_key: "{{ lookup('file', 'user2.pub') }}" | |
state: present | |
group: default_group | |
user3: | |
password: MD5HASH | |
shell: /bin/bash | |
ssh_key: "{{ lookup('file', 'user3.pub') }}" | |
state: present | |
group: default_group | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment