ν΅μ¬
ansible 2.3.0.0 (stable-2.3 923c9ef17c) last updated 2017/03/17 09:12:40 (GMT +1000)
config file = /apps/dev/playbook/jordan/mr-ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.12 (default, Sep 23 2016, 14:23:49) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
νμ€
RHEL 6.7
μ΄κ²μ λ²κ·Έκ° μλ μλ μμ§λ§ μ΄μ λ²μ μμλ μ κ±°νμ§λ§ Ansible 2.3 RC1μ μ¬μ©νλ©΄ λͺ¨λ (when μ ν¬ν¨)μ μν΄ λ±λ‘ λ λ³μκ° μ μλμ΄ μλμ§ νμΈν λ€μ νμ λμ λ리 κ°μ μ»μ μ μμ΅λλ€. 2.3μμ μ€ν¨νκ³ 2.2 μ΄νμμλ μ μλν©λλ€. μ΄κ²μ νΉν λ³μλ₯Ό λ±λ‘νλ λͺ¨λμ΄ μ΄λ€ μ΄μ λ‘ λ 건λ λ΄ λ€μ νμ μμ μ΄ λ³μκ° μ μλμλμ§ νμΈν λ€μ νμ ν€λ₯Ό κ°μ Έμ¬ λ λ°μν©λλ€.
μμ νλ μ΄ λΆ
---
- name: test
hosts: localhost
connection: local
tasks:
- name: module that won't run
stat:
path: /apps/tmp
register: test
when: False
- name: debug of var
debug:
var: test
- name: test with conditional
debug:
msg: A
when: test is defined and test.stat.exists
Ansible 2.2.1.0μ μ¬μ©νλ κ²½μ°
ansible 2.2.1.0
config file = /cygdrive/d/dev/jordan/ansible.cfg
configured module search path = Default w/o overrides
PLAY [test] ********************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [module that won't run] ***************************************************
task path: /cygdrive/d/dev/jordan/2.3tests.yml:7
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true}
TASK [debug of var] ************************************************************
task path: /cygdrive/d/dev/jordan/2.3tests.yml:13
ok: [localhost] => {
"test": {
"changed": false,
"skip_reason": "Conditional check failed",
"skipped": true
}
}
TASK [test with conditional] ***************************************************
task path: /cygdrive/d/dev/jordan/2.3tests.yml:17
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true}
PLAY RECAP *********************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0
PLAY [test] ************************************************************************************************************************************************************************
TASK [Gathering Facts] *************************************************************************************************************************************************************
Friday 17 March 2017 15:20:42 +1000 (0:00:00.039) 0:00:00.039 **********
ok: [localhost]
META: ran handlers
TASK [module that won't run] *******************************************************************************************************************************************************
task path: /apps/dev/playbook/jordan/mr-ansible/test.yml:7
Friday 17 March 2017 15:20:44 +1000 (0:00:01.093) 0:00:01.133 **********
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional result was False", "skipped": true}
TASK [debug of var] ****************************************************************************************************************************************************************
task path: /apps/dev/playbook/jordan/mr-ansible/test.yml:13
Friday 17 March 2017 15:20:44 +1000 (0:00:00.012) 0:00:01.145 **********
ok: [localhost] => {
"changed": false,
"test": {
"changed": false,
"skip_reason": "Conditional result was False",
"skipped": true
}
}
TASK [test with conditional] *******************************************************************************************************************************************************
task path: /apps/dev/playbook/jordan/mr-ansible/test.yml:17
Friday 17 March 2017 15:20:44 +1000 (0:00:00.034) 0:00:01.180 **********
fatal: [localhost]: FAILED! => {"failed": true, "msg": "The conditional check 'test is defined and test.stat.exists' failed. The error was: error while evaluating conditional (test is defined and test.stat.exists): 'dict object' has no attribute 'stat'\n\nThe error appears to have been in '/apps/dev/playbook/jordan/mr-ansible/test.yml': line 17, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: test with conditional\n ^ here\n"}
PLAY RECAP *************************************************************************************************************************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=1
μλ νμΈμ!
Ansibleμ μ μΆν΄ μ£Όμ μ κ°μ¬ν©λλ€. κ·Έκ²μ μ§μ¬μΌλ‘ μ°λ¦¬μκ² λ§μ κ²μ μλ―Έν©λλ€.
ν κ°μ§κ° λͺ μλ κ²κ³Ό μ½κ° λ€λ₯΄κ² μλνκΈ° λλ¬Έμ κ·νκ° μ μΆ ν ν°μΌμ΄ λ€μ μ€ν΄λκ³ μλ€κ³ μκ°ν©λλ€.
μμΌλ‘ μ΄κ²μ μ¬μ©μ λͺ©λ‘μ λ μ ν©ν μ£Όμ κ° λ μ μμΌλ©°, μμ κ΄λ ¨νμ¬ λ λ§μ λμμ΄ νμν κ²½μ° μ¬κΈ°μ κ²μ ν μλ μμ΅λλ€.
'stat'μμ
μ 건λ λ°κΈ° λλ¬Έμ μ μ λ μ¬μ μΌλ‘ test
κ° νμλμ§λ§ stat
ν€κ° μκΈ° λλ¬Έμ CORRECT μ€λ₯ λ©μμ§κ° νμλ©λλ€. μ΄μ κ°μ λ¬Έμ λ₯Ό λ°©μ§νλ €λ©΄ λ€μμ΄ νμν©λλ€.
when: test is defined and 'stat' in test and test.stat.exists
Ansibleμ λν κ΄μ¬κ³Ό κ΄μ¬μ λ€μ ν λ² κ°μ¬λ립λλ€!
μ΄ λμμ λ³κ²½ ν μ»€λ° μλΆ https://github.com/ansible/ansible/commit/81aa12eb1b5a2b50ac9234ca0b05c015af88a845
κ΄λ ¨ λ¬Έμ https://github.com/ansible/ansible/issues/18514
κ°μ₯ μ μ©ν λκΈ
κ°λ₯ν μ€ν΄
μλ νμΈμ!
Ansibleμ μ μΆν΄ μ£Όμ μ κ°μ¬ν©λλ€. κ·Έκ²μ μ§μ¬μΌλ‘ μ°λ¦¬μκ² λ§μ κ²μ μλ―Έν©λλ€.
ν κ°μ§κ° λͺ μλ κ²κ³Ό μ½κ° λ€λ₯΄κ² μλνκΈ° λλ¬Έμ κ·νκ° μ μΆ ν ν°μΌμ΄ λ€μ μ€ν΄λκ³ μλ€κ³ μκ°ν©λλ€.
μμΌλ‘ μ΄κ²μ μ¬μ©μ λͺ©λ‘μ λ μ ν©ν μ£Όμ κ° λ μ μμΌλ©°, μμ κ΄λ ¨νμ¬ λ λ§μ λμμ΄ νμν κ²½μ° μ¬κΈ°μ κ²μ ν μλ μμ΅λλ€.
'stat'μμ μ 건λ λ°κΈ° λλ¬Έμ μ μ λ μ¬μ μΌλ‘
test
κ° νμλμ§λ§stat
ν€κ° μκΈ° λλ¬Έμ CORRECT μ€λ₯ λ©μμ§κ° νμλ©λλ€. μ΄μ κ°μ λ¬Έμ λ₯Ό λ°©μ§νλ €λ©΄ λ€μμ΄ νμν©λλ€.Ansibleμ λν κ΄μ¬κ³Ό κ΄μ¬μ λ€μ ν λ² κ°μ¬λ립λλ€!