-
Notifications
You must be signed in to change notification settings - Fork 59
/
configuration_tasks.yml
329 lines (282 loc) · 12.6 KB
/
configuration_tasks.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
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
319
320
321
322
323
324
325
326
327
328
329
#
# Copyright 2020 - 2022, Dave Slotter (W3DJS). All rights reserved.
#
- name: Configuration Tasks
hosts: all
tasks:
- name: Create /etc/sudoers.d/010_{{ ham_user }}-nopasswd file
become: yes
copy:
content: ""
dest: /etc/sudoers.d/010_{{ ham_user }}-nopasswd
group: root
owner: root
mode: 0440
- name: Enable passwordless sudo for HamPi / HamPC
become: yes
blockinfile:
dest: /etc/sudoers.d/010_{{ ham_user }}-nopasswd
block: |
{{ ham_user }} ALL=(ALL) NOPASSWD: ALL
- name: Change hostname to hampi (for current session)
become: yes
command: hostname -b hampi
when: is_rpi|bool
- name: Change hostname to hampc (for current session)
become: yes
command: hostname -b hampc
when: is_pc|bool
- name: Change hostname to hampi (permanently)
become: yes
copy:
src: "{{ playbook_dir }}/../files/etc/hostname_hampi"
dest: "/etc/hostname"
when: is_rpi|bool
- name: Change hostname to hampc (permanently)
become: yes
copy:
src: "{{ playbook_dir }}/../files/etc/hostname_hampc"
dest: "/etc/hostname"
when: is_pc|bool
- name: Change hostname to hampi (for hosts file)
become: yes
copy:
src: "{{ playbook_dir }}/../files/etc/hosts_hampi"
dest: "/etc/hosts"
when: is_rpi|bool
- name: Change hostname to hampc (for hosts file)
become: yes
copy:
src: "{{ playbook_dir }}/../files/etc/hosts_hampc"
dest: "/etc/hosts"
when: is_pc|bool
- name: Store a basic version file in public location
become: yes
copy:
src: "{{ playbook_dir }}/../files/etc/hampi-release"
dest: "/etc/{{ ham_user }}-release"
when: is_rpi|bool
- name: Store a basic version file in public location
become: yes
copy:
src: "{{ playbook_dir }}/../files/etc/hampc-release"
dest: "/etc/hampc-release"
when: is_pc|bool
- name: Check that the /boot/cmdline.txt exists
stat:
path: /boot/cmdline.txt
register: cmdline_stat_result
- name: Enable resizing of (micro)SD card
become: yes
command: sed -i 's/ quiet splash plymouth.ignore-serial-consoles$/ quiet init=\/usr\/lib\/raspi-config\/init_resize.sh splash plymouth.ignore-serial-consoles/' /boot/cmdline.txt
args:
warn: no
when: cmdline_stat_result.stat.exists
- name: Remove unwanted software packages
become: yes
package:
name: "{{ item }}"
state: absent
with_items:
- wolfram-engine
- wolframscript
- bluej
- greenfoot-unbundled
- minecraft-pi
# This allows apt-add-repository command to be added
- name: Install software-properties-common Packages
become: yes
package:
name: software-properties-common
state: present
retries: 5
delay: 30
register: result
until: result.failed == false
- name: Install powermgmt-base Package for unattended-upgrades
become: yes
package:
name: powermgmt-base
state: present
retries: 5
delay: 30
register: result
until: result.failed == false
- name: Enable mail notifications for unattended-upgrades
become: yes
lineinfile:
path: /etc/apt/apt.conf.d/50unattended-upgrades
regexp: '^\/\/Unattended-Upgrade::Mail \"\";'
line: Unattended-Upgrade::Mail "{{ ham_user }}";
- name: Add the user account to group of 'dialout'
become: yes
user:
name: "{{ ham_user }}"
groups: dialout
append: yes
- name: Add the user account to group of 'plugdev'
become: yes
user:
name: "{{ ham_user }}"
groups: plugdev
append: yes
# Only apply these next two steps to RPi3 and RPi4
# Note: backup: yes cannot be used on /boot filesystem as
# it creates an invalid filename pattern which causes this
# to fail
- name: Configure Pi to use 64-bit kernel
become: yes
blockinfile:
dest: /boot/config.txt
block: |
arm_64bit=1
when: ansible_architecture == "armhf" or ansible_architecture == "armv7l"
- name: Update Pi to use 64-bit Kernel
become: yes
command: echo "y" | rpi-update
when: ansible_architecture == "armhf" or ansible_architecture == "armv7l"
- name: Enable Pi VNC Server (32 bit ARM)
become: yes
file:
dest: /etc/systemd/system/multi-user.target.wants/vncserver-x11-serviced.service
src: /usr/lib/systemd/system/vncserver-x11-serviced.service
state: link
when: ansible_architecture == "armhf" or ansible_architecture == "armv7l"
ignore_errors: yes
- name: Start Pi VNC Server (32 bit ARM)
become: yes
command: systemctl start vncserver-x11-serviced
when: ansible_architecture == "armhf" or ansible_architecture == "armv7l"
ignore_errors: yes
- name: Install Pi VNC Server (64 bit ARM)
become: yes
package:
name: "{{ item }}"
state: present
with_items:
- tightvncserver
when: ansible_architecture == "aarch64"
- name: Create /etc/xdg/pcmanfm/LXDE-pi directory for Raspberry Pi OS
become: yes
file:
path: /etc/xdg/pcmanfm/LXDE-pi
state: directory
when: ansible_distribution == "Debian" and ansible_os_family == "Debian" and (ansible_architecture == 'armhf' or ansible_architecture == 'armv7l' or ansible_architecture == "aarch64")
- name: Create HamPi desktop config 0 for Raspberry Pi OS in /etc/xdg/pcmanfm/LXDE-pi
become: yes
copy:
src: "{{ playbook_dir }}/../files/etc/xdg/pcmanfm/LXDE-pi/desktop-items-0.conf"
dest: "/etc/xdg/pcmanfm/LXDE-pi/desktop-items-0.conf"
when: ansible_distribution == "Debian" and ansible_os_family == "Debian" and (ansible_architecture == 'armhf' or ansible_architecture == 'armv7l' or ansible_architecture == "aarch64")
- name: Create HamPi desktop config 1 for Raspberry Pi OS in /etc/xdg/pcmanfm/LXDE-pi
become: yes
copy:
src: "{{ playbook_dir }}/../files/etc/xdg/pcmanfm/LXDE-pi/desktop-items-1.conf"
dest: "/etc/xdg/pcmanfm/LXDE-pi/desktop-items-1.conf"
when: ansible_distribution == "Debian" and ansible_os_family == "Debian" and (ansible_architecture == 'armhf' or ansible_architecture == 'armv7l' or ansible_architecture == "aarch64")
- name: Create HamPi desktop config 1 for Xubuntu in /etc/xdg/pcmanfm/LXDE-pi
become: yes
copy:
src: "{{ playbook_dir }}/../files/etc/xdg/xdg-xubuntu/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml"
dest: "/etc/xdg/xdg-xubuntu/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml"
when: ansible_distribution == "Ubuntu" and ansible_os_family == "Debian" and (ansible_architecture == "x86_64" or ansible_architecture == "amd64")
- name: Create /home/{{ ham_user }}/.config/pcmanfm/LXDE-pi directory
file:
path: "/home/{{ ham_user }}/.config/pcmanfm/LXDE-pi"
state: directory
when: ansible_distribution == "Debian" and ansible_os_family == "Debian" and (ansible_architecture == 'armhf' or ansible_architecture == 'armv7l' or ansible_architecture == "aarch64")
- name: Create HamPi desktop config in /home/{{ ham_user }}/.config/pcmanfm/LXDE-pi
copy:
src: "{{ playbook_dir }}/../files/home/{{ ham_user }}/.config/pcmanfm/LXDE-pi/desktop-items-0.conf"
dest: "/home/{{ ham_user }}/.config/pcmanfm/LXDE-pi/desktop-items-0.conf"
when: ansible_distribution == "Debian" and ansible_os_family == "Debian" and (ansible_architecture == 'armhf' or ansible_architecture == 'armv7l' or ansible_architecture == "aarch64")
- name: Create /etc/lightdm
become: yes
file:
path: /etc/lightdm
state: directory
- name: Create HamPi greeter config in /etc/lightdm for Raspberry Pi OS
become: yes
copy:
src: "{{ playbook_dir }}/../files/etc/lightdm/pi-greeter.conf"
dest: "/etc/lightdm/pi-greeter.conf"
when: ansible_distribution == "Debian" and ansible_os_family == "Debian" and (ansible_architecture == 'armhf' or ansible_architecture == 'armv7l' or ansible_architecture == "aarch64")
- name: Create HamPi greeter config in /etc/lightdm for Xubuntu
become: yes
copy:
src: "{{ playbook_dir }}/../files/etc/lightdm/lightdm-gtk-greeter.conf"
dest: "/etc/lightdm/lightdm-gtk-greeter.conf"
when: ansible_distribution == "Ubuntu" and ansible_os_family == "Debian" and (ansible_architecture == "x86_64" or ansible_architecture == "amd64")
- name: Create /home/{{ ham_user }}/Desktop directory
file:
path: "/home/{{ ham_user }}/Desktop"
state: directory
- name: Create HamPi README in /home/{{ ham_user }}/Desktop
copy:
src: "{{ playbook_dir }}/../files/home/{{ ham_user }}/Desktop/HAMPI README.docx"
dest: "/home/{{ ham_user }}/Desktop/HAMPI README.docx"
when: ansible_distribution == "Debian" and ansible_os_family == "Debian" and (ansible_architecture == 'armhf' or ansible_architecture == 'armv7l' or ansible_architecture == "aarch64")
- name: Create HamPC README in /home/{{ ham_user }}/Desktop
copy:
src: "{{ playbook_dir }}/../files/home/{{ ham_user }}/Desktop/HAMPC README.docx"
dest: "/home/{{ ham_user }}/Desktop/HAMPC README.docx"
when: ansible_distribution == "Ubuntu" and ansible_os_family == "Debian" and (ansible_architecture == "x86_64" or ansible_architecture == "amd64")
- name: Create HamPi LICENSE in /home/{{ ham_user }}/Desktop
copy:
src: "{{ playbook_dir }}/../files/home/{{ ham_user }}/Desktop/HAMPI LICENSE.TXT"
dest: "/home/{{ ham_user }}/Desktop/HAMPI LICENSE.TXT"
when: ansible_distribution == "Debian" and ansible_os_family == "Debian" and (ansible_architecture == 'armhf' or ansible_architecture == 'armv7l' or ansible_architecture == "aarch64")
- name: Create HamPC LICENSE in /home/{{ ham_user }}/Desktop
copy:
src: "{{ playbook_dir }}/../files/home/{{ ham_user }}/Desktop/HAMPC LICENSE.TXT"
dest: "/home/{{ ham_user }}/Desktop/HAMPC LICENSE.TXT"
when: ansible_distribution == "Ubuntu" and ansible_os_family == "Debian" and (ansible_architecture == "x86_64" or ansible_architecture == "amd64")
- name: Create GIVE BACK in /home/{{ ham_user }}/Desktop
copy:
src: "{{ playbook_dir }}/../files/home/{{ ham_user }}/Desktop/GIVE BACK.PDF"
dest: "/home/{{ ham_user }}/Desktop/GIVE BACK.PDF"
- name: Create HamPi-Help menu item in /usr/share/raspi-ui-overrides/applications
become: yes
copy:
src: "{{ playbook_dir }}/../files/usr/share/raspi-ui-overrides/applications/hampi-help.desktop"
dest: "/usr/share/raspi-ui-overrides/applications/hampi-help.desktop"
when: ansible_distribution == "Debian" and ansible_os_family == "Debian" and (ansible_architecture == 'armhf' or ansible_architecture == 'armv7l' or ansible_architecture == "aarch64")
- name: Create HamPi-Group menu item in /usr/share/raspi-ui-overrides/applications
become: yes
copy:
src: "{{ playbook_dir }}/../files/usr/share/raspi-ui-overrides/applications/hampi-group.desktop"
dest: "/usr/share/raspi-ui-overrides/applications/hampi-group.desktop"
when: ansible_distribution == "Debian" and ansible_os_family == "Debian" and (ansible_architecture == 'armhf' or ansible_architecture == 'armv7l' or ansible_architecture == "aarch64")
# TODO: See if Xubuntu has a Help Menu where this can be added
# - name: Create HamPC-Group menu item in /usr/share/raspi-ui-overrides/applications
# copy:
# src: "{{ playbook_dir }}/../files/usr/share/raspi-ui-overrides/applications/hampc-group.desktop"
# dest: "/usr/share/raspi-ui-overrides/applications/hampc-group.desktop"
# when: ansible_distribution == "Ubuntu" and ansible_os_family == "Debian" and (ansible_architecture == "x86_64" or ansible_architecture == "amd64")
- name: Insert .bash_local configuration
blockinfile:
dest: "/home/{{ ham_user }}/.bash_local"
create: yes
block: |
# BUILD OPTIONS
export MAKEFLAGS="-j `grep processor /proc/cpuinfo | wc -l`"
export CXXFLAGS='-O2 -march=native -mtune=native'
export CFLAGS='-O2 -march=native -mtune=native'
LIBRARY_PATH='/usr/local/lib'
INCLUDE_PATH='/usr/local/include'
# For using XTRX and SoapySDR with SDRAngel:
export LD_LIBRARY_PATH=/usr/local/lib:/opt/install/xtrx-images/lib:$LD_LIBARY_PATH
# TO PERMIT LAUNCHING X-WINDOWS APPS FROM TERMINAL
export DISPLAY=:0
# FIX WSJT-X POPUP BAND/FREQUENCY MENU DISPLAY
export QT_QPA_PLATFORMTHEME=cleanlooks
# QRZ.COM AUTHENTICATION FOR WSJTX_TO_N3FJP LOG ADAPTER
export QRZ_USERNAME=FILLIN
export QRZ_PASSWORD=FILLIN
- name: Insert .bashrc configuration
blockinfile:
dest: "/home/{{ ham_user }}/.bashrc"
block: |
if [ -f ~/.bash_local ]; then
. ~/.bash_local
fi