ansible saltstack 命令簡單對比


salt

ansible

服務安裝

salt h112  pkg.install nginx

ansible h112 -m apt -a "name=nginx state=present"

服務停止

salt h112 service.stop nginx

ansible h112 -m service -a "name=nginx state=stopped"

運行命令

salt h112 cmd.run 'w'

ansible h112 -m command -a "w"

運行命令 服務相關

salt h112 cmd.run 'service nginx restart'

ansible h112 -m command -a "service nginx restart"

文件

salt-cp  h112  file     slave-hosts-dir

ansible h112 -m copy -a "src=/a/b dest=/b/c"

目錄

複雜,用sls





客戶端識別

客戶機配置文件中的id生成minion_id , 主機中salt-key查看客戶端主機名,並列表/正則等匹配

主 配置host文件 ip或 域名




sls playbook

/srv/salt/web/apache.sls

/xxx/web/apache.playbook

ansible-playbook  ntp.yml  --syntax --check  #語法檢查




調用

salt h112 state.sls web.apache

ansible-playbok  /xxx/web/apache

高級

salt '*' state.highstate test=True  #執行前 test=True

role方式,目錄方式。


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