AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 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 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", 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 troubleshooting - Error no-prompting

By Luca Berton · Published 2024-01-01 · Category: troubleshooting

Here's an example of problematic code in an Ansible playbook, including user prompts and a 5-minute pause, which violates best practices and can be corrected.

Ansible troubleshooting - Error no-prompting

Avoid Unnecessary Prompting and Pausing in Ansible Playbooks

Ansible is a powerful automation tool designed to simplify complex IT tasks. While it's excellent for handling various configurations and deployments, it's important to create playbooks that can run unattended, particularly in Continuous Integration/Continuous Deployment (CI/CD) pipelines. This article discusses the Ansible playbook error "no-prompting," which helps ensure that your playbooks are suitable for automated, unattended execution.

See also: Ansible troubleshooting - Error: no-jinja-when

The Challenge: Prompts and Pauses

Sometimes, playbooks include user prompts or unnecessary pauses. While these may be useful for manual interventions in some situations, they can become obstacles when you want your playbooks to execute automatically.

For instance, consider a playbook that asks for user credentials via vars_prompt and includes tasks like ansible.builtin.pause to create wait times. In a CI/CD environment, these prompts and pauses can lead to stalled automation pipelines.

The Solution: no-prompting Rule

To prevent these issues, Ansible provides the no-prompting rule in Ansible-lint. This rule checks playbooks for the presence of vars_prompt or the ansible.builtin.pause module, which are prompts or pauses that can disrupt automation. By enabling this rule, you can identify and rectify any occurrences of these elements in your playbooks.

Enabling the Rule

To use the no-prompting rule, you need to enable it in your Ansible-lint configuration file. Here's an example of how to do it:

enable_list:
  - no-prompting

By adding this rule to your enable list, Ansible-lint will check your playbooks for prompts and pauses, helping you ensure they are suitable for automated execution.

See also: Ansible Troubleshooting: 15 Common Errors and How to Fix Them (2026)

Problematic Code

Here's an example of problematic code in an Ansible playbook:

---
- name: Example playbook
  hosts: all
  vars_prompt:
    - name: username
      prompt: What is your username?
      private: false
    - name: password
      prompt: What is your password?
  tasks:
    - name: Pause for 5 minutes
      ansible.builtin.pause:
        minutes: 5
    - name: Display message
      ansible.builtin.debug:
        msg: "{{ username }}, {{ password }}"

In this code, user prompts for username and password are included using vars_prompt. Additionally, there's a pause task that halts playbook execution for 5 minutes.

Ansible Lint Output

WARNING  Listing 1 violation(s) that are fatal
no-prompting: Play uses vars_prompt
no-prompting.yml:5

Read documentation for instructions on how to ignore specific rule violations.

Rule Violation Summary count tag profile rule associated tags 1 no-prompting opt-in

Failed: 1 failure(s), 0 warning(s) on 1 files. Last profile that met the validation criteria was 'production'. Rating: 5/5 star

Correct Code

The correct code, without the prompting and pausing, would look like this:

---
- name: Example playbook
  hosts: all
  vars:
    username: username
    password: password
  tasks:
    - name: Display message
      ansible.builtin.debug:
        msg: "{{ username }}, {{ password }}"

In the correct code, user prompts and pauses have been removed, making the playbook suitable for unattended execution in automated workflows.

See also: Ansible troubleshooting - Error: name[casing]

Conclusion

The "no-prompting" rule in Ansible-lint is a valuable tool to ensure your Ansible playbooks are automation-friendly. By eliminating user prompts and pauses, you can create playbooks that seamlessly integrate into CI/CD pipelines, improving efficiency and reliability in your automation processes.

the Ansible become reference

Category: troubleshooting

Browse all Ansible tutorials · AnsiblePilot Home