cron-apt.timer and .service instead of cron-job

This commit is contained in:
Denis Knauf 2024-09-19 21:33:24 +02:00
parent 73bc81a1f5
commit 0ad6cbab1a
3 changed files with 30 additions and 3 deletions

View file

@ -0,0 +1,6 @@
[Unit]
Description=Runs periodical apt upgrades
[Service]
Type=oneshot
ExecStart=/usr/sbin/cron-apt

View file

@ -0,0 +1,8 @@
[Unit]
Description=Runs daily apt upgrades
[Install]
WantedBy=timers.target
[Timer]
OnCalendar=4:00

View file

@ -7,10 +7,12 @@
copy: copy:
dest: /etc/apt/apt.conf.d/99AutomaticClean dest: /etc/apt/apt.conf.d/99AutomaticClean
content: | content: |
Aptitude::Clean-After-Install "{{if true == apt_clean_after_install || apt_proxy is defined then 'true' else 'false'}}"; Aptitude::Clean-After-Install "{{value}}";
owner: root owner: root
group: root group: root
mode: 0644 mode: 0644
vars:
value: "{{if true == apt_clean_after_install or apt_proxy is defined then 'true' else 'false'}}"
- name: "Use proxy for apt http" - name: "Use proxy for apt http"
when: "apt_proxy is defined" when: "apt_proxy is defined"
copy: copy:
@ -153,9 +155,17 @@
mode: 0644 mode: 0644
with_dict: with_dict:
cron-apt/action.d/6-upgrade: /etc/cron-apt/action.d/6-upgrade cron-apt/action.d/6-upgrade: /etc/cron-apt/action.d/6-upgrade
cron-apt/cron-apt.service: /etc/systemd/system/cron-apt.service
cron-apt/cron-apt.timer: /etc/systemd/system/cron-apt.timer
notify: notify:
- restart services - restart services
- name: no cron-apt crontabs
lineinfile:
path: /etc/cron.d/cron-apt
line: '# 0 4 * * * root test -x /usr/sbin/cron-apt && /usr/sbin/cron-apt'
regexp: '^\s*[^#].*/usr/sbin/cron-apt'
- name: copy configs - name: copy configs
template: template:
src: "{{item.key}}" src: "{{item.key}}"
@ -228,8 +238,11 @@
src: '../../bin/k{{item}}' src: '../../bin/k{{item}}'
with_items: [dig, nsupdate] with_items: [dig, nsupdate]
- name: enable ssh - name: enable service
systemd: systemd:
name: ssh name: '{{item}}'
enabled: yes enabled: yes
state: started state: started
with_items:
- ssh.service
- cron-apt.timer