我正在写一个剧本,我需要执行mysql查询并以json格式传递 输出。剧本代码工作正常,只是我想面对字符串concatenate
部分中的错误。如果我传递样本JSON字符串,它工作正常。如何连接YAML中的字符串?
- name: Execute php script with json parameter
command: php -f /path/to/php/test.php "{'colors':{'red','blue','yellow'}}"
register: php_output
output.stdout_lines
是在我的剧本已经设置变量,它包含{'red','blue','yellow'}
格式输出。
- name: Execute php script with json parameter
command: php -f /path/to/php/test.php '{"stdout_lines": {{output.stdout_lines}} }'
register: php_output
所以我怎么能串联在'{"stdout_lines": {{output.stdout_lines}} }'
output.stdout_lines
变量?任何建议
当您在Ansible任务上传递数组时,它将针对数组上的每个条目执行一次。它不会像你所假设的那样连接执行过程中的值。看看http://docs.ansible.com/playbooks_loops.html –