-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.yml
More file actions
68 lines (60 loc) · 1.75 KB
/
bootstrap.yml
File metadata and controls
68 lines (60 loc) · 1.75 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
- name: Initial Bootstrap Playbook
hosts: all
gather_facts: yes
become: yes
vars:
bootstrap_user: "{{ ansible_user_id }}"
bootstrap_become_pass_update: true
bootstrap_ssh_key_setup: true
tasks:
- name: Ensure sudo is installed
ansible.builtin.package:
name: sudo
state: present
- name: Ensure user is in sudo group
ansible.builtin.user:
name: "{{ bootstrap_user }}"
groups: sudo
append: yes
when: ansible_os_family == "Debian"
- name: Configure passwordless sudo for user
ansible.builtin.lineinfile:
path: /etc/sudoers.d/{{ bootstrap_user }}
line: "{{ bootstrap_user }} ALL=(ALL) NOPASSWD:ALL"
create: yes
validate: 'visudo -cf %s'
mode: '0440'
when: bootstrap_become_pass_update
- name: Ensure .ssh directory exists
ansible.builtin.file:
path: "/home/{{ bootstrap_user }}/.ssh"
state: directory
owner: "{{ bootstrap_user }}"
group: "{{ bootstrap_user }}"
mode: '0700'
when: bootstrap_ssh_key_setup
- name: Install essential packages
ansible.builtin.package:
name:
- git
- curl
- wget
- ca-certificates
- gnupg
- lsb-release
- software-properties-common
- python3-pip
- python3-venv
state: present
- name: Update all packages
ansible.builtin.apt:
upgrade: dist
update_cache: yes
when: ansible_os_family == "Debian"
- name: Install Ansible collections
ansible.builtin.command: ansible-galaxy collection install -r requirements.yml
delegate_to: localhost
become: no
run_once: true
changed_when: false