ansible role은 ansible task의 공유와 재사용을 가능하게 해준다.
작업 수행에 필요한 모든 지원 가능한 파일, 변수, 템플릿, 핸들러가 Playbook 작업이 포함됩니다.
role은 재사용 및 공유 할 수있는 완전한 자동화 단위입니다.
role은 워크플로우를 자동화하는데 필요한 모든 파일, 변수, 핸들러, Jinja 템플릿 및 작업을 포함하는 디렉토리 구조입니다.
README.md defaults/ main.yml files/ handlers/ main.yml meta/ main.yml tasks/ main.yml templates/ tests/ inventory test.yml vars/ main.yml |
ansible-galaxy 명령어를 이용해서 test-role-1이라는 role template을 생성하는 방법입니다.
[ansible@1ff25a8ed818 test_role]$ ansible-galaxy init test-role-1 - test-role-1 was created successfully [ansible@1ff25a8ed818 test_role]$ tree . └── test-role-1 ├── defaults │ └── main.yml ├── files ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── README.md ├── tasks │ └── main.yml ├── templates ├── tests │ ├── inventory │ └── test.yml └── vars └── main.yml |
아래 명령으로 ansible-playbook 테스트가 가능하다.
[ansible@1ff25a8ed818 test_role]$ ansible-playbook -i test-role-1/tests/inventory test-role-1/tests/test.yml
# 참고 사이트
https://galaxy.ansible.com/docs/finding/content_types.html#ansible-roles
https://galaxy.ansible.com/docs/contributing/creating_role.html
https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html?highlight=roles&extIdCarryOver=true&sc_cid=701f2000001OH7YAAW
'Tool > ansible' 카테고리의 다른 글
ansible에서 문자열 split 방법 (0) | 2019.03.18 |
---|---|
ansible handler란? (0) | 2019.02.01 |
serial keyword를 이용한 rolling update (0) | 2019.01.29 |
ansible-vault를 이용한 암호화 (0) | 2019.01.29 |
ansible source build (0) | 2019.01.29 |