Scripting 将数组作为参数传递给ansible中的脚本模块
我正在使用脚本模块在某些主机上运行脚本。我有一个数组ansible变量,希望将脚本作为空格分隔的参数传递。将数组变量直接作为参数传递没有帮助。建议?您可以加入列表并将其作为变量传递,如下所示:Scripting 将数组作为参数传递给ansible中的脚本模块,scripting,ansible,Scripting,Ansible,我正在使用脚本模块在某些主机上运行脚本。我有一个数组ansible变量,希望将脚本作为空格分隔的参数传递。将数组变量直接作为参数传递没有帮助。建议?您可以加入列表并将其作为变量传递,如下所示: ansible-mscript-a“myscript.sh{{test_list}join('''}})”localhost-e{“test_list”:[1,2,3]} 如果myscript.sh为: #!/bin/bash echo Args are: ${@}, 1st: $1 2nd: $2, 3
ansible-mscript-a“myscript.sh{{test_list}join('''}})”localhost-e{“test_list”:[1,2,3]}
如果myscript.sh为:
#!/bin/bash
echo Args are: ${@}, 1st: $1 2nd: $2, 3d: $3
输出将是:
localhost | SUCCESS => {
"changed": true,
"failed": false,
"rc": 0,
"stderr": "",
"stdout": "Args are: 1 2 3, 1st: 1 2nd: 2, 3d: 3\n",
"stdout_lines": [
"Args are: 1 2 3, 1st: 1 2nd: 2, 3d: 3"
]
}