DevOps / Ansible Interview questions
What is a module in Ansible?
A module is a self-contained, reusable unit of code that performs one specific piece of work, such as installing a package, copying a file, or creating a cloud resource. Tasks in a playbook are really just calls to a module with a set of arguments.
- name: Ensure a config file is present ansible.builtin.copy: src: app.conf dest: /etc/app/app.conf mode: '0644'
Modules are designed to be idempotent: the copy module above checks whether the destination file already matches the source before making any change, so running the same task repeatedly only reports a change the first time. Ansible ships hundreds of built-in modules under the ansible.builtin collection, and thousands more are available through community and vendor-published collections for things like cloud infrastructure, network devices, and container platforms.
More Related questions...