ํ๋ ์ด ๋ถ
ansible 2.4.0
config file = None
configured module search path = [u'/Users/szabop/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /Library/Python/2.7/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.2.1 Compatible Apple LLVM 6.0
๋๋ ์ญํ ์ ๊ฐ์ ธ์ค๊ณ ๋ค๋ฅธ ๋๋ ํ ๋ฆฌ์์ ์ฌ์ํ๋ฏ๋ก ansible.cfg์ ์์ต๋๋ค.
[defaults]
roles_path = ../../../deployment/playbooks/roles
OSX 10.10.5
๊ฐ์ ธ์จ ํ๋ ์ด์ ๋ํด vars_files์ ๋ณ์ (๋จ์ ํ ์คํธ๋ ํ๋ก๋์ ์ํธ๋ฅผ ์ฌ์ฉํด์๋ ์ ๋จ)๋ฅผ ์ฌ์ฉํ์ฌ ๊ฐ์ ธ์ฌ ๋ณผํธ ํ์ผ์ ๋์ ์ผ๋ก ๊ฒฐ์ ํ๋ ค๊ณ ํ ๋ group_vars, host_vars ๋๋ facts๋ฅผ ์ฌ์ฉํ์ฌ ๊ทธ๋ ๊ฒ ํ ์ ์์ต๋๋ค. ์ค์ ํ๋ ์ด์์ ์ค์ ํฉ๋๋ค. ansible ๋ช ๋ น ์ค ์ธ์ ๋ง ์ฌ์ฉํ ์ ์์ต๋๋ค.
ansible-playbook -t app_test -i inventories/localhost/local.hosts unit.yml
---
#
# network.yml
#
- name: Setup the networks
hosts: dockerhosts
vars_files:
- demoVars.yml
- "{{ vault_file }}" # this will only be valid if declared on the ansible command line.
roles:
- role: debug # note this will print out a valid {{ vault_file }} in all cases (but comment out the vars_files line or it will error first)
- role: network_setup
options:
internal: "{{ networks.internal }}"
external: "{{ networks.external }}"
nginx: "{{ networks.nginx }}"
tags:
- setup
- standalone
- app_test
# unit.yml
---
- name: create facts used to compose variables later in this playbook
hosts: dockerhosts
vars:
esTmpDir: "/tmp/es"
roles:
- role: unitenv_setup
tags:
- app_test
- import_playbook: ../../../deployment/playbooks/network.yml
--extra-vars
์ฌ์ฉํ์ฌ ansible ๋ช
๋ น ์ค์ vault_file
๋ณ์๋ฅผ ์ง์ ํ๋ฉด ์คํฌ๋ฆฝํธ๊ฐ ์ ๋๋ก ์คํ๋ฉ๋๋ค. ์ธ๋ฒคํ ๋ฆฌ ํ์ผ์์ vault_file
๊ฐ ์ค์ ๋๊ฑฐ๋ unitenv_setup
ํฉํธ๋ก ์ค์ ๋ ๊ฒฝ์ฐ ์ ๋๋ก ์คํ๋์ด์ผํ์ง๋ง ๊ทธ๋ ์ง ์์ต๋๋ค.
๋ช
๋ น ์ค ์ด์ธ์ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ์ฌ vault_file
๋ฅผ ์ค์ ํ๋ฉด ๋ค์ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
PLAY [Setup the networks] *********************************************************************
ERROR! vars file {{ vault_file }} was not found
๋งค์ฐ ์์ธ ๋ชจ๋ :
ETA: ran handlers
META: ran handlers
Read vars_file 'demoVars.yml'
skipping vars_file '{{ vault_file }}' due to an undefined variable
Read vars_file 'demoVars.yml'
skipping vars_file '{{ vault_file }}' due to an undefined variable
PLAY [Setup the networks] *********************************************************************
Read vars_file 'demoVars.yml'
ERROR! vars file {{ vault_file }} was not found
๋๋ ๋จ์ํ ๊ณต์ ๊ฐ๋ฅํ ๋ณต์ ๋ก ๋ค์ด๊ฐ ์์๋ ๋ด ํ๋ก๋์ ํ๊ฒฝ์ ๋ํด ๋ณต์กํ ๋ฌด์ธ๊ฐ๊ฐ ์๋ค๋ ๊ฒ์ ์๊ณ ์์ต๋๋ค. ์ด์จ๋ , ์ฌ๊ธฐ ์ ์ฌํ
์๋ ํ์ธ์!
Ansible์ ์ ์ถํด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค. ๊ทธ๊ฒ์ ์ง์ฌ์ผ๋ก ์ฐ๋ฆฌ์๊ฒ ๋ง์ ๊ฒ์ ์๋ฏธํฉ๋๋ค.
ํ ๊ฐ์ง๊ฐ ๋ช ์๋ ๊ฒ๊ณผ ์ฝ๊ฐ ๋ค๋ฅด๊ฒ ์๋ํ๊ธฐ ๋๋ฌธ์ ๊ทํ๊ฐ ์ ์ถ ํ ํฐ์ผ์ด ๋ค์ ์คํด๋๊ณ ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
ํฉํธ, ํธ์คํธ ๋ฐ ๊ทธ๋ฃน ๋ณ์ .. ๊ธฐ๋ณธ์ ์ผ๋ก ๋ชจ๋ 'ํธ์คํธ ๊ด๋ จ ๋ณ์'๋ vars_files
์ ์ฌ์ฉํ ์ ์์ผ๋ฉฐ ํด๋น ์์ ์์ ์ฌ์ ๋ฒ์ ๋ณ์ ๋๋ ์ถ๊ฐ ๋ณ์ ๋ง ์ฌ์ฉํ ์ ์์ต๋๋ค. ๋์ include_vars
์์
์ ์ฌ์ฉํ์ธ์.
์์ผ๋ก ์ด๊ฒ์ ์ฌ์ฉ์ ๋ชฉ๋ก์ ๋ ์ ํฉํ ์ฃผ์ ๊ฐ ๋ ์ ์์ผ๋ฉฐ, ์์ ๊ด๋ จํ์ฌ ๋ ๋ง์ ๋์์ด ํ์ํ ๊ฒฝ์ฐ ์ฌ๊ธฐ์ ๊ฒ์ ํ ์๋ ์์ต๋๋ค.
Ansible์ ๋ํ ๊ด์ฌ๊ณผ ๊ด์ฌ์ ๋ค์ ํ ๋ฒ ๊ฐ์ฌ๋๋ฆฝ๋๋ค!
๋ฌธ์๋ฅผ ์์ ํด์ผํ ๊น์? ๋ช ํํ์ง ์์ต๋๋ค ...
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋ฌธ์๋ฅผ ์์ ํด์ผํ ๊น์? ๋ช ํํ์ง ์์ต๋๋ค ...