server Facts¶
See also: operations/server.
server.Arch¶
Returns the system architecture according to uname.
server.AuthorizedKeys¶
Returns the SSH public keys listed in a user's ~/.ssh/authorized_keys file as a
list of full key strings. Empty lines and lines starting with # are skipped; the
file's order is preserved.
server.Command¶
Returns the raw output lines of a given command.
server.Date¶
Returns the current datetime on the server.
server.EtcHosts¶
Returns /etc/hosts (or the file at path) parsed as a mapping of IP address
to the list of hostnames declared on the matching lines. Comments and empty lines
are ignored; when the same IP is listed more than once, hostnames are merged in
file order.
{
"127.0.0.1": ["localhost", "localhost.localdomain"],
"::1": ["localhost"],
"192.168.1.10": ["db.internal"],
}
server.Groups¶
Returns a list of groups on the system.
server.HasGui¶
Returns a boolean indicating the remote side has GUI capabilities. Linux only.
server.Home¶
Returns the home directory of the given user, or the current user if no user is given.
server.Hostname¶
Returns the current hostname of the server.
server.Kernel¶
Returns the kernel name according to uname.
server.KernelModules¶
Returns a dictionary of kernel module name -> info.
server.KernelVersion¶
Returns the kernel version according to uname.
server.Last¶
Returns login records parsed from last as a list of dicts.
Parsing is intentionally light: time holds the raw trailing string from the
last output (e.g. "Thu Apr 17 14:00 still logged in") so that callers can
re-parse the date format that matches their system if needed.
[
{
"user": "alice",
"tty": "pts/0",
"host": "192.168.1.5",
"time": "Thu Apr 17 14:00 still logged in",
},
{
"user": "reboot",
"tty": "system boot",
"host": "6.19.10-arch1-1",
"time": "Thu Apr 17 11:00 - 12:00 (01:00)",
},
]
server.Lastb¶
Returns failed login records parsed from lastb (/var/log/btmp).
Output shape matches :class:Last; see that fact for details. lastb usually
requires root to read /var/log/btmp.
server.LinuxDistribution¶
Returns a dict of the Linux distribution version. Ubuntu, Debian, CentOS, Fedora & Gentoo currently. Also contains any key/value items located in release files.
{
"name": "Ubuntu",
"major": 20,
"minor": 04,
"release_meta": {
"CODENAME": "focal",
"ID_LIKE": "debian",
...
}
}
server.LinuxGui¶
Returns a list of available Linux GUIs.
server.LinuxName¶
Returns the name of the Linux distribution. Shortcut for
host.get_fact(LinuxDistribution)['name'].
server.LoadAverage¶
Returns the system load average keyed by window (1, 5 and 15 minutes).
Reads /proc/loadavg when available (Linux) and falls back to parsing
uptime output on systems without procfs (e.g. FreeBSD).
server.Locales¶
Returns installed locales on the target host.
server.LsbRelease¶
Returns a dictionary of release information using lsb_release.
{
"id": "Ubuntu",
"description": "Ubuntu 18.04.2 LTS",
"release": "18.04",
"codename": "bionic",
...
}
server.MacosVersion¶
Returns the installed MacOS version.
server.Mounts¶
Returns a dictionary of mounted filesystems and information.
server.Os¶
Returns the OS name according to uname.
Warning
This fact is deprecated/renamed, please use the server.Kernel fact.
server.OsRelease¶
Returns a dictionary of release information stored in /etc/os-release.
{
"name": "EndeavourOS",
"pretty_name": "EndeavourOS",
"id": "endeavouros",
"id_like": "arch",
"build_id": "2024.06.25",
...
}
server.OsVersion¶
Returns the OS version according to uname.
Warning
This fact is deprecated/renamed, please use the server.KernelVersion fact.
server.Path¶
Returns the path environment variable of the current user.
server.Port¶
Returns the process occupying a port and its PID.
Supports TCP and UDP protocols via the protocol argument (default "tcp").
Uses ss on Linux (with netstat fallback) and sockstat on FreeBSD.
server.Ports¶
Returns a list of all listening ports with their processes and PIDs.
Uses ss on Linux (with netstat fallback) and sockstat on FreeBSD.
server.Processes¶
Returns a dictionary of running processes keyed by PID.
{
1: {
"user": "root",
"state": "Ss",
"cpu_percent": 0.0,
"mem_percent": 0.1,
"command": "init",
"args": "/sbin/init",
},
}
server.RebootRequired¶
Returns a boolean indicating whether the system requires a reboot.
On Linux systems:
- Checks /var/run/reboot-required and /var/run/reboot-required.pkgs
- On Alpine Linux, compares installed kernel with running kernel
On FreeBSD systems:
- Compares running kernel version with installed kernel version
server.SecurityLimits¶
Returns a list of security limits on the target host.
[
{
"domain": "*",
"limit_type": "soft",
"item": "nofile",
"value": "1048576"
},
{
"domain": "*",
"limit_type": "hard",
"item": "nofile",
"value": "1048576"
},
{
"domain": "root",
"limit_type": "soft",
"item": "nofile",
"value": "1048576"
},
{
"domain": "root",
"limit_type": "hard",
"item": "nofile",
"value": "1048576"
},
{
"domain": "*",
"limit_type": "soft",
"item": "memlock",
"value": "unlimited"
},
{
"domain": "*",
"limit_type": "hard",
"item": "memlock",
"value": "unlimited"
},
{
"domain": "root",
"limit_type": "soft",
"item": "memlock",
"value": "unlimited"
},
{
"domain": "root",
"limit_type": "hard",
"item": "memlock",
"value": "unlimited"
}
]
server.Selinux¶
Discovers the SELinux related facts on the target host.
server.Sysctl¶
Returns a dictionary of sysctl settings and values.
server.Timezone¶
Returns the current system timezone (e.g. Europe/Amsterdam).
server.TmpDir¶
Returns the temporary directory of the current server.
According to POSIX standards, checks environment variables in this order: 1. TMPDIR (if set and accessible) 2. TMP (if set and accessible) 3. TEMP (if set and accessible) 4. Falls back to empty string
server.Uptime¶
Returns the number of seconds the system has been up.
server.User¶
Returns the name of the current user.
server.Users¶
Returns a dictionary of users -> details.
{
"user_name": {
"comment": "Full Name",
"home": "/home/user_name",
"shell": "/bin/bash,
"group": "main_user_group",
"groups": [
"other",
"groups"
],
"uid": user_id,
"gid": main_user_group_id,
"lastlog": last_login_time,
"password": encrypted_password,
},
}
server.Which¶
Returns the path of a given command according to command -v, if available.