Table of Contents
- file_check_FIFO_pipe
- file_check_block_device
- file_check_character_device
- file_check_exists
- file_check_hardlink
- file_check_regular
- file_check_socket
- file_check_symlink
- file_check_symlinkto
- file_copy_from_local_source
- file_copy_from_local_source_recursion
- file_copy_from_remote_source
- file_copy_from_remote_source_recursion
- file_create
- file_create_symlink
- file_create_symlink_enforce
- file_create_symlink_force
- file_download
- file_enforce_content
- file_ensure_block_in_section
- file_ensure_block_present
- file_ensure_key_value
- file_ensure_key_value_present_in_ini_section
- file_ensure_keys_values
- file_ensure_line_present_in_ini_section
- file_ensure_line_present_in_xml_tag
- file_ensure_lines_absent
- file_ensure_lines_present
- file_from_template
- file_from_template_mustache
- file_from_template_type
- file_remove
- file_replace_lines
- file_template_expand
Checks if a file exists and is a FIFO/Pipe
Compatible with nodes running Rudder 2.11 or higher.
This bundle will define a class
file_check_FIFO_pipe_${file_name}_{ok, reached, kept}
if the file is a
FIFO, or
file_check_FIFO_pipe_${file_name}_{not_ok, reached, not_kept, failed}
if the file is not a fifo or does not exist
- file_name: File name
file_check_FIFO_pipe_${file_name}_{kept, repaired, not_ok, reached}
Checks if a file exists and is a block device
Compatible with nodes running Rudder 2.11 or higher.
This bundle will define a class
file_check_block_device_${file_name}_{ok, reached, kept}
if the file
is a block_device, or
file_check_block_device_${file_name}_{not_ok, reached, not_kept, failed}
if the file is not a block device or does not exist
- file_name: File name
file_check_block_device_${file_name}_{kept, repaired, not_ok, reached}
Checks if a file exists and is a character device
Compatible with nodes running Rudder 2.11 or higher.
This bundle will define a class
file_check_character_device_${file_name}_{ok, reached, kept}
if the
file is a character device, or
file_check_character_device_${file_name}_{not_ok, reached, not_kept, failed}
if the file is not a character device or does not exist
- file_name: File name
file_check_character_device_${file_name}_{kept, repaired, not_ok, reached}
Checks if a file exists
Compatible with nodes running Rudder 2.11 or higher.
This bundle will define a class
file_check_exists_${file_name}_{ok, reached, kept}
if the file exists,
or file_check_exists_${file_name}_{not_ok, reached, not_kept, failed}
if the file doesn’t exists
- file_name: File name
file_check_exists_${file_name}_{kept, repaired, not_ok, reached}
Checks if two files are the same (hard links)
Compatible with nodes running Rudder 2.11 or higher.
This bundle will define a class
file_check_hardlink_${file_name_1}_{ok, reached, kept}
if the two
files ${file_name_1}
and ${file_name_2}
are hard links of each
other, or
file_check_hardlink_${file_name_1}_{not_ok, reached, not_kept, failed}
if if the files are not hard links.
- file_name_1: File name #1
- file_name_2: File name #2
file_check_hardlink_${file_name_1}_{kept, repaired, not_ok, reached}
Checks if a file exists and is a regular file
Compatible with nodes running Rudder 2.11 or higher.
This bundle will define a class
file_check_regular_${file_name}_{ok, reached, kept}
if the file is a
regular_file, or
file_check_regular_${file_name}_{not_ok, reached, not_kept, failed}
if
the file is not a regular file or does not exist
- file_name: File name
file_check_regular_${file_name}_{kept, repaired, not_ok, reached}
Checks if a file exists and is a socket
Compatible with nodes running Rudder 2.11 or higher.
This bundle will define a class
file_check_socket_${file_name}_{ok, reached, kept}
if the file is a
socket, or
file_check_socket_${file_name}_{not_ok, reached, not_kept, failed}
if
the file is not a socket or does not exist
- file_name: File name
file_check_socket_${file_name}_{kept, repaired, not_ok, reached}
Checks if a file exists and is a symlink
Compatible with nodes running Rudder 2.11 or higher.
This bundle will define a class
file_check_symlink_${file_name}_{ok, reached, kept}
if the file is a
symlink, or
file_check_symlink_${file_name}_{not_ok, reached, not_kept, failed}
if
the file is not a symlink or does not exist
- file_name: File name
file_check_symlink_${file_name}_{kept, repaired, not_ok, reached}
Checks if first file is symlink to second file
Compatible with nodes running Rudder 2.11 or higher.
This bundle will define a class
file_check_symlinkto_${target}_{ok, reached, kept}
if the file
${symlink}
is a symbolic link to ${target}
, or
file_check_symlinkto_${target}_{not_ok, reached, not_kept, failed}
if
if it is not a symbolic link, or any of the files does not exist. The
symlink’s path is resolved to the absolute path and checked against the
target file’s path, which must also be an absolute path.
- symlink: Symbolic link (absolute path)
- target: Target file (absolute path)
file_check_symlinkto_${symlink}_{kept, repaired, not_ok, reached}
This is a bundle to ensure that a file or directory is copied from a local source
Compatible with nodes running Rudder 2.11 or higher.
- source: Source file
- destination: Destination file
file_copy_from_local_source_${destination}_{kept, repaired, not_ok, reached}
This is a bundle to ensure that a file or directory is copied from a local source
Compatible with nodes running Rudder 2.11 or higher.
- source: Source file
- destination: Destination file
- recursion: Recursion depth to enforce for this path (0, 1, 2, …, inf)
file_copy_from_local_source_${destination}_{kept, repaired, not_ok, reached}
This is a bundle to ensure that a file or directory is copied from a remote source
Compatible with nodes running Rudder 2.11 or higher.
Note: This method uses CFEngine file copy protocol, and can only download files from the policy server. To download a file from an external source, you can use HTTP with the file_download method.
This method requires that the policy server is configured to accept copy of the source file from the agents it will be applied to.
You have to write the full path of the file on the policy server, for example:
/home/myuser/myfile
If you are using Rudder, you can download a file from the shared files with:
/var/rudder/configuration-repository/shared-files/PATH_TO_YOUR_FILE
- source: Source file
- destination: Destination file
file_copy_from_remote_source_${destination}_{kept, repaired, not_ok, reached}
This is a bundle to ensure that a file or directory is copied from a remote source
Compatible with nodes running Rudder 2.11 or higher.
This method requires that the policy server is configured to accept copy of the source file or directory from the agents it will be applied to.
You have to write the full path of the file or directory on the policy server, for example:
/home/myuser/mydirectory
If you are using Rudder, you can download a file from the shared files with:
/var/rudder/configuration-repository/shared-files/PATH_TO_YOUR_DIRECTORY_OR_FILE
- source: Source file
- destination: Destination file
- recursion: Recursion depth to enforce for this path (0, 1, 2, …, inf)
file_copy_from_remote_source_${destination}_{kept, repaired, not_ok, reached}
Create a file if it doesn’t exist
Compatible with nodes running Rudder 2.11 or higher.
- target: File to create
file_create_${target}_{kept, repaired, not_ok, reached}
This is a bundle to create a symlink at a destination path and pointing to a source target except if a file or directory already exists.
Compatible with nodes running Rudder 2.11 or higher.
- source: Source file
- destination: Destination file
file_create_symlink_${destination}_{kept, repaired, not_ok, reached}
This is a bundle to create a symlink at a destination path and pointing to a source target. This is also possible to enforce its creation
Compatible with nodes running Rudder 2.11 or higher.
- source: Source file
- destination: Destination file
- enforce: Force symlink if file already exist (true or false)
file_create_symlink_${destination}_{kept, repaired, not_ok, reached}
This is a bundle to create a symlink at a destination path and pointing to a source target even if a file or directory already exists.
Compatible with nodes running Rudder 2.11 or higher.
- source: Source file
- destination: Destination file
file_create_symlink_${destination}_{kept, repaired, not_ok, reached}
Download a file if it does not exit, using curl with a fallback on wget
Compatible with nodes running Rudder 2.11 or higher.
This method finds a HTTP command-line tool and downloads the given source into the destination.
It tries curl
first, and wget
as fallback.
- source: URL to download from
- destination: File destination
file_download_${destination}_{kept, repaired, not_ok, reached}
This is a bundle to enfore the content of a file
Compatible with nodes running Rudder 2.11 or higher.
- file: File name to edit
- lines: Line(s) to add in the file
- enforce: Enforce the file to contain only line(s) defined (true or false)
file_ensure_lines_present_${file}_{kept, repaired, not_ok, reached}
This is a bundle to ensure that a section contains exactly a text block
Compatible with nodes running Rudder 2.11 or higher.
- file: File name to edit
- section_start: Start of the section
- section_end: End of the section
- block: Block representing the content of the section
file_ensure_block_in_section_${file}_{kept, repaired, not_ok, reached}
This is a bundle to ensure that a text block is present in a specific location
Compatible with nodes running Rudder 2.11 or higher.
- file: File name to edit
- block: Block(s) to add in the file
file_ensure_block_present_${file}_{kept, repaired, not_ok, reached}
Ensure that the file contains a pair of "key separator value"
Compatible with nodes running Rudder 2.11 or higher.
Edit (or create) the file, and ensure it contains an entry key → value with arbitrary separator between the key and its value. If the key is already present, the method will change the value associated with this key.
- file: File name to edit
- key: Key to define
- value: Value to define
- separator: Separator between key and value (for example "=" or " ")
file_ensure_key_value_${file}_{kept, repaired, not_ok, reached}
This is a bundle to ensure that a key-value pair is present in a section in a specific location. The objective of this method is to handle INI-style files.
Compatible with nodes running Rudder 2.11 or higher.
- file: File name to edit
- section: Name of the INI-style section under which the line should be added or modified (not including the [] brackets)
- name: Name of the key to add or edit
- value: Value of the key to add or edit
file_ensure_key_value_present_in_ini_section_${file}_{kept, repaired, not_ok, reached}
Ensure that the file contains all pairs of "key separator value", with arbitrary separator between each key and its value
Compatible with nodes running Rudder 2.11 or higher.
You can create a dict variable by using the variable_dict* methods.
- file: File name to edit
- keys: Dict structure containing the keys (keys of the dict), and values to define (values of the dict)
- separator: Separator between key and value (for example "=" or " ")
file_ensure_keys_values_${file}_{kept, repaired, not_ok, reached}
This is a bundle to ensure that a line is present in a section in a specific location. The objective of this method is to handle INI-style files.
Compatible with nodes running Rudder 2.11 or higher.
- file: File name to edit
- section: Name of the INI-style section under which lines should be added (not including the [] brackets)
- line: Line to ensure is present inside the section
file_ensure_line_present_in_ini_section_${file}_{kept, repaired, not_ok, reached}
This is a bundle to ensure that a line is present in a tag in a specific location. The objective of this method is to handle XML-style files. Note that if the tag is not present in the file, it won’t be added, and the edition will fail.
Compatible with nodes running Rudder 2.11 or higher.
- file: File name to edit
- tag: Name of the XML tag under which lines should be added (not including the <> brackets)
- line: Line to ensure is present inside the section
file_ensure_line_present_in_xml_tag_${file}_{kept, repaired, not_ok, reached}
This is a bundle to ensure that a line is absent in a specific location
Compatible with nodes running Rudder 2.11 or higher.
- file: File name to edit
- lines: Line(s) to remove in the file
file_ensure_lines_absent_${file}_{kept, repaired, not_ok, reached}
This is a bundle to ensure that one or more lines are present in a file
Compatible with nodes running Rudder 2.11 or higher.
- file: File name to edit
- lines: Line(s) to add in the file
file_ensure_lines_present_${file}_{kept, repaired, not_ok, reached}
This is a bundle to build a file from a template
Compatible with nodes running Rudder 2.11 or higher.
- source_template: Source file containing a template to be expanded
- destination: Destination file
file_from_template_${destination}_{kept, repaired, not_ok, reached}
This is a bundle to build a file from a mustache template
Compatible with nodes running Rudder 2.11 or higher.
- source_template: Source file containing a template to be expanded
- destination: Destination file
file_from_template_${destination}_{kept, repaired, not_ok, reached}
This is a bundle to build a file from a template
Compatible with nodes running Rudder 2.11 or higher.
- source_template: Source file containing a template to be expanded
- destination: Destination file
- template_type: Template type (cfengine or mustache)
file_from_template_${destination}_{kept, repaired, not_ok, reached}
Remove a file if it exists
Compatible with nodes running Rudder 2.11 or higher.
- target: File to remove
file_remove_${target}_{kept, repaired, not_ok, reached}
This is a bundle to ensure that a line in a file is replaced by another one
Compatible with nodes running Rudder 2.11 or higher.
- file: File name to edit
- line: Line to match in the file
- replacement: Line to add in the file as a replacement
file_replace_lines_${file}_{kept, repaired, not_ok, reached}
This is a bundle to expand a template in a specific location
Compatible with nodes running Rudder 2.11 or higher.
- tml_file: File name (with full path within the framework) of the template file
- target_file: File name (with full path) where to expand the template
- mode: Mode of destination file
- owner: Owner of destination file
- group: Froup of destination file
file_template_expand_${target_file}_{kept, repaired, not_ok, reached}