天天看點

ansible、saltstack部署

//首先安裝 :

yum install -y epel-release ##首先安裝 epel源

yum install ansible -y

//檢視版本(檢查安裝是否成功):

[[email protected] ~]# ansible --version

//主要配置檔案:

[[email protected] ~]# tree /etc/ansible/ ##樹狀結構展示檔案夾

/etc/ansible/

├── ansible.cfg ##ansible的配置檔案

├── hosts ##ansible的主倉庫,用于存儲需要管理的遠端主機的相關資訊

└── roles ##角色

—管理端添加服務端:

[[email protected] ~]# cd /etc/ansible

[[email protected] ansible]# vim hosts

添加組名和對應的ip位址:

[組名]

ip

。。。

ip

//配置密鑰對驗證:

[[email protected] ansible]# ssh-keygen -t rsa #生成公鑰

[[email protected] ansible]# ssh-copy-id root@用戶端ip #發送公鑰道用戶端,履歷互信

[[email protected] ansible]# ansible 組名 -m ping #驗證通信

10.0.0.32 | SUCCESS => {

“ansible_facts”: {

“discovered_interpreter_python”: “/usr/bin/python”

},

“changed”: false,

“ping”: “pong”

}

#########成功------分割符############

ansible常用子產品

Blockinfile子產品:

在檔案末尾插入兩行
`[[email protected] ~]# ansible all -m blockinfile -a "path=/tmp/rc.local block='service restart sshd\nservice restart httpd'`"

           

繼續閱讀