copy module
The module that puts a file on a host, either copied from the control node or written from content given in the task.
In more detail
It compares the existing file's content and permissions with what you asked for and writes only if they differ, so a repeat run reports ok. Its dest argument names the file to write, and content supplies the text directly. For text that needs variables filled in, use the template module instead.
Example
ansible.builtin.copy:
content: "enabled\n"
dest: app.confRelated terms
- file module — The module that makes sure a file, directory or link exists or is absent, with the owner and permissions you ask for.
- template module — The module that fills in a Jinja template with variables and writes the result to a file on each host.
- idempotency — The property of an operation that gives the same result whether you run it once or many times, because a repeat run finds nothing left to do.
- check mode — A rehearsal run that asks each module what it would change and stops before changing anything.
Taught in
- Writing Your First Playbook — Ansible Configuration Management at Scale
- Modules And Idempotency — Ansible Configuration Management at Scale
- Check Mode And Diff — Ansible Configuration Management at Scale
- Handlers And Notify — Ansible Configuration Management at Scale
- Error Handling With Block, Rescue And Always — Ansible Configuration Management at Scale
- Graded On A Machine You Never Touched — RHCE in Ansible (EX294): Automate Red Hat Systems
- Exam Strategy: The First Fifteen Minutes And ansible-doc — RHCE in Ansible (EX294): Automate Red Hat Systems
- SSH Keys And An Account For Ansible — RHCE in Ansible (EX294): Automate Red Hat Systems
- Privilege Escalation: sudo Rules And become — RHCE in Ansible (EX294): Automate Red Hat Systems
- Anatomy Of A Playbook: Plays, Tasks And Modules — RHCE in Ansible (EX294): Automate Red Hat Systems
- Variables And Where They Win: group_vars, host_vars And Play Vars — RHCE in Ansible (EX294): Automate Red Hat Systems
- Facts And Magic Variables: Let Each Node Describe Itself — RHCE in Ansible (EX294): Automate Red Hat Systems
- Deploying Files: file, copy, lineinfile And blockinfile — RHCE in Ansible (EX294): Automate Red Hat Systems
- Handlers And Failure: notify, block, rescue And always — RHCE in Ansible (EX294): Automate Red Hat Systems
- Roles: The Directory Ansible Expects, Defaults And Handlers — RHCE in Ansible (EX294): Automate Red Hat Systems
- Archives: archive And unarchive On The Managed Nodes — RHCE in Ansible (EX294): Automate Red Hat Systems
- Ansible Vault: Secrets Encrypted, Runs Without A Prompt — RHCE in Ansible (EX294): Automate Red Hat Systems
- Drill: A Web Node From A Ticket — RHCE in Ansible (EX294): Automate Red Hat Systems
- Drill: People, Passwords And sudo From The Vault — RHCE in Ansible (EX294): Automate Red Hat Systems