-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpi-kickstart.yaml
117 lines (117 loc) · 3.62 KB
/
rpi-kickstart.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
---
- name: Install and configure software for rpi-kickstart
gather_facts: True
hosts: localhost
connection: local
tasks:
- name: Copy iptables rules files
copy:
src: files/iptables.rules
dest: /etc/iptables.rules
owner: root
group: root
mode: 0644
- name: Apply iptables rules
command: iptables-restore /etc/iptables.rules
- name: Update apt repositories
when: ansible_os_family == "Debian"
apt:
update_cache: yes
cache_valid_time: 86400
- name: Create /tftproot
file:
path: /tftproot
state: directory
mode: 0755
owner: root
group: root
- name: Create /tftproot/pxelinux.cfg
file:
path: /tftproot/pxelinux.cfg
state: directory
mode: 0755
owner: root
group: root
- name: Install dnsmasq (deb)
when: ansible_os_family == "Debian"
apt:
name: dnsmasq
state: latest
- name: Install dnsmasq (rpm)
when: ansible_os_family == "RedHat"
yum:
name: dnsmasq
state: latest
- name: Install nginx (deb)
when: ansible_os_family == "Debian"
apt:
name: nginx
state: latest
- name: Install nginx (rpm)
when: ansible_os_family == "RedHat"
yum:
name: nginx
state: latest
- name: Install pxelinux (deb)
when: ansible_os_family == "Debian"
apt:
name: pxelinux
state: latest
- name: Install pxelinux (rpm)
when: ansible_os_family == "RedHat"
yum:
name: syslinux-tftpboot
state: latest
- name: Populate dnsmasq main configuration file
copy:
src: files/dnsmasq.conf
dest: /etc/dnsmasq.conf
owner: root
group: root
mode: 0644
notify:
- Restart dnsmasq
- name: Enable dnsmasq
service:
name: dnsmasq
enabled: yes
state: started
- name: Enable nginx
service:
name: nginx
enabled: yes
state: restarted
- name: Symlink pxelinux.0 (debian)
when: ansible_os_family == "Debian"
file:
src: /usr/lib/PXELINUX/pxelinux.0
dest: /tftproot/pxelinux.0
state: link
- name: Symlink pxelinux.0 (redhat)
when: ansible_os_family == "RedHat"
file:
src: /usr/share/syslinux/pxelinux.0
dest: /tftproot/pxelinux.0
state: link
- name: Symlink PXE dependencies (debian)
when: ansible_os_family == "Debian"
command: find /usr/lib/syslinux/modules/bios/ -name *.c32 -exec ln -s {} /tftproot/ \;
- name: Symlink PXE dependencies (redhat)
when: ansible_os_family == "RedHat"
command: find /usr/share/syslinux/ -name *.c32 -exec ln -s {} /tftproot/ \;
- name: Turn on ip_forward
sysctl:
name: net.ipv4.ip_forward
value: 1
sysctl_set: yes
handlers:
- name: Restart dnsmasq
service:
name: dnsmasq
state: restarted
- name: Restart nginx
service:
name: nginx
state: restarted
- name: Run Local Playbook
include: /root/rpi-kickstart-local.yaml