-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaybook.yml
More file actions
318 lines (271 loc) · 10.1 KB
/
playbook.yml
File metadata and controls
318 lines (271 loc) · 10.1 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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
- name: linuxcnc basic
hosts: local
become: yes
tasks:
- name: check if x11vnc password file exists
ansible.builtin.stat:
path: /etc/x11vnc.pass
register: x11vnc_pass_file
- name: prompt for VNC password if needed
ansible.builtin.pause:
prompt: "Enter the VNC password"
echo: no
register: vnc_password_input
when: not x11vnc_pass_file.stat.exists
- name: confirm VNC password if needed
ansible.builtin.pause:
prompt: "Confirm the VNC password"
echo: no
register: vnc_password_confirm
when: not x11vnc_pass_file.stat.exists
- name: verify VNC passwords match
ansible.builtin.fail:
msg: "VNC passwords do not match!"
when:
- not x11vnc_pass_file.stat.exists
- vnc_password_input.user_input != vnc_password_confirm.user_input
- name: set VNC password variable
ansible.builtin.set_fact:
vnc_password: "{{ vnc_password_input.user_input }}"
when: not x11vnc_pass_file.stat.exists
- name: linux-image-6.1.0-30-rt-amd64
ansible.builtin.dpkg_selections:
name: linux-image-6.1.0-30-rt-amd64
selection: hold
- name: linux-image-rt-amd64
ansible.builtin.dpkg_selections:
name: linux-image-rt-amd64
selection: hold
- name: disable brltty service
ansible.builtin.systemd:
name: brltty
enabled: no
state: stopped
masked: yes
ignore_errors: yes
- name: disable brltty-udev service
ansible.builtin.systemd:
name: brltty-udev
enabled: no
state: stopped
masked: yes
ignore_errors: yes
- name: disable initramfs automatic updates
ansible.builtin.lineinfile:
path: /etc/initramfs-tools/update-initramfs.conf
regexp: "^update_initramfs="
line: "update_initramfs=no"
backup: yes
- name: update package lists and upgrade system
ansible.builtin.shell:
cmd: "apt update && apt upgrade -y"
register: apt_upgrade_result
changed_when: "'upgraded' in apt_upgrade_result.stdout"
- name: check if any interface has IP 10.10.10.11
ansible.builtin.shell:
cmd: "ip addr show | grep -q '10.10.10.11/'"
register: mesa_ip_check
failed_when: false
changed_when: false
- name: get available ethernet interfaces
ansible.builtin.shell:
cmd: "ip link show | awk '$2 ~ /^(eth|enp|ens)/ {gsub(/:/, \"\", $2); print $2}'"
register: ethernet_interfaces
when: mesa_ip_check.rc != 0
changed_when: false
- name: prompt for ethernet interface selection
ansible.builtin.pause:
prompt: |
Available ethernet interfaces:
{{ ethernet_interfaces.stdout_lines | join("\n") }}
Select the interface to configure for Mesa (10.10.10.11):
register: selected_interface
when: mesa_ip_check.rc != 0 and ethernet_interfaces.stdout_lines | length > 0
- name: configure selected interface with Mesa IP
ansible.builtin.shell:
cmd: "nmcli connection add type ethernet con-name mesa ifname {{ selected_interface.user_input }} ipv4.addresses 10.10.10.11/8 ipv4.method manual autoconnect yes"
when: mesa_ip_check.rc != 0 and selected_interface.user_input is defined
register: mesa_interface_result
changed_when: true
- name: install required packages
ansible.builtin.apt:
name:
- git
- timeshift
- backintime-qt
- cinnamon
- x11vnc
state: present
update_cache: yes
- name: set cinnamon as default session manager
ansible.builtin.lineinfile:
path: /etc/lightdm/lightdm.conf
regexp: '^#?user-session='
line: 'user-session=cinnamon'
backup: yes
notify: restart lightdm
- name: disable screensaver in cinnamon
ansible.builtin.command:
cmd: gsettings set org.cinnamon.desktop.screensaver lock-enabled false
become: no
become_user: "{{ ansible_env.USER | default(ansible_user_id) }}"
changed_when: false
- name: disable screensaver idle activation
ansible.builtin.command:
cmd: gsettings set org.cinnamon.desktop.screensaver idle-activation-enabled false
become: no
become_user: "{{ ansible_env.USER | default(ansible_user_id) }}"
changed_when: false
- name: set screen to turn off after 1 hour
ansible.builtin.command:
cmd: gsettings set org.cinnamon.settings-daemon.plugins.power sleep-display-ac 3600
become: no
become_user: "{{ ansible_env.USER | default(ansible_user_id) }}"
changed_when: false
- name: create x11vnc password file
ansible.builtin.shell:
cmd: 'printf "{{ vnc_password }}\n{{ vnc_password }}\n" | x11vnc -storepasswd /etc/x11vnc.pass'
args:
creates: "/etc/x11vnc.pass"
changed_when: false
when: not x11vnc_pass_file.stat.exists
- name: create x11vnc systemd service
ansible.builtin.copy:
src: files/x11vnc.service
dest: /etc/systemd/system/x11vnc.service
owner: root
group: root
mode: '0644'
notify:
- reload systemd
- restart x11vnc
- name: enable and start x11vnc service
ansible.builtin.systemd:
name: x11vnc
enabled: yes
state: started
daemon_reload: yes
- name: configure timeshift backup device
ansible.builtin.command:
cmd: timeshift --snapshot-device /dev/sda5 --rsync
changed_when: false
- name: create timeshift configuration file
ansible.builtin.copy:
src: files/timeshift.json
dest: /etc/timeshift/timeshift.json
owner: root
group: root
mode: '0644'
backup: yes
- name: ensure timeshift cron job is active
ansible.builtin.command:
cmd: timeshift --check
changed_when: false
- name: find latest backintime snapshot
ansible.builtin.shell:
cmd: 'find /backup/backintime/backintime/cncpc/evand/1/ -maxdepth 1 -type d -name "*-*" | sort | tail -1'
register: latest_snapshot
changed_when: false
- name: restore backintime config from latest backup
ansible.builtin.copy:
src: "{{ latest_snapshot.stdout }}/backup/home/evand/.config/backintime/config"
dest: "/home/evand/.config/backintime/config"
owner: evand
group: evand
mode: '0644'
backup: yes
when: latest_snapshot.stdout != ""
become: no
- name: copy udev rules for imach-p4s
ansible.builtin.copy:
src: files/99-imach-p4s.rules
dest: /etc/udev/rules.d/99-imach-p4s.rules
owner: root
group: root
mode: '0644'
backup: yes
notify: reload udev rules
- name: clone Funkenjaeger/fj-lcnc-cfg repo
ansible.builtin.git:
repo: https://github.com/Funkenjaeger/fj-lcnc-cfg.git
dest: "~/linuxcnc"
become: no
become_user: "{{ ansible_env.USER | default(ansible_user_id) }}"
- name: check if virtual environment exists
ansible.builtin.stat:
path: /usr/local/venv/linuxcnc_venv/bin/activate
register: venv_exists
- name: create directory for virtual environment
ansible.builtin.file:
path: /usr/local/venv
state: directory
owner: "{{ ansible_env.USER | default(ansible_user_id) }}"
mode: '0755'
when: not venv_exists.stat.exists
- name: check if ADAFRUIT_IO_USERNAME is set
ansible.builtin.shell:
cmd: echo "${ADAFRUIT_IO_USERNAME:-}"
register: existing_username
changed_when: false
become: no
become_user: "{{ ansible_env.USER | default(ansible_user_id) }}"
- name: check if ADAFRUIT_IO_KEY is set
ansible.builtin.shell:
cmd: echo "${ADAFRUIT_IO_KEY:-}"
register: existing_key
changed_when: false
become: no
become_user: "{{ ansible_env.USER | default(ansible_user_id) }}"
- name: prompt for Adafruit IO username
ansible.builtin.pause:
prompt: "Enter your Adafruit IO username"
register: adafruit_username_input
when: existing_username.stdout == ""
- name: prompt for Adafruit IO key
ansible.builtin.pause:
prompt: "Enter your Adafruit IO key"
register: adafruit_key_input
when: existing_key.stdout == ""
- name: set ADAFRUIT_IO_USERNAME environment variable
ansible.builtin.lineinfile:
path: /home/{{ ansible_env.USER | default(ansible_user_id) }}/.bashrc
regexp: '^export ADAFRUIT_IO_USERNAME='
line: 'export ADAFRUIT_IO_USERNAME="{{ adafruit_username_input.user_input }}"'
backup: yes
when: existing_username.stdout == ""
become: no
become_user: "{{ ansible_env.USER | default(ansible_user_id) }}"
- name: set ADAFRUIT_IO_KEY environment variable
ansible.builtin.lineinfile:
path: /home/{{ ansible_env.USER | default(ansible_user_id) }}/.bashrc
regexp: '^export ADAFRUIT_IO_KEY='
line: 'export ADAFRUIT_IO_KEY="{{ adafruit_key_input.user_input }}"'
backup: yes
when: existing_key.stdout == ""
become: no
become_user: "{{ ansible_env.USER | default(ansible_user_id) }}"
- name: create python virtual environment
ansible.builtin.command:
cmd: python3 -m venv /usr/local/venv/linuxcnc_venv
when: not venv_exists.stat.exists
- name: install adafruit-io requirements
ansible.builtin.pip:
requirements: ~/linuxcnc/configs/DCNC/requirements.txt
virtualenv: /usr/local/venv/linuxcnc_venv
become: no
become_user: "{{ ansible_env.USER | default(ansible_user_id) }}"
handlers:
- name: restart lightdm
ansible.builtin.systemd:
name: lightdm
state: restarted
- name: reload systemd
ansible.builtin.systemd:
daemon_reload: yes
- name: restart x11vnc
ansible.builtin.systemd:
name: x11vnc
state: restarted
- name: reload udev rules
ansible.builtin.shell:
cmd: udevadm control --reload-rules && udevadm trigger