切換搜尋
搜尋
切換選單
4
1
140
H.-H.'s Wiki
導覽
首頁
近期變更
隨機頁面
上傳檔案
維基相關
作者簡介
風格指南
關於本站
切換偏好設定選單
通知
切換個人選單
尚未登入
若您做出任何編輯,會公開您的 IP 位址。
user-interface-preferences
個人工具
登入
檢視 Ansible 的原始碼
出自H.-H.'s Wiki
分享此頁面
更多操作
←
Ansible
由於以下原因,您無權編輯此頁面:
您請求的操作只有這個群組的使用者能使用:
使用者
您可以檢視並複製此頁面的原始碼。
'''Ansible''' 是使用 [[Python]] 程式語言開發與實作的一款系統環境自動化與管理工具,主要透過 SSH 協定與節點進行通訊,不需要在節點上安裝客戶端,配置語法使用 YAML 與 Jinja2 模板語言。 == 臨時命令(Ad-hoc Command) == '''臨時命令(Ad-hoc Command)'''是指使用 <code>ansible</code> 二進制執行文件,臨時執行且不需要保存的命令,其執行依賴於 Ansible Module 如 <code>command</code>、<code>raw</code>、<code>shell</code>、<code>file</code> 和 <code>cron</code> 等,執行完畢會返回 JSON 格式的資訊。 一些常用的臨時命令如下:<syntaxhighlight lang="bash"> # Ping Hosts $ ansible managednodes -m ansible.builtin.ping # Display Facts $ ansible managednodes -m ansible.builtin.setup $ ansible managednodes -m ansible.builtin.setup -a "filter=ansible_distribution*" # Copy a File from Control Node to All Managed Nodes $ ansible managednodes -m ansible.builtin.copy -a "src=/etc/hostname dest=/tmp/hostname" # Create a Directory on All Managed Nodes with Specific Ownership and Permissions $ ansible managednodes -m ansible.builtin.file -a "dest=/tmp/newpath mode=777 owner=james group=james state=directory" # Delete a Directory on All Managed Nodes $ ansible managednodes -m ansible.builtin.file -a "dest=/tmp/newpath state=absent" # Install Packages $ ansible managednodes -m ansible.builtin.apt -a "name=apache2 state=present" --become $ ansible managednodes -m ansible.builtin.apt -a "name=apache2 state=latest" --become </syntaxhighlight> * 官方所提供的模組可以使用 <code>ansible-doc -l</code> 查看。 * 如果想要查看某個模組的參數,可以使用 <code>ansible-doc -s module</code> 查看。 == 參考資料 == * [https://clay-wangzhi.com/devops/ansible/ SRE 運維進階之路|Ansible 學習筆記]
返回到「
Ansible
」。
檢視 Ansible 的原始碼
出自H.-H.'s Wiki