File modules deal with, well, files, on the managed systems. Many options are available for file attribute management, copying, templating, or interaction with version control.
File modules handle transferring content to remote systems or making sure that properties of files and directories are as intended. Most file modules take some common attributes:
More Attributes To Come
This is just a starting set, for instance, SELinux attributes will be added in the near future. Though if you think the most useful Linux command is setenforce 0, we also won't judge you.
Copies individual files.
If the source path is relative, the system will look in './files' relative to the playbook being executed, or if in Role context, it will look in ./files inside the role directory. Absolute paths are also allowed.
The attributes block is optional, as are all of the attributes themselves. The copy module contains built-in checksumming and will transfer data only when required.
SFTP Behind The Scenes
Jet file transfers for modules like 'copy' and 'template' require the SSH SFTP subsystem to be enabled, which should be on in nearly all distributions. If this is not the case, be sure to enable it when provisioning your systems via SSH config. If managing pre-existing systems with this feature somehow disabled, a boostrapping playbook that uses the shell module with sed or cat may be helpful to enable this option.
Bandwidth And Load
Jet is smart enough to stream large files rather than to load them in memory, which can result in fairly fast file transfers for 'copy', but executing very many file copies with a large --threads value could still overtax a control machine. If moving large files such as ISOs, it may be better to initiate a download from the remote machine instead.
The directory module creates directories and enforces ownership, use of 'recurse' makes the underlying chown, chgrp, and chmod commands use "-r". Directory creation always implies "mkdir -p"
Modifies attributes of files (vs directories) and can also remove them. If path does not exist, file will create an empty file at a given location.
clones a git repository or updates it a specific version or points it at a specific branch.
The git module works with either private repositories (git:// or ssh protocol only using SSH keys) or public repositories (http:// or https:// only). Repo authentication by password is intentionally not supported with any kind of expect-based prompt-entry feature. While passwords inside the URLs would technically work, we would discourage that practice and recommend key based authentication.
When accessing private repositories jetp must be run with '--forward-agent' which acknowledges signing off on some security implications, namely that untrustworthy root users on the remote (configured) machine could use SSH identities for nefarious purposes. This is not a concern for local (non-SSH) operational modes.
# SSH example, will need --forward-agent on the jetp command line
repo: [email protected]:mpdehaan/func.git
Enterprise Linux 7 Variants Only: Is Your OS "git" New Enough?
At the present time, this command executes git with -C, which means "Enterprise Linux" 7 (which released in 2013) targets are, in stock configuraiton, too old to use with the git module. In general, we try to build modules to support Linux operating systems for the entire life of all "supported" distributions, and longer, however, the -C option (chdir) is too useful for the way Jet operates. If you want to use this module on Enteprise Linux 7 you can upgrade your git version, or alternatively transfer content using other means.
Evaluates a local handlebars template, substituting in variables, and then applies it to the system. This is great for configuration files. The variables section has a lot more information about template syntax. An undefined variable in a template will always produce an error.