-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.yml
134 lines (114 loc) · 3.78 KB
/
main.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
---
- name: Stop and Disable NetworkManager
service:
name: NetworkManager
enabled: no
state: stopped
# Disable unattended upgrades before attempting to install packages
# (stop service, then remove entirely)
# unattended-upgrades only runs on Ubuntu
- block:
- name: Stop unattended-upgrades service
service:
name: unattended-upgrades
state: stopped
- name: Uninstall unattended-upgrades service
apt:
name: unattended-upgrades
state: absent
when: ansible_distribution == "Ubuntu"
- name: Configure network interfaces
copy:
src: etc_network_interfaces
dest: /etc/network/interfaces
mode: 0644
owner: root
group: root
# Check early on to see if the style of interface names need to be changed
# (only applicable to Ubuntu, and not when we're running virtualised)
# We do this before the check for the Armbian reboot oracle. If we need
# to reboot to activate the old-style interface names, we'll sort out the
# reboot oracle too, but if the reboot oracle check is before this check
# we'll need to reboot a second time (after creating the symlink)
- name: setup use of old-style interface names for predictability across devices
file:
dest: /etc/udev/rules.d/80-net-setup-link.rules
src: /dev/null
state: link
when: ansible_virtualization_type == "NA"
register: old_style_names
- name: Request reboot if interface naming style has changed
set_fact:
reboot_required: True
when: old_style_names.changed
tags: skip_ansible_lint
# Check early on to see whether the OS needs to be
# rebooted to allow a disk expansion step to complete.
# This is Armbian only, but the check doesn't hurt others.
- name: Check for resize2fs reboot oracle
stat:
path: "/var/run/resize2fs-reboot"
register: resize2fs_reboot
# If the oracle above exists then we shouldn't continue
- name: Fail when disk expansion is incomplete
set_fact:
reboot_required: True
when: resize2fs_reboot.stat.exists == True
- name: Install firmware package
apt:
name: "armbian-firmware-full"
cache_valid_time: 604800 # 1 week
register: firmware_installed
- name: Schedule reboot if firmware newly installed
set_fact:
reboot_required: True
when: firmware_installed.changed
# Needs to happen before the initial reboot, given the job triggers actions
# on @reboot
- name: Disable armbian auto-update processes
file:
path: /etc/cron.d/armbian-updates
state: absent
- name: Reboot device for changes to take effect
shell: sleep 2 && /sbin/shutdown -r now
async: 1
poll: 0
when: reboot_required
# The system takes 5-10 seconds to disappear from the network
# so let's wait 15 seconds before doing our first check
- name: Wait for server to restart (max wait 5 minutes)
wait_for_connection:
delay=15
timeout=300
when: reboot_required
- name: Set default locale
lineinfile:
path=/etc/default/locale
state=present
line="LC_ALL=en_US.UTF-8"
# This is correct for test clients
- name: Set hostname based on inventory
hostname:
name: "{{ inventory_hostname }}"
- name: Set timezone to Sydney
file:
state: link
src: /usr/share/zoneinfo/Australia/Sydney
dest: /etc/localtime
# The timeout should be a few seconds shorter than the
# WAIT_TIME_FOR_ASSOCIATION_SECS in run.sh
- name: Setup dhcp client including short timeout for obtaining DHCP lease
copy:
src: dhclient.conf
dest: /etc/dhcp/dhclient.conf
# REG_DOMAIN=AU in /etc/default/crda
# change to 0 below
# APT::Periodic::Unattended-Upgrade "1";
- name: Install required packages
apt:
name: ["python3-pip", "python3-virtualenv", "tcpdump", "iperf", "netperf", "armbian-firmware-full"]
cache_valid_time: 604800 # 1 week
- name: Make pcap dumping directory
file:
state: directory
path: /root/wifi-test-results/pcap