LOGBOOK

HELP

Quiz Entry - updated: 2026.11.05

What do the ansible.builtin.copy options src, dest, owner, group and mode do, and why write the mode as 0644 (or "0644") rather than 644?

src is a file on the control node (relative paths resolve against the playbook's files/ directory), dest the target path on the managed host, owner/group the ownership, and mode the permissions. The leading zero makes YAML read the number as octal, which is how permissions work; 644 without it is the decimal number 644, which gives completely wrong permissions.

The mode 0644 split into its digits: octal marker, owner 6 = rw, group 4 = r, others 4 = r, plus a table of 0644, 0500 and 0400

* Each octal digit is read 4 + write 2 + execute 1, for owner, group and others. *

- name: Configure web service
  ansible.builtin.copy:
    src: "{{ httpdconf_src }}"     # files/000-default.conf on the control node
    dest: "{{ httpdconf_dest }}"   # path on the managed host
    owner: root
    group: root
    mode: "0644"

How the permission digits work: each octal digit is one set of rights, owner / group / others, each the sum of read 4, write 2, execute 1. So:

Mode Owner Group Others Typical use
0644 rw r r config file anyone may read
0500 r-x none none a directory only its owner may enter (x on a directory = enter)
0400 r none none a secret file only its owner may read

Unquoted 0644 works because YAML 1.1 reads a leading zero as octal. Quoting it ("0644", or even "644") is the safest form, since Ansible then parses the string as octal itself and nothing depends on YAML's number rules. Writing an unquoted 644 gives decimal 644, which is octal 1204: odd, wrong permissions.

Go deeper:

From Quiz: ITIA / Ansible Variables, Secrets and Facts | Updated: Nov 05, 2026