文章目錄
ansible學習筆記 ansible 介紹 ansible 架構原理 ansible 安裝 ansible 組態檔 ansible 命令 ansible 命令 ansible 常見模塊 ansible命令執行程序 ansible 遠程除錯
ansible playbook
templates 模板 role 介紹 其他系統設定 seLinux 設定 seLinux: 查看SELinux狀態: 關閉SELinux:
服務器建立互信
others
ansible學習筆記
ansible 介紹
Ansible是一種開源軟體配置,配置管理和應用程式部署工具,可將基礎結構作為代碼啟用,它可以在許多類Unix系統上運行,并且可以配置類Unix系統和Microsoft Windows,它包含自己的宣告性語言來描述系統配置,
特點:
輕量級,無需安裝Agent 命令可單條執行,可撰寫成劇本,支持條件判斷、回圈 u基于SSH,Kerberos,LDAP等協議作業 基于python開發,簡單易維護
ansible 架構原理
ansible 安裝
yum 安裝
配置epel源
執行 yum install -y ansible
cd /etc/yum.repos.d/
for i in $( ls ./) ; do echo $i ; mv $i $i .bak.2021.01.11 ; done
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache
yum -y install ansible
ansible --version
原始碼安裝
pip安裝
ansible 組態檔
/etc/ansible/ansible.cfg #組態檔
host_key_checking ssh檢查 log_path 日志記錄
/etc/ansible/hosts #默認主機清單,可以修改,在執行playbook的時候可以通過 -i 引數指定主機清單
可以設定組
[webserver]
192.168.1.100
192.168.1.101
定義變數
[webserver]
192.168.1.100 ansible_port=80 ansible_user=javen
192.168.1.101 ansible_port=81
支持模式匹配
在使用 腳本的時候: ansible web* -m ping
ansible 命令
ansible 命令
ansible # 執行ansible單條命令,ansible稱這種方式為臨時命令(Ansible Ad-Hoc),
ansible-doc # 查看ansible 模塊說明
ansible-galaxy # 連接https://galaxy.ansible.com/ 下載相應的roles
#列出所有已經安裝的 galaxy
ansible-galaxy list
#安裝galaxy
ansible-galaxy install andrewrothstein.etcd
ansible-galaxy install geerlingguy.jenkins
#洗掉galaxy
ansible-galaxy remove andrewrothstein.etcd
ansible-pull #推送命令至遠程
ansible-playbook #
ansible-vault #管理加密解密yml檔案
ansibl-console #執行互動式命令的界面
ansible 常見模塊
ping 模塊
ansible servername -m ping -u username -k command 模塊
ansible 192.168.* -m command -a 'ls /'ansible 192.168.* -a 'ls /' 默認為command 模塊,可以忽略, shell 模塊
ansible 192.168.* -m shell -a 'ls /'
有很多情況下,command 模塊不支持了,就需要使用shell模塊,如下面的情況:
下面的輸出是將單引號里面的內容原樣輸出了
ansible 192.168* -a 'echo 123 | grep 3'
輸出:
192.168.xxx.xxx | CHANGED | rc= 0 >>
123 | grep 3
下面是使用shell模塊的效果
ansible 192.168* -m shell -a 'echo 123 | grep 3'
輸出:
192.168.xxx.xxx | CHANGED | rc= 0 >>
123
script 模塊
ansible 192.168.* -m script -a 'host.sh args' copy 模塊
fetch 模塊
file 模塊
setup 模塊
ansible命令執行程序
<style>#mermaid-svg-h2KMknigpysyiLNn .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-h2KMknigpysyiLNn .label text{fill:#333}#mermaid-svg-h2KMknigpysyiLNn .node rect,#mermaid-svg-h2KMknigpysyiLNn .node circle,#mermaid-svg-h2KMknigpysyiLNn .node ellipse,#mermaid-svg-h2KMknigpysyiLNn .node polygon,#mermaid-svg-h2KMknigpysyiLNn .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-h2KMknigpysyiLNn .node .label{text-align:center;fill:#333}#mermaid-svg-h2KMknigpysyiLNn .node.clickable{cursor:pointer}#mermaid-svg-h2KMknigpysyiLNn .arrowheadPath{fill:#333}#mermaid-svg-h2KMknigpysyiLNn .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-h2KMknigpysyiLNn .flowchart-link{stroke:#333;fill:none}#mermaid-svg-h2KMknigpysyiLNn .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-h2KMknigpysyiLNn .edgeLabel rect{opacity:0.9}#mermaid-svg-h2KMknigpysyiLNn .edgeLabel span{color:#333}#mermaid-svg-h2KMknigpysyiLNn .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-h2KMknigpysyiLNn .cluster text{fill:#333}#mermaid-svg-h2KMknigpysyiLNn div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-h2KMknigpysyiLNn .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-h2KMknigpysyiLNn text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-h2KMknigpysyiLNn .actor-line{stroke:grey}#mermaid-svg-h2KMknigpysyiLNn .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-h2KMknigpysyiLNn .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-h2KMknigpysyiLNn #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-h2KMknigpysyiLNn .sequenceNumber{fill:#fff}#mermaid-svg-h2KMknigpysyiLNn #sequencenumber{fill:#333}#mermaid-svg-h2KMknigpysyiLNn #crosshead path{fill:#333;stroke:#333}#mermaid-svg-h2KMknigpysyiLNn .messageText{fill:#333;stroke:#333}#mermaid-svg-h2KMknigpysyiLNn .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-h2KMknigpysyiLNn .labelText,#mermaid-svg-h2KMknigpysyiLNn .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-h2KMknigpysyiLNn .loopText,#mermaid-svg-h2KMknigpysyiLNn .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-h2KMknigpysyiLNn .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-h2KMknigpysyiLNn .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-h2KMknigpysyiLNn .noteText,#mermaid-svg-h2KMknigpysyiLNn .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-h2KMknigpysyiLNn .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-h2KMknigpysyiLNn .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-h2KMknigpysyiLNn .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-h2KMknigpysyiLNn .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-h2KMknigpysyiLNn .section{stroke:none;opacity:0.2}#mermaid-svg-h2KMknigpysyiLNn .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-h2KMknigpysyiLNn .section2{fill:#fff400}#mermaid-svg-h2KMknigpysyiLNn .section1,#mermaid-svg-h2KMknigpysyiLNn .section3{fill:#fff;opacity:0.2}#mermaid-svg-h2KMknigpysyiLNn .sectionTitle0{fill:#333}#mermaid-svg-h2KMknigpysyiLNn .sectionTitle1{fill:#333}#mermaid-svg-h2KMknigpysyiLNn .sectionTitle2{fill:#333}#mermaid-svg-h2KMknigpysyiLNn .sectionTitle3{fill:#333}#mermaid-svg-h2KMknigpysyiLNn .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-h2KMknigpysyiLNn .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-h2KMknigpysyiLNn .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-h2KMknigpysyiLNn .grid path{stroke-width:0}#mermaid-svg-h2KMknigpysyiLNn .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-h2KMknigpysyiLNn .task{stroke-width:2}#mermaid-svg-h2KMknigpysyiLNn .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-h2KMknigpysyiLNn .taskText:not([font-size]){font-size:11px}#mermaid-svg-h2KMknigpysyiLNn .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-h2KMknigpysyiLNn .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-h2KMknigpysyiLNn .task.clickable{cursor:pointer}#mermaid-svg-h2KMknigpysyiLNn .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-h2KMknigpysyiLNn .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-h2KMknigpysyiLNn .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-h2KMknigpysyiLNn .taskText0,#mermaid-svg-h2KMknigpysyiLNn .taskText1,#mermaid-svg-h2KMknigpysyiLNn .taskText2,#mermaid-svg-h2KMknigpysyiLNn .taskText3{fill:#fff}#mermaid-svg-h2KMknigpysyiLNn .task0,#mermaid-svg-h2KMknigpysyiLNn .task1,#mermaid-svg-h2KMknigpysyiLNn .task2,#mermaid-svg-h2KMknigpysyiLNn .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-h2KMknigpysyiLNn .taskTextOutside0,#mermaid-svg-h2KMknigpysyiLNn .taskTextOutside2{fill:#000}#mermaid-svg-h2KMknigpysyiLNn .taskTextOutside1,#mermaid-svg-h2KMknigpysyiLNn .taskTextOutside3{fill:#000}#mermaid-svg-h2KMknigpysyiLNn .active0,#mermaid-svg-h2KMknigpysyiLNn .active1,#mermaid-svg-h2KMknigpysyiLNn .active2,#mermaid-svg-h2KMknigpysyiLNn .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-h2KMknigpysyiLNn .activeText0,#mermaid-svg-h2KMknigpysyiLNn .activeText1,#mermaid-svg-h2KMknigpysyiLNn .activeText2,#mermaid-svg-h2KMknigpysyiLNn .activeText3{fill:#000 !important}#mermaid-svg-h2KMknigpysyiLNn .done0,#mermaid-svg-h2KMknigpysyiLNn .done1,#mermaid-svg-h2KMknigpysyiLNn .done2,#mermaid-svg-h2KMknigpysyiLNn .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-h2KMknigpysyiLNn .doneText0,#mermaid-svg-h2KMknigpysyiLNn .doneText1,#mermaid-svg-h2KMknigpysyiLNn .doneText2,#mermaid-svg-h2KMknigpysyiLNn .doneText3{fill:#000 !important}#mermaid-svg-h2KMknigpysyiLNn .crit0,#mermaid-svg-h2KMknigpysyiLNn .crit1,#mermaid-svg-h2KMknigpysyiLNn .crit2,#mermaid-svg-h2KMknigpysyiLNn .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-h2KMknigpysyiLNn .activeCrit0,#mermaid-svg-h2KMknigpysyiLNn .activeCrit1,#mermaid-svg-h2KMknigpysyiLNn .activeCrit2,#mermaid-svg-h2KMknigpysyiLNn .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-h2KMknigpysyiLNn .doneCrit0,#mermaid-svg-h2KMknigpysyiLNn .doneCrit1,#mermaid-svg-h2KMknigpysyiLNn .doneCrit2,#mermaid-svg-h2KMknigpysyiLNn .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-h2KMknigpysyiLNn .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-h2KMknigpysyiLNn .milestoneText{font-style:italic}#mermaid-svg-h2KMknigpysyiLNn .doneCritText0,#mermaid-svg-h2KMknigpysyiLNn .doneCritText1,#mermaid-svg-h2KMknigpysyiLNn .doneCritText2,#mermaid-svg-h2KMknigpysyiLNn .doneCritText3{fill:#000 !important}#mermaid-svg-h2KMknigpysyiLNn .activeCritText0,#mermaid-svg-h2KMknigpysyiLNn .activeCritText1,#mermaid-svg-h2KMknigpysyiLNn .activeCritText2,#mermaid-svg-h2KMknigpysyiLNn .activeCritText3{fill:#000 !important}#mermaid-svg-h2KMknigpysyiLNn .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-h2KMknigpysyiLNn g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-h2KMknigpysyiLNn g.classGroup text .title{font-weight:bolder}#mermaid-svg-h2KMknigpysyiLNn g.clickable{cursor:pointer}#mermaid-svg-h2KMknigpysyiLNn g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-h2KMknigpysyiLNn g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-h2KMknigpysyiLNn .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-h2KMknigpysyiLNn .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-h2KMknigpysyiLNn .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-h2KMknigpysyiLNn .dashed-line{stroke-dasharray:3}#mermaid-svg-h2KMknigpysyiLNn #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-h2KMknigpysyiLNn #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-h2KMknigpysyiLNn #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-h2KMknigpysyiLNn #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-h2KMknigpysyiLNn #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-h2KMknigpysyiLNn #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-h2KMknigpysyiLNn #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-h2KMknigpysyiLNn #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-h2KMknigpysyiLNn .commit-id,#mermaid-svg-h2KMknigpysyiLNn .commit-msg,#mermaid-svg-h2KMknigpysyiLNn .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-h2KMknigpysyiLNn .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-h2KMknigpysyiLNn .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-h2KMknigpysyiLNn g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-h2KMknigpysyiLNn g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-h2KMknigpysyiLNn g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-h2KMknigpysyiLNn g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-h2KMknigpysyiLNn g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-h2KMknigpysyiLNn g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-h2KMknigpysyiLNn .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-h2KMknigpysyiLNn .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-h2KMknigpysyiLNn .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-h2KMknigpysyiLNn .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-h2KMknigpysyiLNn .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-h2KMknigpysyiLNn .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-h2KMknigpysyiLNn .edgeLabel text{fill:#333}#mermaid-svg-h2KMknigpysyiLNn .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-h2KMknigpysyiLNn .node circle.state-start{fill:black;stroke:black}#mermaid-svg-h2KMknigpysyiLNn .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-h2KMknigpysyiLNn #statediagram-barbEnd{fill:#9370db}#mermaid-svg-h2KMknigpysyiLNn .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-h2KMknigpysyiLNn .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-h2KMknigpysyiLNn .statediagram-state .divider{stroke:#9370db}#mermaid-svg-h2KMknigpysyiLNn .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-h2KMknigpysyiLNn .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-h2KMknigpysyiLNn .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-h2KMknigpysyiLNn .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-h2KMknigpysyiLNn .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-h2KMknigpysyiLNn .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-h2KMknigpysyiLNn .note-edge{stroke-dasharray:5}#mermaid-svg-h2KMknigpysyiLNn .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-h2KMknigpysyiLNn .error-icon{fill:#522}#mermaid-svg-h2KMknigpysyiLNn .error-text{fill:#522;stroke:#522}#mermaid-svg-h2KMknigpysyiLNn .edge-thickness-normal{stroke-width:2px}#mermaid-svg-h2KMknigpysyiLNn .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-h2KMknigpysyiLNn .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-h2KMknigpysyiLNn .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-h2KMknigpysyiLNn .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-h2KMknigpysyiLNn .marker{fill:#333}#mermaid-svg-h2KMknigpysyiLNn .marker.cross{stroke:#333}
:root { --mermaid-font-family: "trebuchet ms", verdana, arial;}</style>
<style>#mermaid-svg-h2KMknigpysyiLNn {
color: rgba(0, 0, 0, 0.75);
font: ;
}</style>
ansible
remote server
加載自己的組態檔\n(/etc/ansible/ansible.cfg)
加載自己的模塊檔案\n(如 ping、 command)
生成臨時py檔案\n(~/.ansible/tmp/)
將py傳輸至遠程受控機(~/.ansible/tmp)
ansible支持批量的操作\n這里的remote server可以是多臺主機
給檔案增加執行權限,并執行 (+x)
回傳執行結果
洗掉臨時檔案
ansible
remote server
Ansible命令執行程序
ansible 遠程除錯
ansible playbook
playbook 核心元素
hosts 執行的遠程主機串列 tasks 任務集 varniables 內置變數或者自定義變數在playbook中呼叫 templates 模板,可替換模板檔案中的變數并實作一些簡單邏輯的檔案 handlers 和 notify結合使用,由特定條件觸發,滿足條件才執行,否則不執行 tags 標簽,指定某條任務執行,用于選擇playbook中的部分代碼,ansible具有冪等性,因此會自動跳過沒有變化的部分,即便如此,有些代碼為了測驗其確實沒有發生變化的時間很長,此時,如果確定沒有變化,就可以通過tags跳過這些代碼片段 ansible-playbook -t tagsname useradd.yml
templates 模板
jinja2語言
role 介紹
下載role:通過在ansible-galaxy的網站上面搜索下載自己需要的role,
geerlingguy.jenkins #每一個檔案夾就是一個role
├── defaults #設定默認變數時使用此目錄中的main.yml
│ └── main.yml
├── handlers #至少有一個main.yml,其他檔案通過include包含
│ └── main.yml
├── LICENSE
├── meta #至少有一個main.yml,其他檔案通過include包含,定義當前角色的特殊設定及依賴關系
│ └── main.yml
├── molecule
│ └── default
│ ├── converge.yml
│ ├── java-11.yml
│ ├── java-8.yml
│ ├── molecule.yml
│ ├── playbook-http-port.yml
│ ├── playbook-jenkins-version.yml
│ ├── playbook-plugins-with-home.yml
│ ├── playbook-prefix.yml
│ └── requirements.yml
├── README.md
├── tasks #至少有一個main.yml,其他檔案通過include包含,定義task的基本元素
│ ├── main.yml
│ ├── plugins.yml
│ ├── settings.yml
│ ├── setup-Debian.yml
│ └── setup-RedHat.yml
├── templates #存放模板檔案
│ ├── basic-security.groovy.j2
│ └── proxy.xml
├── tests
│ └── test-plugins.yml
└── vars #至少有一個main.yml,其他檔案通過include包含,定義變數的目錄
├── Debian.yml
└── RedHat.yml
其他系統設定
seLinux 設定
seLinux:
SELinux(Security-Enhanced Linux) 是美國國家安全域NSA對于強制訪問控制的實作,是 Linux歷史上最杰出的新安全子系統,NSA是在Linux社區的幫助下開發了一種訪問控制體系,在這種訪問控制體系的限制下,行程只能訪問那些在他的任務中所需要檔案,SELinux 默認安裝在 Fedora 和 Red Hat Enterprise Linux 上,也可以作為其他發行版上容易安裝的包得到,
查看SELinux狀態:
1、/usr/sbin/sestatus -v #如果SELinux status引數為enabled即為開啟狀態
SELinux status: enabled
2、getenforce #也可以用這個命令檢查
關閉SELinux:
1、臨時關閉(不用重啟機器):
setenforce 0 #設定SELinux 成為permissive模式
setenforce 1 #setenforce 1 設定SELinux 成為enforcing模式
2、修改組態檔需要重啟機器:
修改/etc/selinux/config 檔案
將SELINUX=enforcing改為SELINUX=disabled
重啟機器即可
服務器建立互信
ssh-keygen
ssh-copy-id 10.1.xx.xxx
others