Hi,
> - name: Install restic
> ansible.builtin.package:
> name: "{{ restic_packages }}"
> state: present
> when:
> - "'{{ restic_packages }}' not in ansible_facts.packages"
1. This condition does not do what you want. You are testing whether
the list of packages is a *member* of the set of installed packages.
(Which does not work, because lists cannot be part of hash sets and
lists are not hashable.) You want to test for subset, not for
membership.
2. Why not simply remove the `when:` and let the package action decide
whether the packages have already been installed or not? The package
action is supposed to be idempotent.
Cheers,
Felix