-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplaybook.yaml
138 lines (127 loc) · 4.47 KB
/
playbook.yaml
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
- name: Fabricant
hosts: localhost
vars_files:
- fabricant_users.yaml
tasks:
# Set up bw
- name: Install nvm
ansible.builtin.shell: >
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
args:
creates: "{{ ansible_env.HOME }}/.nvm/nvm.sh"
- name: Install npm
ansible.builtin.shell: "source {{ ansible_env.HOME }}/.nvm/nvm.sh && nvm install v22.9.0"
args:
executable: /bin/bash
creates: "{{ ansible_env.HOME }}/.nvm/versions/node/v22.9.0/bin/npm"
- name: Install BitWarden CLI
ansible.builtin.command:
cmd: >
bash -c "source $HOME/.nvm/nvm.sh && nvm exec v22.9.0 && npm install -g @bitwarden/cli"
creates: "{{ ansible_env.HOME }}/.nvm/versions/node/v22.9.0/bin/bw"
- name: Bootstrap BW Creds
ansible.builtin.shell:
cmd: '{{ansible_env.HOME}}/.nvm/versions/node/v22.9.0/bin/node {{ansible_env.HOME}}/.nvm/versions/node/v22.9.0/lib/node_modules/@bitwarden/cli/build/bw.js unlock --raw > .bw_session'
chdir: '{{ansible_env.HOME}}/fabricant'
creates: '{{ansible_env.HOME}}/fabricant/.bw_session'
- name: Sync BW Client
ansible.builtin.shell:
cmd: '{{ansible_env.HOME}}/.nvm/versions/node/v22.9.0/bin/node {{ansible_env.HOME}}/.nvm/versions/node/v22.9.0/lib/node_modules/@bitwarden/cli/build/bw.js sync --session `cat .bw_session`'
chdir: '{{ansible_env.HOME}}/fabricant'
# Set timezone
- name: Set timezone to America/Los_Angeles
become: true
community.general.timezone:
name: America/Los_Angeles
# Set netplan
- name: Install netplan config
become: true
ansible.builtin.copy:
src: netplan/01-fabricant.yml
dest: /etc/netplan/01-fabricant.yaml
owner: root
group: root
mode: '0600'
- name: Netplan Apply
become: true
ansible.builtin.command:
cmd: netplan apply
# Packages
- name: Ensure that system is up to date
become: true
apt:
name: "*"
state: latest
autoremove: yes
update_cache: yes
- name: Install/update system packages
become: true
ansible.builtin.apt:
pkg:
- python3
- build-essential
- name: Ensure these packages are not installed
become: true
ansible.builtin.apt:
state: absent
pkg:
- cups-browsed
- cups-filters
- cups-filters-core-drivers
- libcupsfilters2t64
- import_tasks: unattended-upgrades.yml
# Setup Docker
- import_tasks: docker_ubuntu_24.yaml
# Monitoring
- import_tasks: monitoring.yaml
# UFW
- import_tasks: ufw.yml
# Qualys/Trellix
- import_tasks: oec_qualys_trellix.yaml
vars:
installer: '{{ansible_env.HOME}}/installers/qualys_trellix/oec-qualystrellixinstallers-linux.tgz'
# Create users:
- import_tasks: create_users.yaml
# Auto deploy
- name: Ensure systemd user dir exists
ansible.builtin.file:
path: .config/systemd/user/
state: directory
- name: Deploy self updater
ansible.builtin.template:
src: ansible_deploy_service.service
dest: .config/systemd/user/ansible_deploy_service.service
- name: Enable ansible_deploy_service
ansible.builtin.systemd_service:
enabled: true
name: ansible_deploy_service
state: started
scope: user
- name: enable login linger
ansible.builtin.command:
cmd: loginctl enable-linger {{ ansible_user_id }}
- name: Ensure secrets dir exists
ansible.builtin.file:
path: '{{ansible_env.HOME}}/fabricant/.secrets/'
state: directory
- name: Ensure prometheus data dir exists
ansible.builtin.file:
path: '{{ansible_env.HOME}}/fabricant/prometheus-data/'
state: directory
mode: '0777'
- name: Deploy gf_admin_password
ansible.builtin.shell:
cmd: '{{ansible_env.HOME}}/.nvm/versions/node/v22.9.0/bin/node {{ansible_env.HOME}}/.nvm/versions/node/v22.9.0/lib/node_modules/@bitwarden/cli/build/bw.js --session `cat .bw_session` get password "dashboard.waiter.ucsd.edu admin" > {{ansible_env.HOME}}/fabricant/.secrets/gf_admin_password.txt'
chdir: '{{ansible_env.HOME}}/fabricant'
creates: '{{ansible_env.HOME}}/fabricant/.secrets/gf_admin_password.txt'
- name: Docker compose
community.docker.docker_compose_v2:
project_src: '{{ansible_env.HOME}}/fabricant/'
pull: 'always'
handlers:
# Restart Docker if necessary. This happens after ALL tasks are executed, including the docker-compose task.
- name: Restart Docker
become: true
service:
name: docker
state: restarted