Merge pull request 'Holding both states, absent and present' (#6) from state-for-flatpak-timer into main

Reviewed-on: #6
This commit is contained in:
mrckndt
2021-12-19 11:14:28 +00:00
3 changed files with 50 additions and 27 deletions

View File

@@ -1,4 +1,4 @@
--- ---
flatpak_configure_remotes: true flatpak_configure_remotes: true
flatpak_alter_flatpaks: true flatpak_alter_flatpaks: true
flatpak_automatic_updates: true flatpak_automatic_updates: false

View File

@@ -1,13 +0,0 @@
---
- name: Enable flatpak-automatic
ansible.builtin.systemd:
name: flatpak-automatic.timer
state: started
enabled: yes
daemon_reload: yes
become: yes
- name: Update Flatpaks
ansible.builtin.command:
cmd: flatpak update -y
become: yes

View File

@@ -9,16 +9,52 @@
# https://github.com/flatpak/flatpak/issues/3847#issuecomment-818532856 # https://github.com/flatpak/flatpak/issues/3847#issuecomment-818532856
- name: Enable flatpak Automatic Update - name: Enable flatpak Automatic Update
ansible.builtin.template: block:
src: "{{ item }}" - name: Place systemd service and timer
dest: "/etc/systemd/system/{{ item | regex_replace('.j2', '') }}" ansible.builtin.template:
owner: root src: "{{ item }}"
group: root dest: "/etc/systemd/system/{{ item | regex_replace('.j2', '') }}"
mode: '0644' owner: root
become: yes group: root
with_items: mode: '0644'
- flatpak-automatic.service.j2 become: yes
- flatpak-automatic.timer.j2 with_items:
notify: - flatpak-automatic.service.j2
- Enable flatpak-automatic - flatpak-automatic.timer.j2
when: flatpak_automatic_updates | bool notify:
- Enable flatpak-automatic
when: flatpak_automatic_updates | bool
- name: Enable systemd timer
ansible.builtin.systemd:
name: flatpak-automatic.timer
state: started
enabled: yes
daemon_reload: yes
become: yes
when: flatpak_automatic_updates | bool
- name: Update Flatpaks
ansible.builtin.command:
cmd: flatpak update -y
when: flatpak_automatic_updates | bool
- name: Disable flatpak Automatic Update
block:
- name: Disable systemd timer
ansible.builtin.systemd:
name: flatpak-automatic.timer
state: stopped
enabled: no
become: yes
when: not flatpak_automatic_updates | bool
- name: Remove systemd service and timer
ansible.builtin.file:
path: "/etc/systemd/system/{{ item }}"
state: absent
become: yes
with_items:
- flatpak-automatic.service
- flatpak-automatic.timer
when: not flatpak_automatic_updates | bool