From 78c22dd28e1d58d843fbdfb21d174c3b5d1d6fb0 Mon Sep 17 00:00:00 2001 From: "Stefan G. Weichinger" Date: Mon, 22 Mar 2021 14:05:40 +0100 Subject: [PATCH 1/6] improved handling of local_facts, fix test for binary installation --- tasks/main.yml | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 71f5a25..27416f0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -8,6 +8,19 @@ tags: - vars +- name: Create directory for ansible custom facts + ansible.builtin.file: + state: directory + recurse: true + path: /etc/ansible/facts.d + +- name: Create facts file from template + ansible.builtin.template: + src: 'etc/ansible/facts.d/rclone.fact.j2' + dest: /etc/ansible/facts.d/rclone.fact + mode: '0755' + register: rclone__register_facts + - name: Re-read facts after adding custom fact become: true ansible.builtin.setup: @@ -43,26 +56,23 @@ - rclone_version | length == 0 or rclone_version == "0.0.0" - rclone_release == 'beta' +- name: "ansible-ad-hoc | show-ansible-facts-local | " + setup: + filter: "ansible_local" + gather_subset: + - '!all' + - '!min' + - 'facter' +- debug: + msg: "{{ ansible_facts['ansible_local'] }}" + - name: Install the binary include_tasks: install-bin.yml - when: (ansible_facts['ansible_local']['rclone']['installed'] is not true) or (ansible_facts['ansible_local']['rclone']['installed_version'] != rclone_version) + when: (((not ansible_local.rclone.installed|d())|bool) or (ansible_local.rclone.installed_version|d("0.0.0")) != rclone_version) - name: Install the config include_tasks: install-config.yml -- name: Create directory for ansible custom facts - ansible.builtin.file: - state: directory - recurse: true - path: /etc/ansible/facts.d - -- name: Create facts file from template - ansible.builtin.template: - src: 'etc/ansible/facts.d/rclone.fact.j2' - dest: /etc/ansible/facts.d/rclone.fact - mode: '0755' - register: rclone__register_facts - - name: Update Ansible facts if they were modified action: setup when: rclone__register_facts is changed From ab5a14600a8aa43024bab046d2e2ed13885a2163 Mon Sep 17 00:00:00 2001 From: "Stefan G. Weichinger" Date: Mon, 22 Mar 2021 14:10:18 +0100 Subject: [PATCH 2/6] remove debug statement --- tasks/main.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 27416f0..5fa68f5 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -56,16 +56,6 @@ - rclone_version | length == 0 or rclone_version == "0.0.0" - rclone_release == 'beta' -- name: "ansible-ad-hoc | show-ansible-facts-local | " - setup: - filter: "ansible_local" - gather_subset: - - '!all' - - '!min' - - 'facter' -- debug: - msg: "{{ ansible_facts['ansible_local'] }}" - - name: Install the binary include_tasks: install-bin.yml when: (((not ansible_local.rclone.installed|d())|bool) or (ansible_local.rclone.installed_version|d("0.0.0")) != rclone_version) From c4cc17511c8772b483ca4f76f7a34a9b6c3d2f14 Mon Sep 17 00:00:00 2001 From: "Stefan G. Weichinger" Date: Tue, 23 Mar 2021 16:54:19 +0100 Subject: [PATCH 3/6] DEBUG statement to display the facts from the checker script --- tasks/main.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tasks/main.yml b/tasks/main.yml index 5fa68f5..3fb23d2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -26,6 +26,17 @@ ansible.builtin.setup: filter: ansible_local +# from https://github.com/fititnt/infrastructure-as-code-ad-hoc-ansible/blob/master/info/show-ansible-facts-local.yml +- name: "ansible-ad-hoc | show-ansible-facts-local | " + setup: + filter: "ansible_local" + gather_subset: + - '!all' + - '!min' + - 'facter' +- debug: + msg: "{{ ansible_facts['ansible_local'] }}" + - block: - name: Check latest stable rclone version number uri: From 72e61bb57b6b31e6940eccf626910e00edb0f4a4 Mon Sep 17 00:00:00 2001 From: "Stefan G. Weichinger" Date: Tue, 23 Mar 2021 16:57:50 +0100 Subject: [PATCH 4/6] fix linting; cutnpaste doesnt always work --- tasks/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 3fb23d2..389ddb3 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -31,9 +31,9 @@ setup: filter: "ansible_local" gather_subset: - - '!all' - - '!min' - - 'facter' + - '!all' + - '!min' + - 'facter' - debug: msg: "{{ ansible_facts['ansible_local'] }}" From 52843f306cee89e3945c63a7c1a38a2f1b94cbe1 Mon Sep 17 00:00:00 2001 From: "Stefan G. Weichinger" Date: Wed, 24 Mar 2021 08:49:54 +0100 Subject: [PATCH 5/6] DEBUG: show content of directory --- tasks/install-bin.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tasks/install-bin.yml b/tasks/install-bin.yml index edbd936..e67cff9 100644 --- a/tasks/install-bin.yml +++ b/tasks/install-bin.yml @@ -42,6 +42,13 @@ file_type: directory register: rclone_archive +- name: DEBUG + command: "ls {{ rclone_setup_tmp_dir }}/rclone-v{{ rclone_version }}-linux-{{ rclone_arch }}" + register: dir_out + +- debug: var={{item}} + with_items: dir_out.stdout_lines + - name: Copy rclone binary copy: src: "{{ rclone_setup_tmp_dir }}/rclone-v{{ rclone_version }}-linux-{{ rclone_arch }}/rclone" From d6a5c07eac9d66c38b065aad47a26d16552ced0b Mon Sep 17 00:00:00 2001 From: "Stefan G. Weichinger" Date: Wed, 24 Mar 2021 09:00:53 +0100 Subject: [PATCH 6/6] fix gh action molecule idempotence test hopefully --- tasks/install-bin.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/install-bin.yml b/tasks/install-bin.yml index e67cff9..f382443 100644 --- a/tasks/install-bin.yml +++ b/tasks/install-bin.yml @@ -45,6 +45,7 @@ - name: DEBUG command: "ls {{ rclone_setup_tmp_dir }}/rclone-v{{ rclone_version }}-linux-{{ rclone_arch }}" register: dir_out + changed_when: "'molecule-notest' not in ansible_skip_tags" - debug: var={{item}} with_items: dir_out.stdout_lines