Hello,
I try to install restic with Ansible and I use multiple Distros.
So I create a vars file with content:
_restic_packages:
default:
- restic
- fuse
- bzip2
- pigz
Alpine:
- restic
- fuse
- bzip2
- pigz
Archlinux:
- restic
- fuse3
- fuse2fs
- bzip2
- pigz
Debian:
- restic
- fuse3
- fuse2fs
- bzip2
- pigz
FreeBSD:
- restic
- fusefs-sshfs
- fusefs-libs
- bzip2
- pigz
restic_packages: "{{ _restic_packages[ansible_os_family ~ '-' ~ ansible_distribution_major_version] | default(_restic_packages[ansible_os_family] | default(_restic_packages['default'] )) }}"
The install file in role:
- name: Check installation
ansible.builtin.package_facts:
manager: auto
- name: Install restic
ansible.builtin.package:
name: "{{ restic_packages }}"
state: present
when:
- "'{{ restic_packages }}' not in ansible_facts.packages"
This end with:
[WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: {{ restic_packages }} not in ansible_facts.packages
fatal: [storage_fr]: FAILED! =>
msg: |-
The conditional check '{{ restic_packages }} not in ansible_facts.packages' failed. The error was: Unexpected templating type error occurred on ({% if ['restic', 'fuse3', 'fuse2fs', 'bzip2', 'pigz'] not in ansible_facts.packages %} True {% else %} False {% endif %}): unhashable type: 'list'
The error appears to be in '/home/siefke/Public/projects/coding/ansible/roles/core/restic/tasks/install\.yml': line 3, column 3, but may
be elsewhere in the file depending on the exact syntax problem\.
The offending line appears to be: