2016-08-31 3 views
0

우리는 나는 다음과 같은 snipplet을 실행 할 수 있었다이 구조Ansible 재귀 검사

존 사양 https://gist.github.com/git001/9230f041aaa34d22ec82eb17d444550c

을 통해 갈 필요하지만 지금은 오류 검사에서 stucked입니다.

각본

-- 
- hosts: all 
    gather_facts: no 

    vars_files: 
    - "../doc/application-zone-spec.yml" 

    roles: 
    - { role: ingress_add, customers: "{{ application_zone_spec }}" } 

역할 ansible 실행

https://gist.github.com/git001/dab97d7d12a53edfcf2a69647ad543b7

문제의 출력은 내가 유입 항목을 통해 갈 필요가 내가 필요가있다

- name: check if router exists 
    shell: "oc get dc -n default {{ customers.zone_name }}-{{ item.type }}" 
    with_items: "{{ customers.ingress }}" 
    ignore_errors: True 
    register: check_router 

- name: Print ingress hostnames 
    debug: var=check_router 

- name: create new router 
    shell: "echo 'I will create a router'" 
    with_items: "{{ customers.ingress }}" 
    when: check_router.rc == 1 

differnt 유형의 오류를 "check_router" 등록.

뭔가를 만드는 것이 좋을 것 같습니다.

의사 코드.

Iterate through the "customers.ingress" 
    check in "check_router" if the rc is ! 0 
    execute command. 

을 사용합니다.

ansible-playbook --version 
ansible-playbook 2.1.0.0 
    config file = /etc/ansible/ansible.cfg 
    configured module search path = Default w/o overrides 

답변

0

당신과 함께 두 번째 루프를 대체 할 수있다 :이 check_route 루프의 모든 단계를 반복합니다

- name: create new router 
    shell: "echo 'I will create a router with type {{ item.item }}'" 
    with_items: "{{ check_router.results }}" 
    when: item.rc == 1 

을 당신은 item.item를 통해 원래 항목에 액세스 할 수 있습니다.

+0

감사합니다. 콘스탄틴. 이 작동합니다. – Aleksandar