This project implements a file transfer script using Puppet to automate the process of copying a file from the master node to agent nodes.
Directory overview
The scripts are organised in a module named 'movefile'. There are two directories inside the module; files and manifests. The files directory stores the file to be copied to the agent node while the manifests directory stores the init.pp and site.pp file. The init.pp file is the default manifest file in a Puppet module. It acts as the main entry point for defining resources and configurations in that module. The site.pp file serves as the entry point for defining how nodes in the Puppet infrastructure are configured. Puppet uses this file to determine what resources, classes, and modules to apply to each node.
User and group resources
A users.pp file containing the user and group resources is created in the manifests directory to manage user accounts and groups on a system.
User resource attributes
Group resource attribute
File resource
The init.pp file is the default manifest file in a Puppet module. It acts as the main entry point for defining resources and configurations in that module. It has the file resource for managing files and directories on a system.
Check the syntax of both .pp files using 'puppet parser validate' to ensure that the Puppet agent can apply the configurations successfully.
Node definition
The site.pp file defines how the agent nodes should be configured. It defines the classes (modules) to be applied to the nodes. When the agent node requests the configuration from the master node, the Puppet master evaluates the site.pp file and other manifests, generating a catalog, which is then sent back to the agent node to apply the desired configuration. If no specific configuration is provided for a node, the default configuration in site.pp is applied. In the script created, the movefile module and users.pp file is applied to the agent node named 'pa5066357p.localdomain'.
Similarly, check the syntax of the site.pp file using 'puppet parser validate' to ensure that the Puppet agent can apply the configurations successfully.
Apply configurations
After creating the required files, it is time to apply the configurations. Run the command 'puppet agent -tv --noop' from the Puppet agent terminal. The command with the --noop flag simulates the changes but does not apply them. Puppet will show which resources would be changed, added, or removed without actually making those changes. After verifying the configurations in noop mode, use the command 'puppet agent -tv' to apply the changes to the system. Note that in a typical Puppet setup, the process of checking for configuration changes is automated and does not require manually running 'puppet agent -tv'. This is in line with the DevOps principle of automation, which in this case is the automation of configuration management.
Verify changes
The last step is to verify that the changes have been applied correctly. Similarly, this process is automated using automated testing or with monitoring tools as part of a continuous delivery pipeline.