1
조건부로 Anonymous 역할을 실행하고 싶습니다. 즉, 일부 바이너리가 존재하지 않는 경우에만 (특정 앱 설치가 없다는 것을 의미합니다).조건부 역할 포함이 불안정합니다.
사용 패턴과 같은 것 here.
내 작전에 다음 코드를 사용 :
PLAY ***************************************************************************
TASK [setup] *******************************************************************
ok: [my_host ]
TASK [ myconditional_role : create temporary installation directory] ***********************
fatal: [my_host]: FAILED! => {"failed": true, "msg": "ERROR! The conditional check 'myapp_exists|failed' failed. The error was: ERROR! |failed expects a dictionary"}
왜 조건 검사가 실패 :
여기
- hosts: my_host
tasks:
- name: check app existence
command: /opt/my_app/somebinary
register: myapp_exists
ignore_errors: yes
roles:
- { role: myconditional_role, when: myapp_exists|failed }
- another_role_to_be_included_either_way
출력입니까?
BTW
Ubuntu 16.04.01
에 ansible 2.0.0.2
사용 : "임시 설치 디렉토리를 생성"을 조건부로 포함 역할의 첫 번째 주요 업무의 이름입니다.
그렇다면 특정 사용 사례에 대한 조건부 역할 포함을위한 제안 된 패턴은 무엇입니까? – pkaramol
역할의 main.yml 작업 파일 내부에서 테스트를 이동하고 필요할 경우 install.yml을 포함합니다. –