perform ansible task with variable undefines

0 votes
How do I run an Ansible Task when my variables are undefined?
Feb 4, 2019 in Ansible by Laksha
539 views

1 answer to this question.

0 votes

Hey @Laksha,

If a variable has not been set, you can skip or fail using Jinja2’s defined test. For example:

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

So in your case, when: deployed_revision is not defined should work

answered Feb 4, 2019 by Anushri

Related Questions In Ansible

0 votes
1 answer

Error message saying variable undefines - Ansible

Hey @Karthik, you don't really have to ...READ MORE

answered Feb 9, 2019 in Ansible by Monish
921 views
0 votes
1 answer

How to use Ansible git module pull a branch with local changes?

You cannot achieve it using the git ...READ MORE

answered Jul 9, 2018 in Ansible by Atul
• 10,240 points
7,055 views
0 votes
1 answer

Ansible iterate over hash with condition

Your when statement is wrong. you either split ...READ MORE

answered Jul 23, 2018 in Ansible by Kalgi
• 52,350 points
1,373 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,036 views
+2 votes
1 answer
0 votes
2 answers

Issue creating AWS VPC with Ansible

You can use the details given in ...READ MORE

answered Aug 16, 2018 in Ansible by Priyaj
• 58,020 points
1,263 views
0 votes
1 answer

What all can I do with Ansible?

Ansible is capable of doing a lot ...READ MORE

answered Jan 8, 2019 in Ansible by Takeshi
844 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP