카테고리 없음
YAML with AWX : Debug for ansible_facts
거나미스
2019. 1. 2. 11:19
반응형
- Yaml에서 ansible_facts를 사용하기 위해 어떤 것들이 지원되는지 알아보기 위한 샘플 코드
- #debugtest.yml 파일 생성
---
- name: debug Test
hosts: all
tasks:
- name: debug testing
shell: echo "debug test"
- debug: var=ansible_facts- 들여쓰기 등 주의
- 아래 이미지와 같이 생성 후 저장
- #ansible-playbook -i hosts.inv debugtest.yml
- 중간 생략
- -
- Yaml에서 ['os_family']를 확인할 경우
tasks: - shell: echo "only on Red Hat 6, derivatives, and later" when: ansible_facts['os_family'] == "RedHat" and ansible_facts['lsb']['major_release']|int >= 6
의 형태로 사용 가능
- 자세한 내용을 알고 싶을 경우 stdout을 파일로 받아서 확인
- #ansible-playbook -i hosts.inv debugtest.yml > out.txt
- #cat out.txt
- -
- 목표
- ansible_fact에서 사용가능한 종류 확인