Ansible 정리 - Inventory
- 1 minutes read - 179 wordsAnsible 접속 방법
SSH or WinRM (powershell remoting)을 통해서 연결 agent가 필요 없다
inventory file
기본 위치 : /etc/ansible/hosts
서버 주소가 listing 되어있는 파일 (ini 형식비스무리)
server1.company.com
server2.company.com
[mail]
server3.company.com
server4.company.com
[web]
server5.company.com
server6.company.com
inventory with alias
web ansible_host=server1.company.com ansible_connection=ssh
db ansible_host=192.168.129.111 ansible_connection=winrm
- 그 외 inventory parameters
- ansible_host : 주소
- ansible_connection : conneciton type(ssh/winrm/localhos)
- ansible_port : 포트 번호 (22/5986)
- ansible_user : root/administrator
- ansible_ssh_pass : ssh password
- ansible_password : winrm password
# Web Servers
web1 ansible_host=server1.company.com ansible_connection=ssh ansible_user=root ansible_ssh_pass=Password123!
web2 ansible_host=server2.company.com ansible_connection=ssh ansible_user=root ansible_ssh_pass=Password123!
web3 ansible_host=server3.company.com ansible_connection=ssh ansible_user=root ansible_ssh_pass=Password123!
# Database Servers
db1 ansible_host=server4.company.com ansible_connection=winrm ansible_user=administrator ansible_password=Password123!
# Sample Inventory File
# Web Servers
web1 ansible_host=server1.company.com ansible_connection=ssh ansible_user=root ansible_ssh_pass=Password123!
web2 ansible_host=server2.company.com ansible_connection=ssh ansible_user=root ansible_ssh_pass=Password123!
web3 ansible_host=server3.company.com ansible_connection=ssh ansible_user=root ansible_ssh_pass=Password123!
# Database Servers
db1 ansible_host=server4.company.com ansible_connection=winrm ansible_user=administrator ansible_password=Password123!
[web_servers]
web1
web2
web3
[db_servers]
db1
web_node1 ansible_host=web01.xyz.com ansible_connection=winrm ansible_user=administrator ansible_password=Win$Pass
web_node2 ansible_host=web02.xyz.com ansible_connection=winrm ansible_user=administrator ansible_password=Win$Pass
web_node3 ansible_host=web03.xyz.com ansible_connection=winrm ansible_user=administrator ansible_password=Win$Pass
# DB Servers
sql_db1 ansible_host=sql01.xyz.com ansible_connection=ssh ansible_user=root ansible_ssh_pass=Lin$Pass
sql_db2 ansible_host=sql02.xyz.com ansible_connection=ssh ansible_user=root ansible_ssh_pass=Lin$Pass
# Groups
[db_nodes]
sql_db1
sql_db2
[web_nodes]
web_node1
web_node2
web_node3
[boston_nodes]
sql_db1
web_node1
[dallas_nodes]
sql_db2
web_node2
web_node3
[us_nodes:children]
boston_nodes
dallas_nodes