Ansible 정리 - variable
- 1 minutes read - 63 wordsvariables in playbook
hosts:localhost
vars: # variable 선언
dns_server: 10.1.1.10
tasks:
- lineinfile:
path: /etc/resolv.conf
line: 'nameserver {{ dns_server }}' # variable 사용
variable을 저장하는 파일을 따로 만들 수도 있음, 또는 invertory file에다가 선언도 가능
web http_port=8081 snmp_port=161-162
http_port: 8081
snmp_port: 161-162
variable 사용법
source: {{ snmp_port }} <== 이건 안됨 soruce: ‘{{ snmp_port }}’ <== 가능 soruce: aaaa{{ snmp_port }}bbbb <== 가능