2015-05-08 8 views

risposta

112

Dal ansible docs: Se non è stata impostata una variabile desiderata, è possibile saltare o fallire usando Jinja2 di definito test. Per esempio:

tasks: 

- shell: echo "I've got '{{ foo }}' and am not afraid to use it!" 
    when: foo is defined 

- fail: msg="Bailing out. this play requires 'bar'" 
    when: bar is not defined 

Quindi nel tuo caso, when: deployed_revision is not defined dovrebbe funzionare

+3

grazie questo ha lavorato per me 'quando: deployed_revision non è definito o deployed_revision.stdout non è definito o deployed_revision.stdout == ''' – sakhunzai

+3

Puoi anche combinarlo con condizioni diverse: 'quando: item.sudo è definito e item.sudo == true' – czerasz

+2

Non fare quello che ho fatto e mettere parentesi graffe attorno al foo in' when: foo is defined' (es. questo non funziona: 'quando: {{foo}} è definito' – David

Problemi correlati