Ansible Automation Ansible Roles & Galaxy 2 — Questions and Answers
Question 1: What is Ansible Galaxy?
- A community hub for sharing and downloading reusable Ansible roles and collections (Correct answer)
- An Ansible GUI for managing playbooks
- A cloud service for running Ansible remotely
- A testing framework for Ansible roles
Correct answer: A community hub for sharing and downloading reusable Ansible roles and collections
Ansible Galaxy (galaxy.ansible.com) is the official community repository where users share roles and collections for reuse.
Question 2: How do you install a role from Ansible Galaxy?
- ansible-galaxy role install namespace.rolename (Correct answer)
- ansible-galaxy download namespace.rolename
- ansible install-role namespace.rolename
- pip install ansible-role-namespace.rolename
Correct answer: ansible-galaxy role install namespace.rolename
ansible-galaxy role install <namespace.rolename> downloads the role from Galaxy into the configured roles path.
Question 3: What file format is used to define a list of roles and collections to install from Galaxy?
- requirements.yml (Correct answer)
- galaxy.yml
- dependencies.yml
- install.yml
Correct answer: requirements.yml
requirements.yml lists roles and collections with optional version pins that ansible-galaxy install -r processes.
Question 4: Which command installs all roles and collections listed in a requirements.yml file?
- ansible-galaxy install -r requirements.yml (Correct answer)
- ansible-galaxy install requirements.yml
- ansible-galaxy role install --file requirements.yml
- ansible-galaxy apply requirements.yml
Correct answer: ansible-galaxy install -r requirements.yml
The -r flag tells ansible-galaxy to read role and collection dependencies from the specified requirements file.
Question 5: What is an Ansible Collection?
- A packaged bundle of roles, modules, plugins, and playbooks distributed as a single unit (Correct answer)
- A group of inventory hosts
- A set of related playbooks in one directory
- A Galaxy namespace containing only roles
Correct answer: A packaged bundle of roles, modules, plugins, and playbooks distributed as a single unit
A Collection bundles related roles, modules, plugins, and playbooks into a distributable package with a namespace.collection format.
Question 6: What is the default installation path for Galaxy roles on a Linux system?
- ~/.ansible/roles (Correct answer)
- /etc/ansible/roles
- /usr/share/ansible/roles
- /opt/ansible/roles
Correct answer: ~/.ansible/roles
By default, ansible-galaxy installs roles to ~/.ansible/roles in the current user's home directory.
What is Ansible Galaxy?