300-910 · Question #103
300-910 Question #103: Real Exam Question with Answer & Explanation
This question tests knowledge of writing an Ansible playbook that uses the community.general.docker_container module to deploy a named Docker container from a specific Docker Hub image. It requires understanding correct Ansible module names, Docker image tag syntax, and playbook
Question
Drag and Drop Question A DevOps engineer is constructing an Ansible playbook to deploy a containerized application via Docker. This playbook must conform to these requirements: - Run against the production_hosts group of hosts as defined in the Ansible inventory file. - Must pull the latest my application Docker image from the my_repository registry on the Docker Hub registry. - Must give the container a name of my_container. Drag and drop the code snippets from the bottom onto the boxes in the code to construct an Ansible playbook to fulfill the requirements. Not all options are used. ```yaml --- - name: Deploy container hosts: <BLANK_1> tasks: - name: Update container with latest if necessary <BLANK_2>: name: <BLANK_3> image: <BLANK_4> pull: true state: started ``` Snippets to drag: - `community.general.lxc_container` - `my_repository/my_application:latest` - `community.general.docker_container` - `my_repository/my_application[latest]` - `hosts: production_hosts` - `my_container`
Explanation
This question tests knowledge of writing an Ansible playbook that uses the community.general.docker_container module to deploy a named Docker container from a specific Docker Hub image. It requires understanding correct Ansible module names, Docker image tag syntax, and playbook host targeting.
Approach. BLANK_1 = 'production_hosts': The 'hosts:' key is already present in the template, so only the inventory group name fills the blank. BLANK_2 = 'community.general.docker_container': This is the correct Ansible module for managing Docker containers; 'community.general.lxc_container' is for Linux Containers (LXC), not Docker. BLANK_3 = 'my_container': The 'name' parameter under the module sets the container's name as required. BLANK_4 = 'my_repository/my_application:latest': Docker Hub image references use the format 'registry/image:tag' with a colon before the tag - 'my_repository/my_application[latest]' uses invalid bracket syntax and would fail. The snippet 'hosts: production_hosts' is a distractor because 'hosts:' is already written in the playbook template.
Concept tested. Ansible playbook structure for Docker container management using the community.general.docker_container module, including correct Docker image tag syntax (colon notation) and proper host group targeting from an Ansible inventory.
Reference. Ansible community.general.docker_container module documentation: https://docs.ansible.com/ansible/latest/collections/community/general/docker_container_module.html
Topics
Community Discussion
No community discussion yet for this question.