From e613663215186910c09281807f05878ba8925af1 Mon Sep 17 00:00:00 2001 From: L3D Date: Tue, 22 Oct 2019 22:17:23 +0200 Subject: [PATCH] Update versionscheck f00 --- tasks/versioncheck.yml | 35 +++++++++++++++++++++++++++++++---- vars/main.yml | 4 ++-- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/tasks/versioncheck.yml b/tasks/versioncheck.yml index 767cd5c..9cfdbba 100644 --- a/tasks/versioncheck.yml +++ b/tasks/versioncheck.yml @@ -2,19 +2,27 @@ - name: Create directory for versionscheck become: true file: - path: '/etc/ansible-version' + path: '/etc/.ansible-version' state: directory mode: 0755 when: submodules_versioncheck|bool +- name: check legacy playbook version + become: true + slurp: + src: "/etc/ansible-version/{{ playbook_version_path }}" + register: legacy_playbook_version + when: submodules_versioncheck|bool + ignore_errors: yes + changed_when: False + - name: check playbook version become: true slurp: - src: "{{ playbook_version_path }}" + src: "/etc/.ansible-version/{{ playbook_version_path }}" register: playbook_version when: submodules_versioncheck|bool ignore_errors: yes - failed_when: false - name: Print remote role version debug: @@ -31,10 +39,29 @@ 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 + - legacy_playbook_version.content|default("Mgo=")|b64decode|int - 1 >= playbook_version_number|int and submodules_versioncheck|bool + +- name: delete legacy version if needed + become: true + file: + state: absent + path: "/etc/ansible-version/{{ playbook_version_path }}" + +- name: check if '/etc/ansible-version/' is empty + find: + paths: '/etc/ansible-version/' + register: filesFound + +- name: delete legacy version folder if needed + become: true + file: + state: absent + path: "/etc/ansible-version" + when: filesFound.matched < 0 - name: write new version to remote disk become: true copy: content: "{{ playbook_version_number }}" - dest: "{{ playbook_version_path }}" + dest: "/etc/.ansible-version/{{ playbook_version_path }}" when: submodules_versioncheck|bool diff --git a/vars/main.yml b/vars/main.yml index 2faeccc..96b1580 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,3 +1,3 @@ --- -playbook_version_number: 102 -playbook_version_path: '/etc/ansible-version/role-ntp_chaos-bodensee_github.com.version' +playbook_version_number: 1024 # should be over ninethousand +playbook_version_path: 'role-ntp_chaos-bodensee_github.com.version'