安裝方式主要有以下4種
yum install epel-release
yum install ansible
pip install ansible
brew install ansible
安裝完成後,使用git clone
cd ansible
sudo python setup.py install
ansible --version
檢查是否安裝成功
跳出版本資訊即安裝成功,如下圖
參考圖
測試環境:centos linux release 7.7.1908 (core)
測試在本地進行,即控制主機和被控主機都是localhost
ssh-keygen
ssh-keygen
後不加引數,預設生成rsa型金鑰檔案,出現如下框框則代表金鑰生成成功。金鑰檔案在/root/.ssh
目錄下。
參考圖
ssh-copy-id localhost
參考圖
在進行ssh localhost
時,就不再需要輸入密碼,直接可以進入
在/etc/ansible/hosts
檔案末尾,新增localhost,儲存檔案退出
參考圖
輸入如下命令進行連通性測試
ansible all -m ping
該樣例實現乙個ansible
版的hello world!
建立乙個新目錄,在該目錄下建立inventory
和all.yml
兩個檔案
參考圖[all]
localhost

參考圖---
- name: debug hello world
hosts: all
gather_facts: no
tasks:
- name: debug
debug:

ansible-playbook -i inventory all.yml
輸出結果見下圖
msg中輸出hello world!
物件導向01 基礎篇
物件導向基礎 一 物件導向的概念 1.物件導向的概念 面向過程的思想是拿到一件事,首先考慮的是該怎麼去做 而物件導向的思想是拿到一件事考慮的是該讓誰去做 物件導向是將面向過程中的執行者變成指揮者,使用物件導向的開發降低 的耦合度 一般將具有 封裝,繼承,多型 等特徵的程式語言稱為具有物件導向思想的程...
Ansible實踐篇(一) Ansible免密登入
主要是ansible服務端需要將 root ssh id rsa.pub分發到其他伺服器 有兩個命令比較重要 ssh keygen 這個命令是用來生成本機的公鑰和私鑰的 ssh keyscan 這條命令是用來把遠端伺服器的公鑰來獲取到本地的 1 首先關閉公鑰認證 如果說不想關閉公鑰認證的話,可以用s...
ansible 基礎入門
開始自動化運維工具ansible學習之路 ansible管理工具使用 m選項指定使用的模組,預設使用的是command模組 ansible host hostgroups m ping ansible host hostgroups m command a date cron有兩種狀態 state ...