A gem to get inventories of nodes in a Puppet / Choria deployment.
- Installation
- Usage
- Configuration
- Resolvers
- Formatters
- Development
- Contributing
- License
- Code of Conduct
Take care to install this tool in the Puppet environment. If you are using the AIO package, you can install with:
/opt/puppetlabs/puppet/bin/gem install --bindir /opt/puppetlabs/bin motoko
Alternatively, you can install using Puppet:
package { 'motoko':
ensure => 'installed',
provider => 'puppet_gem',
install_options => [
'--bindir',
'/opt/puppetlabs/bin',
],
}
Two inventroy scripts are currently provided:
exe/inventory
use Choria discovery and return live data from your infrastructure;exe/pdb-inventory
use PuppetDB querying and return what Puppet thinks about your infrastructure.
Both have a similar feature-set, and a full list of available options can be obtained by running them with --help
.
romain@zappy ~ % inventory
romain@zappy ~ % pdb-inventory
By default, the report display the node name, along with it's customer
and role
facts (if these facts are available). You can request additional facts are just replace the list. The syntax is the same for both the choria and puppetdb inventory scripts.
romain@zappy ~ % inventory -a datacenter,city,country
The usual filtering knobs are available for the choria inventory script. The puppetdb inventory script has a minimal support for choria-like filtering.
The initial work on querying PuppetDB is due to the fact that you can't ask Choria for information about nodes which are gone. On March 9th 2021, OVH lost (part of) it's Strasboug datacenter and the frustration of not being able to conveniently build a list of affected nodes and customers was a pain. With Motoko we can now just query PuppetDB:
romain@zappy ~ % pdb-inventory -F datacenter=/sbg/
At startup, Motoko will try to load a system-wide configuration from /etc/motoko/config.yaml
, a user configuration from ~/.config/motoko/config.yaml
and a project configuration from .motoko.yaml
in the current working directory.
Set the list of columns to display by default:
columns:
- "host"
- "customer"
- "role"
- "country"
- "city"
Customize how columns are displayed:
human_name
: what title should be used for the column (defaults to a capitalized version of the column name);resolver
: which resolver to use to gather the information (defaults tofact
);formatter
: which formatter to use to print the value (none by default);align
: how to align the formatted value in the column (default toleft
).
columns_spec:
host:
resolver: "identity"
customer:
formatter: "ellipsis"
max_length: 20
cpu:
resolver: "cpu"
os:
human_name: "Operating System"
resolver: "os"
reboot_required:
human_name: "R"
resolver: "reboot_required"
formatter: "boolean"
shortcuts:
dc:
description: "Show physical node locations"
add_columns:
- "datacenter"
- "server_rack"
- "server_id"
with_fact:
- "virtual=physical"
This add a new command switch --dc
equivalent to --add-columns datacenter,server_rack,server_id --with-fact virtual=physical
.
The following settings are available when defining shortcuts:
Setting | Description |
---|---|
description |
Description of the shortcut (visible in --help ) |
columns |
List of columns to display |
add_columns |
Extra columns to append of the default list |
with_fact |
Extra filtering of the results based on facts |
with_class |
Extra filtering of the results based on configured classes |
Resolver name | Description |
---|---|
cpu |
Aggregate information about the CPU |
fact |
Gather the value of the fact fact (default to the column name if unset) |
identity |
Gather the node identity |
os |
Aggregate information about the OS |
reboot_required |
Combine value of various facts to determine if a reboot is required |
Custom resolvers can be dropped in the <motoko-config-directory>/resolvers/
directory. They are automatically loaded on startup.
Formatter name | Description |
---|---|
boolean |
Display a checkmark for things that evaluate to true |
datetime |
Display a date and time in the local time zone |
datetime_ago |
Display a date and time as a duration |
ellipsis |
Display a value truncated at max_length chars (default: 20) |
timestamp |
Display a timestamp (number of seconds since the Unix epoch) in the local time zone |
timestamp_ago |
Display a timestamp (number of seconds since the Unix epoch) as a duration |
Custom formatters can be dropped in the <motoko-config-directory>/formatters/
directory. They are automatically loaded on startup.
In order to use the Puppet environment, use the version of bundler bundled with Puppet:
/opt/puppetlabs/puppet/bin/bundle install
/opt/puppetlabs/puppet/bin/bundle exec rake spec
/opt/puppetlabs/puppet/bin/bundle exec exe/inventory
Iy you want to install this development code:
/opt/puppetlabs/puppet/bin/gem build motoko.gemspec
sudo /opt/puppetlabs/puppet/bin/gem install --bindir /opt/puppetlabs/bin motoko-x.y.z.gem
Bug reports and pull requests are welcome on GitHub at https://github.com/opus-codium/motoko. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Motoko project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.