Interview Prep/Ansible/Fundamentals and Architecture

What is the `raw` module and when do you use it?

IntermediateConceptFundamentals and Architecture
Answer

raw sends a command straight over SSH with no module payload, so it does not need Python on the target. It is not idempotent and has no changed detection.

Use it for bootstrapping (installing Python) and for devices that cannot run modules, such as some routers.

- name: Bootstrap Python
  hosts: new_servers
  gather_facts: false
  become: true
  tasks:
    - ansible.builtin.raw: test -e /usr/bin/python3 || (apt-get update && apt-get install -y python3)
      changed_when: false

gather_facts: false matters here, since fact gathering itself needs Python.

All Ansible questions Roadmap: Ansible

More on Fundamentals and Architecture