CtrlK
BlogDocsLog inGet started
Tessl Logo

pantheon-ai/ansible-validator

Comprehensive toolkit for validating, linting, testing, and automating Ansible playbooks, roles, and collections. Use this skill when working with Ansible files (.yml, .yaml playbooks, roles, inventories), validating automation code, debugging playbook execution, performing dry-run testing with check mode, or working with custom modules and collections.

Overall
score

93%

Does it follow best practices?

Validation for skill structure

Overview
Skills
Evals
Files

module_alternatives.mdreferences/

Ansible Module Alternatives

Overview

This guide provides replacement alternatives for deprecated or legacy Ansible modules. Use this reference when ansible-lint reports deprecated module warnings or when updating older playbooks to modern best practices.

Quick Detection

Use the FQCN checker script to automatically detect non-FQCN module usage:

# Scan a playbook
bash scripts/check_fqcn.sh playbook.yml

# Scan a role
bash scripts/check_fqcn.sh roles/webserver/

# Scan entire directory
bash scripts/check_fqcn.sh .

The script identifies modules using short names and provides specific FQCN migration recommendations.

Deprecated Modules and Replacements

Package Management

Deprecated ModuleReplacementNotes
apt (short name)ansible.builtin.aptUse FQCN for clarity
yum (short name)ansible.builtin.yum or ansible.builtin.dnfdnf preferred for RHEL 8+
pip (short name)ansible.builtin.pipUse FQCN
easy_installansible.builtin.pipeasy_install is deprecated in Python
homebrewcommunity.general.homebrewMoved to community.general
zyppercommunity.general.zypperMoved to community.general
apkcommunity.general.apkMoved to community.general

File Operations

Deprecated ModuleReplacementNotes
copy (short name)ansible.builtin.copyUse FQCN
file (short name)ansible.builtin.fileUse FQCN
template (short name)ansible.builtin.templateUse FQCN
lineinfile (short name)ansible.builtin.lineinfileUse FQCN
blockinfile (short name)ansible.builtin.blockinfileUse FQCN
synchronizeansible.posix.synchronizeMoved to ansible.posix
aclansible.posix.aclMoved to ansible.posix

Service Management

Deprecated ModuleReplacementNotes
service (short name)ansible.builtin.service or ansible.builtin.systemdUse systemd for systemd-based systems
systemd (short name)ansible.builtin.systemdUse FQCN
sysvinitansible.builtin.serviceservice module handles sysvinit

User and Group Management

Deprecated ModuleReplacementNotes
user (short name)ansible.builtin.userUse FQCN
group (short name)ansible.builtin.groupUse FQCN
authorized_key (short name)ansible.posix.authorized_keyMoved to ansible.posix

Networking

Deprecated ModuleReplacementNotes
get_url (short name)ansible.builtin.get_urlUse FQCN
uri (short name)ansible.builtin.uriUse FQCN
iptablesansible.builtin.iptablesUse FQCN
ufwcommunity.general.ufwMoved to community.general
firewalldansible.posix.firewalldMoved to ansible.posix

Command Execution

Deprecated ModuleReplacementNotes
command (short name)ansible.builtin.commandUse FQCN; prefer specific modules
shell (short name)ansible.builtin.shellUse FQCN; prefer specific modules
raw (short name)ansible.builtin.rawUse FQCN; use only when necessary
script (short name)ansible.builtin.scriptUse FQCN

Cloud Providers

Deprecated ModuleReplacementNotes
ec2amazon.aws.ec2_instanceUse amazon.aws collection
ec2_amiamazon.aws.ec2_amiUse amazon.aws collection
ec2_vpcamazon.aws.ec2_vpc_netUse amazon.aws collection
azure_rm_*azure.azcollection.*Use azure.azcollection
gcp_*google.cloud.*Use google.cloud collection
docker_containercommunity.docker.docker_containerUse community.docker collection
docker_imagecommunity.docker.docker_imageUse community.docker collection

Database

Deprecated ModuleReplacementNotes
mysql_dbcommunity.mysql.mysql_dbUse community.mysql collection
mysql_usercommunity.mysql.mysql_userUse community.mysql collection
postgresql_dbcommunity.postgresql.postgresql_dbUse community.postgresql collection
postgresql_usercommunity.postgresql.postgresql_userUse community.postgresql collection
mongodb_*community.mongodb.*Use community.mongodb collection

Monitoring and Logging

Deprecated ModuleReplacementNotes
nagioscommunity.general.nagiosUse community.general collection
zabbix_*community.zabbix.*Use community.zabbix collection

FQCN Migration

Why Use Fully Qualified Collection Names (FQCN)?

  1. Clarity: Explicitly shows which collection provides the module
  2. Conflict Prevention: Avoids naming conflicts between collections
  3. Future-Proofing: Prevents breakage when modules move between collections
  4. Best Practice: Recommended by Ansible for all new playbooks

Migration Examples

# Old style (deprecated)
- name: Install nginx
  apt:
    name: nginx
    state: present

# New style (recommended)
- name: Install nginx
  ansible.builtin.apt:
    name: nginx
    state: present
# Old style (deprecated)
- name: Configure firewall
  ufw:
    rule: allow
    port: '443'

# New style (recommended)
- name: Configure firewall
  community.general.ufw:
    rule: allow
    port: '443'

Installing Required Collections

When migrating to FQCN modules, ensure the required collections are installed:

# Install common collections
ansible-galaxy collection install ansible.posix
ansible-galaxy collection install community.general
ansible-galaxy collection install community.docker
ansible-galaxy collection install community.mysql
ansible-galaxy collection install community.postgresql
ansible-galaxy collection install amazon.aws
ansible-galaxy collection install azure.azcollection
ansible-galaxy collection install google.cloud

Or create a requirements.yml:

---
collections:
  - name: ansible.posix
    version: ">=1.5.0"
  - name: community.general
    version: ">=6.0.0"
  - name: community.docker
    version: ">=3.0.0"
  - name: community.mysql
    version: ">=3.0.0"
  - name: community.postgresql
    version: ">=2.0.0"

Then install with:

ansible-galaxy collection install -r requirements.yml

Checking for Deprecated Modules

Use ansible-lint to identify deprecated modules in your playbooks:

# Check for deprecated module usage
ansible-lint --profile production playbook.yml

# Show rule documentation for deprecated modules
ansible-lint -L | grep deprecated

Version Compatibility Notes

  • Ansible 2.9: Last version with many modules in ansible.builtin
  • Ansible 2.10+: Collections separated from core
  • Ansible 2.12+: Many deprecated modules removed from core
  • Ansible 2.14+: FQCN strongly recommended for all modules

Resources

  • Ansible Collections Index
  • Ansible Changelog
  • Community Collections
  • ansible-lint Rules

Install with Tessl CLI

npx tessl i pantheon-ai/ansible-validator@0.1.0

SKILL.md

tile.json