ansible之script模塊

例:在所有節點上執行/tmp/test.sh1 腳本(該腳本是在ansible 控制節點上的)
[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": "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@client02 tmp]# date
Mon Jul 11 00:00:05 CST 2016
[root@client01 tmp]# date
Mon Jul 11 00:00:09 CST 2016

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章