diff --git a/README.md b/README.md index c29b197..3c2b2bc 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This ansible warning will install an bash Script, that will be executet every 3 minutes. -If your batterie is under 25 min, it will make a warning. +If your batterie is under 25 min, it will start warning you. This role is only tested on arch, but probably will work on all distros! diff --git a/defaults/main.yml b/defaults/main.yml index dbdd022..7a30328 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -7,3 +7,6 @@ install_and_enable_cronie: false # play a video in the background with sound multimedia_akku_warning: true + +# version check for this playbook +submodules_versioncheck: true diff --git a/tasks/main.yml b/tasks/main.yml index 9c6b77e..bd9c181 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,4 +1,7 @@ --- +- include_tasks: versioncheck.yml + when: submodules_versioncheck|bool + - name: copy sound warning script become: yes copy: @@ -16,7 +19,7 @@ owner: 'root' group: 'root' mode: '0644' - when: multimedia_akku_warning + when: multimedia_akku_warning|bool - name: install zenity and mpv for notifications become: yes @@ -37,7 +40,7 @@ - name: Make sure cron is installed become: true - when: install_and_enable_cronie + when: install_and_enable_cronie|bool package: name: - cronie @@ -45,7 +48,7 @@ - name: Make sure cron is running become: true - when: install_and_enable_cronie + when: install_and_enable_cronie|bool systemd: name: cronie.service state: started diff --git a/tasks/versioncheck.yml b/tasks/versioncheck.yml new file mode 100644 index 0000000..28464aa --- /dev/null +++ b/tasks/versioncheck.yml @@ -0,0 +1,39 @@ +--- +- name: Create directory for versionscheck + become: true + file: + path: '/etc/ansible-version' + state: directory + mode: 0755 + when: submodules_versioncheck|bool + +- name: check playbook version + become: true + slurp: + src: "{{ playbook_version_path }}" + register: playbook_version + when: submodules_versioncheck|bool + ignore_errors: yes + +- name: Print remote role version + debug: + msg: "Remote role version: {{ playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}" + when: submodules_versioncheck|bool + +- name: Print locale role version + debug: + msg: "Local role version: '{{ playbook_version_number|string }}'." + when: submodules_versioncheck|bool + +- name: Check if your version is outdated + fail: + msg: "Your ansible module has the version '{{ playbook_version_number }}' and is outdated. You need to update it!" + when: + - playbook_version.content|default("Mgo=")|b64decode|int - 1 >= playbook_version_number|int and submodules_versioncheck|bool + +- name: write new version to remote disk + become: true + copy: + content: "{{ playbook_version_number }}" + dest: "{{ playbook_version_path }}" + when: submodules_versioncheck|bool diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..7054e04 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,3 @@ +--- +playbook_version_number: 100 +playbook_version_path: '/etc/ansible-version/role-akku-warning_chaos-bodensee_github.com.version'