I have a playbook which runs a custom task to set up an nginx vhost:
tasks: - include: tasks/tweaks.yml In this playbook, the following var_files are used:
vars_files: - ../config.yml In config.yml I have the following list which holds the vhost info:
nginx_hosts_custom: - server_name: "mytest.dev" root: /drupal/www/mytest is_php: true common_config: true remote_host: "12.34.56.78" remote_root: "/web/ubuntu/www/mytest/public" pem: "mytest.pem" Within tweaks.yml I have the following:
- name: "Extra Nginx hosts for the Drupal sites" template: src: ../templates/nginx-vhost.conf.j2 dest: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf" force: yes owner: root group: root mode: 0644 with_items: nginx_hosts_custom notify: restart nginx when: drupalvm_webserver == 'nginx' This used to work perfectly, but now I receive the following error when running the provision:
fatal: [owenvm]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'unicode object' has no attribute 'server_name'\n\nThe error appears to have been in /tasks/tweaks.yml': line 20, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"Extra Nginx hosts for the Drupal sites\"\n ^ here\n"} So it appears the variable server_name is not being picked up - can anyone suggest a fix?