--- - name: background packages apt: pkg: "{{ item }}" with_items: - mate-backgrounds - gnome-backgrounds - name: directory for backgrounds file: path: /opt/backgrounds state: directory - name: copy kita-pro backgrounds synchronize: src: background/ dest: /opt/backgrounds perms: false - name: find all other backgrounds find: paths: - /usr/share/backgrounds/gnome - /usr/share/backgrounds/mate/nature - /usr/share/backgrounds/mate/abstract recurse: yes excludes: "{{_excluded_backgrounds}}" register: _find_backgrounds - name: link background files file: src: "{{item}}" dest: "/opt/backgrounds/{{item|basename}}" state: link with_items: "{{_find_backgrounds|json_query('files[].path')}}"