Skip to main content

Return facts of server

Project description

Returns facts of local machine.

Installation

pip install facts

CLI Usage

Get all facts:

facts all

Get one fact:

fact read foo

Set one custom fact:

fact write foo 'It is nice'

When value is a mapping, then you can choose between 2 merging strategies:

fact write foo '{is: bar}' --format yaml --replace
fact write foo '{not: baz}' --format yaml --merge

Delete a custom fact:

fact delete foo

Targeting

By convention key facts can’t have colon marks. Because facts can be nested, and it’s possible to target these sub data. Each parts must be seperated by a colon. For example if:

fact read foo

returns:

is: bar
not: baz

Then:

fact read foo:is

returns:

bar

But:

fact read foo:wrong:key

will return nothing.

Matching

It is also possible to check if a certain fact turns out true:

fact match foo:is:bar

Grafting

Facts allow you to extends with ‘grafts’. There is 2 ways

1. by modules

You can extend with your own facts. Any python modules under ~/.facts/grafts will be loaded. For example:

# ~/.facts/grafts/my_grafts.py

from . import graft

@graft
def hello_world():
    return {
        'hello': 'world'
    }

Will append the fact hello with the value world.

2. with setuptools

You also write python libraries that will contribute to facts with using setuptools. Add the following to the setup.py function:

entry_points={
    'facts.graft': [
        'plugin-1 = mylib:plugin_1',
        'plugin-2 = mylib:plugin_2'
    ]
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

facts-0.3.tar.gz (7.0 kB view details)

Uploaded Source

File details

Details for the file facts-0.3.tar.gz.

File metadata

  • Download URL: facts-0.3.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for facts-0.3.tar.gz
Algorithm Hash digest
SHA256 0b9486eea3d1cf8f0d5ef1770b465057b6f7da4e4bdb1d7f528ade437f3c1a93
MD5 ac5d6ce7214e1a6c90cdfdf7f9503429
BLAKE2b-256 3db351940ce1381f61d9683f927e8b988a75bf02ba4a3cc3e22c9ed38739b71e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page