第1章葫哗、ansible使用SSH的認(rèn)證方式
image.png
第一種束析、創(chuàng)建秘鑰
ssh-keygen -f ~/.ssh/id_rsa sshpass -p123456 ssh-copy-id -f -i ~/.ssh/id.rsa.pub -o'StrictHostKeyChecking=no'172.16.1.7ssh172.16.1.14"free -m"
image.png
image.png
image.png
image.png
第二種骑晶、使用ansible進(jìn)行免密
vim etc/ansible/hosts[oldboy]172.16.1.12 ansible_ssh_user=root ansible_ssh_pass=123456172.16.1.14 ansible_ssh_user=root ansible_ssh_pass=123456vim /etc/ansible/ansible/ansible.cfg取消71行前面的#號(hào)ansible oldboy -mcommand-a"free -m"
image.png
第三章溯捆、ansible的模塊以及參數(shù)講解
查看使用幫助:? ? ansible-doc? -l? 查模塊的參數(shù):? ansible-doc -scommand
3.1寂嘉、command模塊
image.png
3.2遏暴、shell模塊
功能說明:執(zhí)行一個(gè)命令在遠(yuǎn)程節(jié)點(diǎn)上
image.png
image.png
實(shí)踐:增加文本文件
image.png
3.3贡耽、copy模塊
功能說明:復(fù)制文件到遠(yuǎn)程主機(jī)
image.png
實(shí)踐1衷模、把/etc?hosts拷貝到/opt下蒲赂,權(quán)限設(shè)置400阱冶,用戶和用戶組為root
image.png
實(shí)踐2、把/etc/passwd拷貝到/tmp下改名為oldgirl,用戶和用戶組為oldboy,權(quán)限600滥嘴,如果有同名文件覆蓋
image.png
3.4木蹬、scripts 模塊
功能:遠(yuǎn)程節(jié)點(diǎn)上運(yùn)行本地腳本模塊
image.png
3.5、file模塊
設(shè)置文件屬性
image.png
實(shí)踐若皱,創(chuàng)建數(shù)據(jù)文件(普通文件 目錄 軟連接文件)
ansible oldgirl? -m file -a"dest=/tmp/oldboy state=directory"ansible oldgirl? -m file -a"dest=/tmp/123.txt state=touch"
image.png
image.png
3.6镊叁、yum模塊
image.png
image.png
3.7、systemd(Cent0s6 :service)
啟動(dòng)停止服務(wù)
image.png
image.png
image.png
實(shí)踐1走触、停止crond
image.png
實(shí)踐2晦譬、啟動(dòng)crond,設(shè)置開機(jī)啟動(dòng)
image.png
實(shí)踐3、查看crond狀態(tài)
image.png
3.8互广、cron模塊
管理定時(shí)任務(wù)條目信息模塊
image.png
image.png
實(shí)踐1敛腌、注釋定時(shí)任務(wù),是定時(shí)任務(wù)失效
image.png
3.9惫皱、user模塊
3.10像樊、mount模塊
image.png
3.11、group模塊