Facts Index¶
pyinfra uses facts to determine the existing state of a remote server. Operations use this information to generate commands which alter the state. Facts can be easily tested like so:
$ pyinfra -i myhost.com --fact date
...
"myhost.com": "2016-01-01T16:20:00+00:00"
Facts are namespaced similarly to modules, use the sidebar to browse those available.
Apt¶
apt_sources
¶
Returns a dict of installed apt sources:
'http://archive.ubuntu.org': { 'type': 'deb', 'distribution': 'trusty', 'components', ['main', 'multiverse'] }, ...
deb_package
¶
Returns information on a .deb file.
deb_packages
¶
Returns a dict of installed dpkg packages:
'package_name': 'version', ...
Devices¶
block_devices
¶
Returns a dict of (mounted) block devices:
'/dev/sda1': { 'available': '39489508', 'used_percent': '3', 'mount': '/', 'used': '836392', 'blocks': '40325900' }, ...
network_devices
¶
Gets & returns a dict of network devices:
'eth0': { 'ipv4': { 'address': '127.0.0.1', 'netmask': '255.255.255.255', 'broadcast': '127.0.0.13' }, 'ipv6': { 'size': '64', 'address': 'fe80::a00:27ff:fec3:36f0' } }, ...
Files¶
directory
¶
file
¶
find_directories
¶
Returns a list of directories from a start point, recursively using find.
find_files
¶
Returns a list of files from a start point, recursively using find.
find_in_file
¶
Checks for the existence of text in a file using grep. Returns a list of matching lines if the file exists, andNone
if the file does not.
find_links
¶
Returns a list of links from a start point, recursively using find.
link
¶
sha1_file
¶
Returns a SHA1 hash of a file. Works with both sha1sum and sha1.
Init¶
initd_status
¶
Low level check for every /etc/init.d/* script. Unfortunately many of these mishehave and return exit status 0 while also displaying the help info/not offering status support.
Returns a dict of name -> status.
- Expected codes found at:
- http://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
rcd_enabled
¶
Returns a dict of service name -> whether enabled (on boot) status. Different to Linux variants because BSD has no/one runlevel.
rcd_status
¶
Same asinitd_status
but for BSD (/etc/rc.d) systems. Unlike Linux/init.d, BSD init scripts are well behaved and as such their output can be trusted.
systemd_enabled
¶
Returns a dict of name -> whether enabled for systemd managed services.
systemd_status
¶
Returns a dict of name -> status for systemd managed services.
upstart_status
¶
Returns a dict of name -> status for upstart managed services.
Npm¶
npm_local_packages
¶
Returns a dict of locally installed npm packages in a given directory:
'package_name': 'version', ...
npm_packages
¶
Returns a dict of globally installed npm packages:
'package_name': 'version', ...
Pip¶
pip_packages
¶
Returns a dict of installed pip packages:
'package_name': 'version', ...
pip_virtualenv_packages
¶
Server¶
arch
¶
command
¶
date
¶
Returns the current datetime on the server.
groups
¶
Returns a list of groups on the system.
home
¶
hostname
¶
linux_distribution
¶
Returns a dict of the Linux distribution version. Ubuntu, Debian, CentOS, Fedora & Gentoo currently:
{ 'name': 'CentOS', 'major': 6, 'minor': 5 }
os
¶
os_version
¶
users
¶
Returns a dict of users -> details:
'user_name': { 'home': '/home/user_name', 'shell': '/bin/bash, 'group': 'main_user_group', 'groups': [ 'other', 'groups' ] }, ...