Move tarball compression to background service;Housekeeping
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
0d7b1ab269
commit
c9a8598a35
@ -0,0 +1,4 @@
|
||||
- name: Disable crontab job
|
||||
ansible.builtin.cron:
|
||||
name: firstboot
|
||||
state: absent
|
@ -1,10 +1,5 @@
|
||||
- name: Compress tarballs
|
||||
community.general.archive:
|
||||
dest: /opt/metacluster/container-images/image-tarballs.tgz
|
||||
path: /opt/metacluster/container-images/*.tar
|
||||
format: gz
|
||||
remove: yes
|
||||
ignore_errors: yes
|
||||
- import_tasks: service.yml
|
||||
- import_tasks: cron.yml
|
||||
|
||||
- name: Cleanup tempfile
|
||||
ansible.builtin.file:
|
||||
@ -12,11 +7,6 @@
|
||||
state: absent
|
||||
when: kubeconfig.path is defined
|
||||
|
||||
- name: Disable crontab job
|
||||
ansible.builtin.cron:
|
||||
name: firstboot
|
||||
state: absent
|
||||
|
||||
- name: Reboot host
|
||||
ansible.builtin.shell:
|
||||
cmd: /usr/sbin/reboot now
|
||||
|
@ -0,0 +1,24 @@
|
||||
- name: Create tarball compression service
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "{{ item.mode | default(omit) }}"
|
||||
vars:
|
||||
_template:
|
||||
service:
|
||||
name: compressTarballs
|
||||
executable: /opt/firstboot/compresstarballs.sh
|
||||
workingdir: /opt/metacluster/container-images/
|
||||
loop:
|
||||
- src: compresstarballs.j2
|
||||
dest: "{{ _template.service.executable }}"
|
||||
mode: o+x
|
||||
- src: systemdunit.j2
|
||||
dest: /etc/systemd/system/{{ _template.service.name }}.service
|
||||
|
||||
- name: Enable tarball compression service
|
||||
ansible.builtin.systemd:
|
||||
name: compressTarballs
|
||||
enabled: yes
|
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Change working directory
|
||||
popd {{ _template.service.workingdir }}
|
||||
|
||||
# Compress *.tar files
|
||||
if tar -czf image-tarballs.tgz *.tar; then
|
||||
# Disable systemd unit
|
||||
systemctl disable {{ _template.service.name }}
|
||||
fi
|
@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description={{ _template.service.name }}
|
||||
|
||||
[Service]
|
||||
ExecStart={{ _template.service.executable }}
|
||||
Nice=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user