Skip to content

Commit

Permalink
improved handling of local_facts, fix test for binary installation (#87)
Browse files Browse the repository at this point in the history
* improved handling of local_facts, fix test for binary installation

* run config file install as root (#88)

* a block instead of an include

Co-authored-by: theenglishway <33462256+theenglishway@users.noreply.github.com>
  • Loading branch information
stefangweichinger and theenglishway committed Mar 25, 2021
1 parent 165823a commit 6b7153f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 32 deletions.
17 changes: 0 additions & 17 deletions tasks/install-config.yml

This file was deleted.

43 changes: 28 additions & 15 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -45,23 +58,23 @@

- 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: Install configs
block:
- name: Create config directory
file:
path: '{{ rclone_config_location | dirname }}'
state: directory
mode: '0700'

- 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: Set up rclone config
template:
src: rclone.conf.j2
dest: '{{ rclone_config_location }}'
mode: 0600
become: true
when: rclone_configs is defined

- name: Update Ansible facts if they were modified
action: setup
Expand Down

0 comments on commit 6b7153f

Please sign in to comment.