AnsibleError: unexpected templating type error

This probably indicates a yaml problem with your site_hosts. My first guess would be that your redirects is just empty, like this:

wordpress_sites:
  example.com:
    site_hosts:
      - canonical: example.com
        redirects:
    local_path: ../site # path targeting local Bedrock site directory (relative to Ansible root)
    ...

Ansible loads a YAML variable without a value as the python None, whose type is NoneType and indeed 'NoneType' object is not iterable, as it needs to be for the loop: {% for redirect in item.redirects | default([]) %}.

If the problem is with redirects and you simply don’t have any redirects, just remove redirects completely, or comment it out, or specify it as an empty list, e.g., redirects: []

Here is some discussion on the YAML structure of site_hosts.

If the above doesn’t clear it up, feel free to post your wordpress_sites for review.

4 Likes