我试图使用rabbitmq_parameter ansible模块来设置联合上游集,同时动态生成集合,如下所示:
- name: Set federation upstream set
rabbitmq_parameter:
component: federation-upstream-set
name: my-upstreams
vhost: my-vhost
value: "{{ my_upstream_set }}"
变量my_upstream_set在单独的主机变量文件中定义,如下所示:
my_upstream_set: [{"upstream": "upstream1"}, {"upstream": "upstream2"}]
但是,无论我如何生成值参数,它必须是json,(带或不带引号,带有简单或双引号,yaml或json格式化),我无法使其工作。我得到的任务失败了" stderr:错误:JSON解码错误"或者出现以下错误:
failed: [myhost] => {"failed": true, "parsed": false}
invalid output was: Traceback (most recent call last):
File "<stdin>", line 1498, in <module>
File "<stdin>", line 142, in main
File "<stdin>", line 104, in set
File "<stdin>", line 88, in _exec
File "<stdin>", line 1351, in run_command
File "/usr/lib/python2.7/posixpath.py", line 261, in expanduser
if not path.startswith('~'):
AttributeError: 'list' object has no attribute 'startswith'
debug3: mux_client_read_packet: read header failed: Broken pipe
debug2: Received exit status from master 1
我尝试使用硬编码值(因此,直接在任务文件中)运行任务,并且它按预期工作,但我无法将变量集成到该任务中。知道我在这里做错了什么吗?谢谢!
答案 0 :(得分:0)
my_upstream_set
在你的情况下应该是一个JSON(字符串),它是一个列表。