這是本文件的舊版!
[Draft]運用 Ansible 進行多主機管理
- 管理端環境 :
- CT - Ubuntu 20.04 LTS (2 vCore/ 2G RAM / 20G SSD)
- 預計使用 git 管理 ansible 的定義檔
安裝程序
sudo apt install ansible git
確認版本
jonathan@ct-ansible:~$ ansible --version ansible 2.9.6 config file = /etc/ansible/ansible.cfg configured module search path = ['/home/jonathan/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3/dist-packages/ansible executable location = /usr/bin/ansible python version = 3.8.10 (default, May 26 2023, 14:05:08) [GCC 9.4.0]
建立主機清單檔 inventory.yaml
- Exp.
pveserver: hosts: aac: ansible_host: 192.168.11.249 ansible_port: 22 ansible_user: root ansible_ssh_pass: "mypassword" h470: ansible_host: 192.168.11.252 ansible_port: 22 ansible_connection: ssh ansible_user: root ansible_ssh_pass: "mypassword"
- 簡單驗證
$ ansible all -i test.yaml --list-hosts hosts (4): aac h470