ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 430 - DOP-C01 discussion

Report
Export

When specifying more than one conditional requirements for a task, what is the proper method?

A.
- when: foo == "hello" and bar == "world"
Answers
A.
- when: foo == "hello" and bar == "world"
B.
- when: foo == "hello" - when: bar == "world"
Answers
B.
- when: foo == "hello" - when: bar == "world"
C.
- when: foo == "hello" && bar == "world"
Answers
C.
- when: foo == "hello" && bar == "world"
D.
- when: foo is "hello" and bar is "world"
Answers
D.
- when: foo is "hello" and bar is "world"
Suggested answer: A

Explanation:

Ansible will allow you to stack conditionals using ‘and’ and ‘or’. It requires it to be in the same ‘when’ statement, comparisons must be ‘==’ for equals or ‘!=’ for not equals and the ‘and/or’ must be written as such, not ‘&&/||’.

Reference: http://docs.ansible.com/ansible/playbooks_conditionals.html#the-when-statement

asked 16/09/2024
Sam Krupesh
38 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first