0
I 오류를 던지고되지 다음 코드를 가지고 있지만 사실은 여기 ansible 구문 분석 여분의 var에 사용하는 기본 정규식이 실패 할 경우
- shell: echo '{{ p }}'
register: results
- debug:
var: results
- set_fact:
myrepo: "{{ results.stdout | regex_search(regexp,'\\1') | default ({'0':'global'}) }}"
vars:
regexp: '(.*)/(.*)'
이 명령은 출력
TASK [command] **************************************************************************************************************************************************************************************
changed: [localhost]
TASK [debug] ****************************************************************************************************************************************************************************************
ok: [localhost] => {
"results": {
"changed": true,
"cmd": "echo 'tim'",
"delta": "0:00:00.095831",
"end": "2017-09-06 16:37:19.977023",
"rc": 0,
"start": "2017-09-06 16:37:19.881192",
"stderr": "",
"stderr_lines": [],
"stdout": "tim",
"stdout_lines": [
"tim"
]
}
}
TASK [set_fact] *************************************************************************************************************************************************************************************
ok: [localhost]
TASK [debug] ****************************************************************************************************************************************************************************************
ok: [localhost] => {
"myrepo": ""
}
입니다 비어 ansible-playbook -i hosts -c local file.yml --extra-vars "p=tim"
정규 표현식 결과가 비어있는 경우 myrepo가 global
이됩니다.