-
-
Save mrcrilly/277beff5a3743e10dbad to your computer and use it in GitHub Desktop.
This file contains hidden or 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
--- | |
- hosts: all | |
gather_facts: false | |
sudo: true | |
vars: | |
users: | |
user1: | |
name: Full Name | |
group: "group1" | |
user2: | |
name: Full Name | |
group: "group2" | |
user3: | |
name: Full Name | |
group: "group3" | |
tasks: | |
- name: Add all groups | |
group: | |
name: "{{item.value.group}}" | |
state: "present" | |
with_dict: users | |
- name: Add all users | |
user: | |
name: "{{ item.key }}" | |
group: "{{ item.value.group }}" | |
comment: "{{ item.value.name }}" | |
shell: "/bin/bash" | |
with_dict: users | |
register: addedusers | |
- name: Update the password if the user was created | |
user: | |
name: "{{item.name}}" | |
password: "superpassword!" | |
with_items: addedusers.results | |
when: item.changed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment