delegate_to in combination with with_items

Why doesn’t the following work? Syntax issue? or bug?

`

  • name: Backup home dir and nagios rights
    shell: “cd {{ dirpath }}; getfacl -R {{ dir }} > {{ file }}.{{ ansible_date_time.date }}”
    with_items:
  • { dirpath: “/home/”, dir: “*”, file: “home_rights.txt” }
  • { dirpath: “/tmp”, dir: “*”, file: “tmp_rights.txt” }
  • { dirpath: “/usr/local/”, dir: “nagios”, file: “nagios_rights.txt” }
  • { dirpath: “/var/spool/mail/”, dir: “nagios”, file: “nagios_mail_rights.txt” }
    delegate_to: “{{ ansible_hostname }}”

`

Result:

`
fatal: [ansible-oel6]: FAILED! => {“msg”: “The task includes an option with an undefined variable. The error was: ‘dirpath’ is undefined\n\nThe error appears to have been in ‘/etc/ansible/playbooks/one-offs/clean_up_users.yml’: line 19, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Backup home dir and nagios rights\n ^ here\n”}

`

ansible version:
ansible-2.6.1-1.el7.noarch

When using with_items the variable is always item, so it's item.dirpath, item.dir and item.file.

Thanks Kai. I don’t know how I missed that one. I stared and stared at it but still missed it.