我以另一个角色定义了nginx_upstreams变量,而该角色又使用geerlingguy.nginx角色,并且还指定了“名称”,“策略”和“服务器”,但是当我运行此角色时,抛出ansible出现以下错误,好像它无法访问为nginx_upstream定义的“名称”变量一样。
这是引发错误的任务
- name: Create upstream files
file:
path: "{{ nginx_vhost_path }}/{{ item.name + '.conf' }}"
state: touch
with_items: "{{ nginx_upstreams }}"
在定义“ nginx_upstreams”时使用的角色。
- 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 }}"
这是我得到的错误-
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"}
答案 0 :(得分:0)
这是由最有可能被循环的空白变量引起的。 仔细检查您的变量设置是否正确。
例如,如果失败的任务是这样:
def main():
#Inputs information into global variables for later usage
x, y = genDataMatrix(100)
#Sets up and runs the LSTM Neural Netwwok class to be run
L = NN_LSTM()
L.__init__
L.runLSTM_NN(x, y)
main()
添加调试任务:
- 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 }}"
然后在该mysql角色(---
- 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 }}"
中进行简单的跨目录搜索)中搜索该变量的atom
(在这种情况下为set_fact
您很有可能将事实设置为空的代理对象