-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.yml
139 lines (115 loc) · 3.92 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
134
135
136
137
138
139
---
- name: Do Everything
hosts: vm
become: true
user: imageadmin
gather_facts: true
vars:
ansible_python_interpreter: /usr/bin/python3
tasks:
- name: copy pam_environment to make sure the proxy is disabled for icpcadmin(and root)
copy: src=files/pam_environment dest={{ item }}/.pam_environment
with_items:
- /root
- /home/imageadmin
- name: copy updated pam sudo config so it reads .pam_environment
copy: src=files/pam_sudo dest=/etc/pam.d/sudo
- name: disable fsync for dpkg
copy: dest=/etc/dpkg/dpkg.cfg.d/02-dpkg-no-sync content="force-unsafe-io"
- name: disable apt cache
copy:
dest: /etc/apt/apt.conf.d/02-fast-apt
content: |
# Disable some apt-caching
Dir::Cache {
srcpkgcache "";
pkgcache "";
}
# No translations
Acquire::Language "none";
- name: be sure apt cache is updated
apt: update_cache=yes upgrade=dist
- name: set up efi booting
apt:
pkg: [ grub-efi, grub-efi-amd64-signed ]
state: present
- name: run grub-install for efi
command: grub-install --no-nvram --uefi-secure-boot --target=x86_64-efi /dev/sda
- name: remove snap package
apt:
name: snapd
purge: true
state: absent
- name: clean up any leftover snap data
file:
state: absent
path: "{{item}}"
with_items:
- /snap
- /var/snap
- /var/lib/snapd
- /var/cache/snapd
- /run/snapd-snap.socket
- /run/snapd.socket
- /etc/apt/apt.conf.d/20snapd.conf
- name: prevent snapd from being installed later
copy:
dest: /etc/apt/preferences.d/snapd-disable
content: |
Package: snapd
Pin: release *
Pin-Priority: -1
# remove cloud init, because it's a security issue (a cd/other usb drive could give someone root)
- name: remove cloud-init
apt:
pkg: cloud-init
state: absent
purge: yes
- import_tasks: 'playbooks/gui.yml'
- import_tasks: 'playbooks/reverseproxy.yml'
- import_tasks: 'playbooks/compilers.yml'
- import_tasks: 'playbooks/devel_tools.yml'
- import_tasks: 'playbooks/icpc.yml'
- import_tasks: 'playbooks/vmtouch.yml'
- import_tasks: 'playbooks/firewall.yml'
- import_tasks: 'playbooks/system.yml'
# Management related things
- import_tasks: 'playbooks/ansible-pull.yml'
- import_tasks: 'playbooks/reversetunnel.yml'
- import_tasks: 'playbooks/vpn.yml'
- import_tasks: 'playbooks/monitoring.yml'
- name: autoremove/autoclean apt
block:
- apt: autoremove=yes
- apt: autoclean=yes
- shell: apt-get clean
- name: ensure systemd-timesyncd is running (to make sure ntp is working properly)
# This will/should fail if ntp is installed
service: name=systemd-timesyncd state=started
# Copy some build information to the image
- shell: 'echo "Built on $(date +"%Y-%m-%d %H:%M:%S")\nRevision: $(git rev-list --full-history --all --abbrev-commit | head -1)\n"'
become: false
register: git_revision
delegate_to: 127.0.0.1
- name: copy version info
copy: content="{{git_revision.stdout}}\n" dest=/icpc/version
# - name: zero out the disk so it's more optimal (this is part of the makeDist script)
# shell: |
# dd if=/dev/zero of=/empty bs=1M || true
# rm -f /empty
# sync
handlers:
- name: clear user password
command: passwd -d contestant
- name: update grub
command: /usr/sbin/update-grub
- name: restart squid
service: name=squid state=restarted
- name: update-ca-certificates
command: /usr/sbin/update-ca-certificates
- name: restart ssh
service: name=ssh state=restarted
- name: reload nginx
ansible.builtin.service:
name: nginx
state: reloaded