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.
More on Fundamentals and Architecture
What is Ansible and what problem does it solve?BeginnerWhat does "agentless" mean in Ansible?BeginnerWhat are the requirements for the control node?BeginnerWhat does a managed node need?BeginnerIs Ansible push-based or pull-based?BeginnerWalk through what happens when you run `ansible-playbook site.yml`.Intermediate