Loading views...
ansible inventory 공부

ansible inventory 공부

Date
Date
2020 Jan 15 0:0
Created by
Created by
Seonglae ChoSeonglae Cho
Created time
Created time
2023 Feb 28 12:39
Last edited by
Last edited by
Seonglae ChoSeonglae Cho
Last edited time
Last edited time
2023 Apr 15 16:44
Refs
Refs
기본 /etc/ansible/hosts 파일로 호스트들을 관리할 수는 있지만 호스트 많아지면 덜직관적이라서 힘들다
그래서 트리구조 가지는 yaml 활용한 ansible inventory가 있는데
 
Using Variables - Ansible Documentation
While automation exists to make it easier to make things repeatable, all systems are not exactly alike; some may require configuration that is slightly different from others. In some instances, the observed behavior or state of one system might influence how you configure other systems. For example, you might need to find out the IP address of a system and use it as a configuration value on another system.
Using Variables - Ansible Documentation
How to build your inventory - Ansible Documentation
Ansible works against multiple managed nodes or "hosts" in your infrastructure at the same time, using a list or group of lists know as inventory. Once your inventory is defined, you use to select the hosts or groups you want Ansible to run against. The default location for inventory is a file called /etc/ansible/hosts .
How to build your inventory - Ansible Documentation
위 공식문서를 보고 참고해서
ansible-inventory
에 정리했다
그러면 아래같이 트리구조로 inventory 정리가능
 
children, vars, hosts, all 같은 예약어만 몇개 알아두면 되는 문법 자체는 어렵지 않다
 
 
 
notion image
사실 35줄을 43줄로 늘였긴 했지만 가독성이 yaml 이 좋으니 뭐 흠흠
 
 
 
 
 
 
 
 

Recommendations