day—39架構(gòu)第一階段day9

第1章、ansible使用SSH的認證方式

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進行免密

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行前面的#號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í)行一個命令在遠程節(jié)點上

image.png

image.png

實踐:增加文本文件

image.png

3.3、copy模塊

功能說明:復(fù)制文件到遠程主機

image.png

實踐1、把/etc?hosts拷貝到/opt下,權(quán)限設(shè)置400,用戶和用戶組為root

image.png

實踐2、把/etc/passwd拷貝到/tmp下改名為oldgirl,用戶和用戶組為oldboy,權(quán)限600,如果有同名文件覆蓋

image.png

3.4、scripts 模塊

功能:遠程節(jié)點上運行本地腳本模塊

image.png

3.5、file模塊

設(shè)置文件屬性

image.png

實踐,創(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)

啟動停止服務(wù)

image.png

image.png

image.png

實踐1、停止crond

image.png

實踐2、啟動crond,設(shè)置開機啟動

image.png

實踐3、查看crond狀態(tài)

image.png

3.8、cron模塊

管理定時任務(wù)條目信息模塊

image.png

image.png

實踐1、注釋定時任務(wù),是定時任務(wù)失效

image.png

3.9、user模塊

3.10、mount模塊

image.png

3.11、group模塊

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 12.ansible模塊查看和幫助***** 查找模塊 ansible-doc -l #模塊就Linux命...
    一關(guān)_e438閱讀 375評論 0 0
  • 1.ansible介紹 ssh秘鑰認證+腳本批量管理,特點:簡單、實用, 但是看起來比較LOW,需要人工寫腳本,類...
    木木彡_ebe8閱讀 315評論 0 0
  • Ansible配置管理系統(tǒng) Ansible是一個配置管理系統(tǒng)configuration management sy...
    山有木兮_8adb閱讀 305評論 0 0
  • 12.2 script模塊功能說明:功能說明:在遠程節(jié)點上運行本地腳本官方鏈接:http://docs.ansib...
    Gentlewei丶閱讀 264評論 0 0
  • 毛坦廠中學(xué)教師組織參與骨干教師市級培訓(xùn) 近日,為貫徹落實《六安市教育局關(guān)于開展2018年骨干教師市級培訓(xùn)的...
    立心教育閱讀 687評論 0 1

友情鏈接更多精彩內(nèi)容