copy

Copy files.

Parameters

Parameter

Type

Comments

path

string required

Path to file.

copyfile

dict required

copyfile parameters (see tasks/files-copy.yml)

path

string required

Path of the source file.

remote_src

string

Source file from remote.

force

boolean

If no, transfer if dest does not exist.

<TBD>

owner

string

Owner of the file.

group

string

Group of the file.

mode

string

Mode of the file.

attributes

string

Attributes of the file.

validate

string

Command to validate file.

handlers

list

List of handlers.

Example

Create the description of the file (2) and declare the variable for the dictionary (7)

[contrib/lighttpd_nagios/conf-light/files.d/lighttpd-modulesconf.yml]

 1---
 2lighttpd-modulesconf:
 3  path: /usr/local/etc/lighttpd/modules.conf
 4  create: true
 5  owner: root
 6  group: wheel
 7  mode: "0644"
 8  copyfile: "{{ cl_lighttpd_modulesconf_copy }}"
 9  markers: "{{ cl_lighttpd_modulesconf_markers }}"
10  lines: "{{ cl_lighttpd_modulesconf_lines }}"
11  blocks: "{{ cl_lighttpd_modulesconf_blocks }}"
12  handlers:
13    - configtest lighttpd
14    - reload lighttpd

Create the dictionary cl_lighttpd_modulesconf_copy (69)

[contrib/lighttpd_nagios/cl-lighttpd.yml]

68# /usr/local/etc/lighttpd/modules.conf
69cl_lighttpd_modulesconf_copy:
70  path: /usr/local/etc/lighttpd/modules.conf.sample
71  remote_src: true
72  force: false

Then, the command

shell> ansible-playbook config-light.yml -t cl_files_copy

will copy sample file modules.conf.sample to modules.conf if the destination does not exist.

See also