Enforcing that a line to be present in a single occurence in a file is not an easy process to automate. Providing templates is an easy way to achieve this but not always possible.
If you don’t want to use a template, you can use Technique Enforce a File content to control the content of a file.
The whole logic to edit a file so it contain only one occurence of a line is:
- Add the line, so it will be added if missing)
- Replace line that looks almost like our line by the line
- Delete all duplicated lines
With these 3 steps, You will end with one line!
So, here is a small example: let’s say you want /etc/sysconfig/sysctl to contain line ENABLE_SYSRQ="yes"
You will need to create a Directive based on Enforce a File content with the following content:
Rudder 4.1 introduced a way to share files from one node to another. It allows a node to send a file to its relay, which will make it available for another target node, that has to to specifically download it.
This file sharing method is secured by:
- The control of uploaded file signature by the server, to check it matches the source node’s private key.
- The same mechanism as standard file copy in Rudder to download the shared file from the server.
It also includes a ttl mechanism that allows sharing a file for a limited amount of time.
To use this feature, two generic methods are available in the technique editor:
- sharedfile_from_node: To download a file shared from another node.
- sharedfile_to_node: To make a file available to another node.
See the documentation of these methods for details about the required parameters, and especially sharedfile_to_node for a complete usage example.