what's wrong here?

  • blockinfile:
    path: /etc/apache2/sites-enabled/“{{ item }}”.php.qarea.org.conf
    block: |

    AssignUserId “{{ item }}” “{{ item }}”

    insertbefore:
    with_items:
    “{{ sites }}”

TASK [blockinfile] ************************************************************************************************************************************************************************************************************************************************************
task path: /home/greg/projects/php-users.yaml:104
fatal: [php]: FAILED! => {
“failed”: true,
“msg”: “the field ‘args’ has an invalid value, which appears to include a variable that is undefined. The error was: ‘item’ is undefined\n\nThe error appears to have been in ‘/home/greg/projects/php-users.yaml’: line 104, 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 - blockinfile:\n ^ here\n”
}

sites variable is defined like this:

vars:
sites:

it seems like it doesn’t understand double reference to a variable in cycle like “{{ item }}” “{{ item }}”

what to do?
thanks a lot in advance

- does it work when your block contain a single "{{ item }}" ?
- does it work when you "{{ sites }}" is on the same line as with_items?

It seems like with_items is indented inside blockinfile, it should be at the same level:

  • blockinfile:
    path: /etc/apache2/sites-enabled/“{{ item }}”.php.qarea.org.conf
    block: |

    AssignUserId “{{ item }}” “{{ item }}”

    insertbefore:
    with_items: “{{ sites }}”