Ansible Role files
This role manages file system entities such as files, directories and symlinks.
Runs on
RHEL 8 (and compatible)
Optional Requirements
It is recommeded to set
inventory_ignore_patterns = '(host|group)_files'
in youransible.cfg
on the Ansible Controller to ignore files ininventory_dir/host_files
.
Optional Role Variables
Variable |
Description |
Default Value |
---|---|---|
|
List of dictionaries containing the directories to manage. Subkeys:
|
|
|
List of dictionaries containing the files to manage. Subkeys:
|
|
|
List of dictionaries the symlinks to manage. Subkeys:
|
|
Example:
# optional
files__directories__host_var:
- path: '/data/a'
- path: '/data/b'
mode: 0o770
- path: '/data/b/c'
owner: 'apache'
files__files__host_var:
- path: '/data/file1'
content: |-
echo "a script with
multiple lines"
mode: 0o755
- path: '/data/file2' # content will be taken from `inventory_dir/host_files/inventory_hostname/data/file3`
- path: '/data/file3'
state: 'absent'
files__symlinks__host_var:
- src: '/data/file1'
dest: '/data/file1_link'