Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue89 #90

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tasks/install-bin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
file_type: directory
register: rclone_archive

- 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

- name: Copy rclone binary
copy:
src: "{{ rclone_setup_tmp_dir }}/rclone-v{{ rclone_version }}-linux-{{ rclone_arch }}/rclone"
Expand Down
39 changes: 25 additions & 14 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,35 @@
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:
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:
Expand Down Expand Up @@ -45,24 +69,11 @@

- 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