Member-only story

Ansible troubleshooting — Error 303: command-instead-of-module

How to Solve the Ansible Error 303 command-instead-of-module Enhancing Ansible Playbooks

Luca Berton
4 min readNov 1, 2023

Introduction

In the world of Ansible automation, best practices and efficiency are paramount. Ansible-Lint, a popular linting tool for Ansible playbooks, comes with a variety of rules to help you follow best practices, maintain consistency, and avoid common pitfalls. One such rule, Rule 303, “command-instead-of-module,” recommends using specific Ansible modules in place of commands for tasks where modules are a more reliable and feature-rich choice.

Understanding Rule 303

Rule 303, “command-instead-of-module,” serves as a friendly reminder that, in many cases, using Ansible modules is a better approach than running raw shell commands. Modules provide various benefits, including improved reliability, better messaging, and additional features like retry capabilities. By adhering to this rule, you can enhance the quality and maintainability of your Ansible playbooks.

Problematic Code

Let’s examine a common issue that Rule 303 can help identify in your playbooks:

---
- name: Update apt cache
hosts: all
tasks…

--

--

Luca Berton
Luca Berton

Written by Luca Berton

I help creative Automation DevOps, Cloud Engineer, System Administrator, and IT Professional to succeed with Ansible Technology to automate more things everyday

No responses yet