Ansible剧本只能在一个主机上运行
DECLARE @json NVARCHAR(MAX) = N'{
"currency": {
"0": {
"ISOCode": "USD",
"name": "US Dollar",
"symbol": "$",
"real": "$#,###.##",
"free": "#,###.##"
},
"1": {
"ISOCode": "IEP",
"name": "Irish Pound or Punt",
"symbol": "£",
"real": "£#,###.##",
"free": "#,###.##"
},
"2": {
"ISOCode": "BEF",
"name": "Belgian Franc",
"symbol": "₣",
"real": "#,###.##₣",
"free": "#,###.##"
}
}
}'
SELECT j2.*
INTO #TempCurrencyTable
FROm OPENJSON(@json, '$.currency') j1
CROSS APPLY OPENJSON(j1.[value]) WITH (
currency INT
) j2
SELECT *
FROM #TempCurrencyTable
实际输出是
任务[暂停渲染] ********************************************** ************************************************ [暂停渲染] 输出= {'失败':错误,u'changed':错误,u'stdout_lines':[[u'hostname las-a',u'logging-id hostname']],u'stdout':[u'主机名las-a \ nlogging origin-id主机名']}
我是“ las-a” : 好的:[las-a]
PLAY RECAP ********************************************* ****************************************************** *****
las-a:ok = 4更改= 0不可达= 0失败= 0跳过= 0获救= 0忽略= 0
las-b:ok = 3更改= 0不可达= 0失败= 0跳过= 0获救= 0忽略= 0
但是我想我是“ las-a”而我是“ las-b”
答案 0 :(得分:0)
pause“ Pauses playbook execution ...
”,即谁先到达它都会暂停所有分叉。
尝试调试,您将同时看到“ las-a”和“ las-b”。
- name: "Debug (was: pause with render)"
debug:
msg: "{{ lookup('template', 'conditional.j2') }}"
使用库存进行测试
test_jails:
hosts:
test_01:
test_02:
test_03:
下面带有 run_once: yes
- hosts: test_jails
tasks:
- pause:
prompt: "Please enter the value"
echo: yes
register: result
run_once: yes
- debug:
var: result.user_input
给予
PLAY [test_jails] ***************************************************************************
TASK [pause] ********************************************************************************
[pause]
Please enter the value:
[[ok: [test_01]
TASK [debug] ********************************************************************************
ok: [test_02] => {
"result.user_input": "TEST"
}
ok: [test_01] => {
"result.user_input": "TEST"
}
ok: [test_03] => {
"result.user_input": "TEST"
}
PLAY RECAP **********************************************************************************
test_01 : ok=2 changed=0 unreachable=0 failed=0
test_02 : ok=1 changed=0 unreachable=0 failed=0
test_03 : ok=1 changed=0 unreachable=0 failed=0
但是与 run_once: no
相同的剧本却给出了
PLAY [test_jails] ***************************************************************************
TASK [pause] ********************************************************************************
[pause]
Please enter the value:
[[ok: [test_01]
TASK [debug] ********************************************************************************
ok: [test_01] => {
"result.user_input": "TEST"
}
ok: [test_02] => {
"result.user_input": "VARIABLE IS NOT DEFINED!"
}
ok: [test_03] => {
"result.user_input": "VARIABLE IS NOT DEFINED!"
}
PLAY RECAP **********************************************************************************
test_01 : ok=2 changed=0 unreachable=0 failed=0
test_02 : ok=1 changed=0 unreachable=0 failed=0
test_03 : ok=1 changed=0 unreachable=0 failed=0
ok=2
。在这两种情况下,暂停仅执行一次。run_once: yes
的注册变量对其他主机不可用。