ansible之script模塊
阿新 • • 發佈:2018-03-05
ansible之script模塊例:在所有節點上執行/tmp/test.sh1 腳本(該腳本是在ansible 控制節點上的)
[root@master tmp]# vim test.sh1
#!/bin/sh
Time=
echo "$Time script testing success!"
[root@master tmp]# ansible slave -m script -a "/tmp/test.sh1"
agent.test.com | SUCCESS => {
"changed": true,
"rc": 0,
"stderr": "",
"stdout": "Mon Jul 11 00:00:00 CST 2016 script testing success!\r\n",
"stdout_lines": [
"Mon Jul 11 00:00:00 CST 2016 script testing success!"
]
}
client02 | SUCCESS => {
"changed": true,
"rc": 0,
"stderr": "",
"stdout": "Mon Jul 11 00:00:00 CST 2016 script testing success!\r\n",
"stdout_lines": [
"Mon Jul 11 00:00:00 CST 2016 script testing success!"
]
}
[root@master tmp]# vim test.sh1
#!/bin/sh
Time=
date -s "2016/7/11"
echo "$Time script testing success!"
[root@master tmp]# ansible slave -m script -a "/tmp/test.sh1"
agent.test.com | SUCCESS => {
"changed": true,
"rc": 0,
"stderr": "",
"stdout_lines": [
"Mon Jul 11 00:00:00 CST 2016 script testing success!"
]
}
client02 | SUCCESS => {
"changed": true,
"rc": 0,
"stderr": "",
"stdout": "Mon Jul 11 00:00:00 CST 2016 script testing success!\r\n",
"Mon Jul 11 00:00:00 CST 2016 script testing success!"
]
}
[root@client02 tmp]# date
Mon Jul 11 00:00:05 CST 2016
[root@client01 tmp]# date
Mon Jul 11 00:00:09 CST 2016
ansible之script模塊