AnsiblePilot — Master Ansible Automation
AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,100 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.
Popular Topics
About Luca Berton
Luca Berton is an Ansible automation expert, author of "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example" published by Apress, and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.
Ansible ansible.builtin vs ansible.legacy: Collection Namespaces Explained — Video Tutorial
Understand ansible.builtin vs ansible.legacy namespaces. Learn when to use FQCN, how module resolution works, and migrate to fully qualified collection names.
What You'll Learn
- What is ansible.builtin collection?
- What is ansible.legacy collection?
- Links
- Demo
- common code
- ansible.builtin code
- ansible.builtin execution
- ansible.legacy code
- ansible.legacy execution
- ansible.vanilla code
Full Tutorial Content
What is the "ansible.builtin" Ansible collection? What is the "ansible.legacy" collection?
Today we're going to talk about Ansible's most essential modules and plugins and how we can use them in our everyday Playbook.
I'm Luca Berton, Ansible Automation Expert, and welcome to today's lesson.
What is ansible.builtin collection?
The "ansible.builtin" collection refers to modules & plugins shipped with ansible-core.
Technically is a synthetic collection, virtually constructed by the core engine.
What is ansible.legacy collection?
The "ansible.legacy" collection is a superset of "ansible.builtin" with 'custom' plugins in the configured paths and adjacent directories. We use the "ansible.legacy" when we don't specify any Ansible collection in our playbook.
Technically is a synthetic collection, virtually constructed by the core engine.
Links
- https://docs.ansible.com/ansible/latest/reference_appendices/faq.html#what-is-the-difference-between-ansible-legacy-and-ansible-builtin-collections
- https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-action-plugin-path
Demo
Live Playbook about "ansible.builtin" vs. "ansible.legacy" collections.
Let's jump in a quick Playbook to demonstrate the difference between the "ansible.builtin" vs. "ansible.legacy" collections.
I'm going to create a custom "debug" module that prints the extra text "foo" when used with the "msg" parameter.
Let's see the different results when we execute with "ansible.builtin", "ansible.legacy" or without specifying any collections.
The code is the following.
common code
- inventory (localhost)
```ini
localhost ansible_connection=local
```
- ansible.cfg
```ini
[defaults]
action_plugins = plugins/action
```
- plugins/action/debug.py
```python
Copyright 2012, Dag Wieers
Copyright 2016, Toshio Kuratomi
This file is part of Ansible
Ansible is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Ansible is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Ansible. If not, see .
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible.errors import AnsibleUndefinedVariable
from ansible.module_utils.six import string_types
from ansible.module_utils._text import to_text
from ansible.plugins.action import ActionBase
class ActionModule(ActionBase):
''' Print statements during execution '''
TRANSFERS_FILES = False
_VALID_ARGS = frozenset(('msg', 'var', 'verbosity'))
def run(self, tmp=None, task_vars=None):
if
About This Tutorial
- Author: Luca Berton
- Difficulty: Advanced
- Read time: 8 min
- Category: installation
Read the full written article: Ansible ansible.builtin vs ansible.legacy: Collection Namespaces Explained