ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 424 - DOP-C01 discussion

Report
Export

If designing a single playbook to run across multiple Linux distributions that have distribution specific commands, what would be the best method to allow a successful run?

A.
Enable fact gathering and use the `when' conditional to match the distribution to the task.
Answers
A.
Enable fact gathering and use the `when' conditional to match the distribution to the task.
B.
This is not possible, a separate playbook for each target Linux distribution is required.
Answers
B.
This is not possible, a separate playbook for each target Linux distribution is required.
C.
Use `ignore_errors: true' in the tasks.
Answers
C.
Use `ignore_errors: true' in the tasks.
D.
Use the `shell' module to write your own checks for each command that is ran.
Answers
D.
Use the `shell' module to write your own checks for each command that is ran.
Suggested answer: A

Explanation:

Ansible provides a method to only run a task when a condition is met using the `when' declarative. With gather facts enabled, the play has access to the distribution name of the Linux system, thus, tasks can be tailored to a specific distribution and ran only when the condition is met, e.g.: ` - when: ansible_os_family == "Debian"'.

Reference: http://docs.ansible.com/ansible/playbooks_conditionals.html

asked 16/09/2024
saiming wong
37 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first