-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap-varsfiles.yml
42 lines (36 loc) · 1.09 KB
/
bootstrap-varsfiles.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
---
- name: bootstrapping and new user
hosts: raiders
gather_facts: no
# vars_files expects a list of 1 or more files
vars_files:
- vars/newusers1.yml
- vars/newusers2.yml
tasks:
# update the apt catalog
- name: "update apt with latest repo info"
ansible.builtin.raw: "apt update -y"
become: yes
# install Python3 and pip3 with ansible
- name: "Bootstrap python install"
ansible.builtin.raw: "apt install -y python3-pip"
become: yes
# create a new group
- name: Create the new group sandbox
ansible.builtin.group:
name: sandbox
state: present
become: yes
# create new user on target system
- name: Add new users to group 'sandbox'
ansible.builtin.user:
name: "{{ item }}"
comment: throwaway user account for testing
state: present
shell: /bin/bash # Defaults to /bin/bash
system: no # Defaults to no
createhome: yes # Defaults to yes
group: sandbox
become: yes
loop: "{{ users1 + users2 }}"
## notice how we combine two separate lists with the above technique