ansible實現集群節點資訊收集

2021-10-05 20:36:24 字數 1368 閱讀 2172

之前寫了一篇關於收集伺服器硬體資訊的博文,詳見伺服器硬體常用資訊查詢指令碼 ,除使用指令碼可以收集外,也可以使用ansible來實現資源收集。

#cat collectinfo.yaml 

- hosts: all

tasks:

- name: collect info

template: src=./info.j2 dest=/info.txt

- name: collect file

fetch: src=/info.txt dest=./collections/

- name: delete remote file

command: rm -f /info.txt

在當前目錄下新建collections目錄,用於存放收集回的資訊

hostname: 

}product name:

}product serial:

}system: }}

kernel:

}cpu count:

}} cores

total memory:

} mb

ip address:

}

# ansible-playbook collectinfo.yaml
[root@node01 ******_book]

# tree

.├── collectinfo.yaml

├── collections

│ ├── node01

│ │ └── info.txt

│ ├── node02

│ │ └── info.txt

│ └── node03

│ └── info.txt

└── info.j2

# cat collections/node02/info.txt 

hostname: node02

product name: vmware virtual platform

product serial: vmware-56 4d 43 50 c5 12 0d ae-28 bd 3b 60 89 6c fd f0

system: centos 7.4

kernel: 3.10.0-693.el7.x86_64

cpu count: 1 2 cores

total memory:3774 mb

ip address: [u'172.16.0.12', u'192.168.23.12'

]

自用 ansible集群

1.環境準備 3臺虛擬機器 centos7 ansible,管理節點 192.168.189.171 centos6 被管理節點 192.168.189.162 centos6 被管理節點 192.168.189.163 所有節點的防火牆和iptables都關一下!centos7 systemctl...

ansible集群控制

介紹 ansible是新出現的自動化運維工具,基於python開發,集合了眾多運維工具 puppet cfengine chef func fabric 的優點,實現了批量系統配置 批量程式部署 批量執行命令等功能。無客戶端。工作原理 ansible基礎 1.定義主機清單 vim etc ansib...

集群工具ansible簡單使用

ansible是與puppet saltstack類似的集群管理工具,其優點是僅需要ssh和python即可使用,而不像puppet saltstack那樣都需要客戶端。與puppet類似,ansible也支援豐富的功能 安裝方法為 yum y install ansible或pip install...