1 ---
2 - hosts: all
3 vars_files:
4 - /etc/ansible/group_vars/[some-group-name-goes-here]/users.yaml
5 tasks:
6 - name: Create user.
7 user: home=/home/{{ item }} name={{ item }} shell=/bin/bash state=present
8 with_items: users
9 - name: copy per-user ssh key (authorized_keys2) to the destination server
10 action: copy src=/usr/share/ansible/files/ssh/{{ item }}/authorized_keys2 dest=/home/{{ item }}/.ssh/authorized_keys2 mode=755
11 with_items: users
$ cat /etc/ansible/group_vars/[some-group-name-goes-here]/users.yaml
users:
- user1
- user2
- user3
group_name:
- users
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
$ cat /etc/ansible/users.yaml
all_users:
- user1
- user2
- user3
- user4
- user5
- user6
Ops:
- user1
- user2
- user3
- user4
databaseTeam:
- user5
- user6
---
- hosts: all
vars_files:
- /etc/ansible/users.yaml
tasks:
- name: Create user.
user: home=/home/{{ item }} name={{ item }} shell=/bin/bash state=present
with_items: Ops
- name: copy per-user ssh key (authorized_keys2) to the destination server
action: copy src=/usr/share/ansible/files/ssh/{{ item }}/authorized_keys2 dest=/home/{{ item }}/.ssh/authorized_keys2 mode=755
with_items: Ops
---
- hosts: all
vars_files:
- /etc/ansible/users.yaml
tasks:
- name: Create user.
user: home=/home/{{ item }} name={{ item }} shell=/bin/bash state=present
with_items: accounts_to_add
- name: copy per-user ssh key (authorized_keys2) to the destination server
action: copy src=/usr/share/ansible/files/ssh/{{ item }}/authorized_keys2 dest=/home/{{ item }}/.ssh/authorized_keys2 mode=755
with_items: accounts_to_add
$ cat /etc/ansible/users.yaml
all_users:- user1- user2- user3- user4
- user5
- user6
Ops:- user1- user2- user3- user4
databaseTeam:
- user5
- user6
1 ---
2 - hosts: all
3 vars_files:
4 - /etc/ansible/users.yaml
5 tasks:
6 - name: Create user.
7 user: home=/home/{{ item }} name={{ item }} shell=/bin/bash state=present
8 with_items: $accounts_to_add
9 - name: copy per-user ssh key (authorized_keys2) to the destination server
10 action: copy src=/usr/share/ansible/files/ssh/{{ item }}/authorized_keys2 dest=/home/{{ item }}/.ssh/authorized_keys2 mode=755
11 with_items: $accounts_to_add
1 ---
2 #NTP
3 - include: ntp.yaml
4
5 #USERS
6 - include: add_users.yaml accounts_to_add=databaseTeam
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Will take another look.