I have defined the nginx_upstreams variable in a different role that in turn uses the geerlingguy.nginx role and I have also specified the "name", "strategy" and the "servers", but when I run this role, ansible throws the error given below as if it cannot access the "name" variable defined for nginx_upstream.
This is the task that throws the error
- name: Create upstream files
file:
path: "{{ nginx_vhost_path }}/{{ item.name + '.conf' }}"
state: touch
with_items: "{{ nginx_upstreams }}"
This the role to use where the "nginx_upstreams" are defined.
- name: "Configure specific nginx service for concert to connect on remote host"
include_role:
name: geerlingguy.nginx
vars:
#for configuration specific to each server
nginx_upstreams:
- name: SOME_UPSTREAM_NAME
strategy: SOME_STRATEGY
servers: "{{ SOME_SERVER }}"
This is the ERROR that I get-
fatal: [IP]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'value'\n\nThe error appears to be in '/etc/ansible/roles/geerlingguy.nginx/tasks/vhosts.yml': line 29, 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: Create upstream files\n ^ here\n"}
This is caused by a blank variable most likely that is being looped on. Double check your variable is being set correctly.
For example if your task that is failing is this:
- name: Ensure MySQL databases are present.
mysql_db:
name: "{{ item.name }}"
collation: "{{ item.collation | default('utf8_general_ci') }}"
encoding: "{{ item.encoding | default('utf8') }}"
state: "{{ item.state | default('present') }}"
with_items: "{{ mysql_databases }}"
add a debug task:
---
- name: "Debug"
debug:
var: mysql_databases
- name: Ensure MySQL databases are present.
mysql_db:
name: "{{ item.name }}"
collation: "{{ item.collation | default('utf8_general_ci') }}"
encoding: "{{ item.encoding | default('utf8') }}"
state: "{{ item.state | default('present') }}"
with_items: "{{ mysql_databases }}"
And then search in that mysql role (atom
does easy cross directory searches) for the set_fact
for that var (in this case mysql_databases
More than likely you're setting the fact to an empty proxy object