]> git.somenet.org - root/pub/somesible.git/blob - roles/base/apt/tasks/main.yml
roles/base/backup/files
[root/pub/somesible.git] / roles / base / apt / tasks / main.yml
1 #####################################
2 ### someone's ansible provisioner ###
3 #####################################
4 # Part of: https://git.somenet.org/root/pub/somesible.git
5 # 2017-2024 by someone <someone@somenet.org>
6 #
7 ---
8 - name: copy apt sources.list
9   copy:
10     src: "{{item}}"
11     dest: "/etc/apt/sources.list"
12     mode: 0644
13     owner: "root"
14     group: "root"
15   with_first_found:
16     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/apt-sources.list"
17     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/apt-sources.list"
18     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/apt-sources.list"
19     - "default/apt-sources.list"
20
21
22 - name: copy apt package-pinning
23   copy:
24     src: "{{item}}"
25     dest: "/etc/apt/preferences.d/pinning.pref"
26     mode: 0644
27     owner: "root"
28     group: "root"
29   with_first_found:
30     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/apt-pinning.pref"
31     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/apt-pinning.pref"
32     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/apt-pinning.pref"
33     - "default/apt-pinning.pref"
34
35
36 - name: copy apt kernel autoremove settings
37   copy:
38     src: "{{item}}"
39     dest: "/etc/apt/apt.conf.d/01autoremove"
40     mode: 0644
41     owner: "root"
42     group: "root"
43   with_first_found:
44     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/apt.conf.d/01autoremove"
45     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/01autoremove"
46     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/01autoremove"
47     - "default/apt.conf.d/01autoremove"
48
49
50 - name: copy additional apt settings
51   copy:
52     src: "{{item}}"
53     dest: "/etc/apt/apt.conf.d/90somecustom"
54     mode: 0644
55     owner: "root"
56     group: "root"
57   with_first_found:
58     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/apt.conf.d/90somecustom"
59     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/90somecustom"
60     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/90somecustom"
61     - "default/apt.conf.d/90somecustom"
62
63
64 - name: copy additional dpkg settings
65   copy:
66     src: "{{item}}"
67     dest: "/etc/dpkg/dpkg.cfg.d/90somecustom"
68     mode: 0644
69     owner: "root"
70     group: "root"
71   with_first_found:
72     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/dpkg.cfg.d-90somecustom"
73     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/dpkg.cfg.d-90somecustom"
74     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/dpkg.cfg.d-90somecustom"
75     - "default/dpkg.cfg.d-90somecustom"
76
77
78 - name: copy ucf settings
79   copy:
80     src: "{{item}}"
81     dest: "/etc/ucf.conf"
82     mode: 0644
83     owner: "root"
84     group: "root"
85   with_first_found:
86     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/ucf.conf"
87     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/ucf.conf"
88     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/ucf.conf"
89     - "default/ucf.conf"
90
91
92 - name: copy ucf bin to /usr/bin/ucf
93   copy:
94     src: "{{item}}"
95     dest: "/usr/bin/ucf"
96     mode: 0755
97     owner: "root"
98     group: "root"
99   with_first_found:
100     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/ucf.bin"
101     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/ucf.bin"
102     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/ucf.bin"
103     - "default/ucf.bin"
104
105
106 - name: disable and stop apt-daily.timer
107   systemd:
108     name: apt-daily.timer
109     daemon_reload: yes
110     enabled: no
111     state: stopped
112
113
114 - name: disable and stop apt-daily-upgrade.timer
115   systemd:
116     name: apt-daily-upgrade.timer
117     daemon_reload: yes
118     enabled: no
119     state: stopped
120
121
122 - name: update repository cache if older than {{apt_cache_valid_time}} sec
123   apt:
124     update_cache: yes
125     cache_valid_time: "{{apt_cache_valid_time}}"
126   tags: "online"
127   ignore_errors: True
128
129
130 - name: install apt helper packages
131   apt:
132     pkg: "{{apt_helper_packages}}"
133     state: present
134     policy_rc_d: 101
135   tags: "online"
136   ignore_errors: "{{ignore_online_errors | bool}}"
137   register: temp
138
139
140 - name: update repository cache once more
141   apt:
142     update_cache: yes
143   tags: "online"
144   ignore_errors: True
145   when: temp.changed
146
147
148 # Use new configs. always. otherwise things like distupgrade can break.
149 - name: upgrade packages
150   apt:
151     upgrade: dist
152     install_recommends: no
153     policy_rc_d: 101
154     dpkg_options: 'force-confnew,force-confmiss'
155   tags: "online"
156   ignore_errors: "{{ignore_online_errors | bool}}"
157
158
159 - name: remove dependencies that are no longer required
160   apt:
161     autoremove: yes
162     purge: yes
163   tags: "online"
164   ignore_errors: "{{ignore_online_errors | bool}}"
165   when: apt_cleanup | bool
166
167
168 - name: remove useless packages from the download cache
169   apt:
170     autoclean: yes
171   tags: "online"
172   ignore_errors: "{{ignore_online_errors | bool}}"
173   when: apt_cleanup | bool
174
175
176 - name: install additional packages
177   apt:
178     pkg: "{{ apt_additional_pkg + apt_additional_pkg_extra }}"
179     state: present
180     policy_rc_d: 101
181   tags: "online"
182   ignore_errors: "{{ignore_online_errors | bool}}"
183
184
185 - name: install additional bare metal packages
186   apt:
187     pkg: "{{ apt_additional_pkg_bare_metal }}"
188     state: present
189     policy_rc_d: 101
190   when: is_bare_metal | bool
191   tags: "online"
192   ignore_errors: "{{ignore_online_errors | bool}}"
193
194
195 # hacky, but sufficient for now: enablestart some installed services
196 - name: enable and start plocate-updatedb.timer
197   include_role: name="base/systemd/enable-and-start"
198   vars:
199     service_name: plocate-updatedb.timer
200
201 - name: enable and start lm-sensors.service
202   include_role: name="base/systemd/enable-and-start"
203   vars:
204     service_name: lm-sensors.service
205   when: is_bare_metal | bool
206
207 - name: enable and start smartmontools.service
208   include_role: name="base/systemd/enable-and-start"
209   vars:
210     service_name: smartmontools.service
211   when: is_bare_metal | bool