Version information
This version is compatible with:
- Puppet Enterprise 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x
- Puppet >= 6.0.0 < 8.0.0
- , , , , , ,
Tasks:
- csv_handler
- ensure_job_run
- node_info_clear
- node_info_source_clear
Plans:
- export_csv
- load_csv
- source_clear
Start using this module
Add this module to your Puppetfile:
mod 'cheehuan-node_info', '0.2.3'
Learn more about managing modules with a PuppetfileDocumentation
node_info
A node information publisher to prepared node facts.
Table of Contents
- Description
- Setup
- Usage - Configuration options and additional functionality
- Limitations - OS compatibility, etc.
- Development - Guide for contributing to the module
Description
This module prepare facts from a primary Puppet server. You can load multiple sources feed_type
of information with comma delimited values files. The CSV file require a identifier key_field
to associate with Puppet agent fact stated in lookup_facts
parameters. You can specify more than one fact, avoid complex lookup facts and it will increase Puppet compilation time.
Setup
Declare node_info
class will prepare a node_info.yaml when there any relevant data found that belong to the agents. node_info only refreshed when there was changes on sources.
UNIX: /etc/puppetlabs/facter/facts.d/node_info.yaml
Windows: C:\ProgramData\PuppetLabs\puppet\cache\facts.d\node_info.yaml
Parameters
This module uses local module hiera in data/common.yaml. Bring custom parameter into your own control repositories or classification configuration.
- Pick up a unique name or uses the default
node_info
fornode_info::node_info_fact
- Update
lookup_facts
to associate with thekey_field
.
node_info::node_info_fact: node_info
node_info::lookup_facts:
- hostname
- virtual_info.id
Load data
You can prepare multiples CSV files with unique feed_type
, The CSV file need to be visible on Puppet server.
- Upload CSV file to Puppet server's default folder
/var/puppetlabs/data/node_info/in
. - Trigger plan
node_info::load_csv
, you can specify following optional parameters:
- csv_filename [Stdlib::Absolutepath], CSV absolute path with filename, Default:
/var/puppetlabs/data/node_info/in/cmdb_data.csv
- feed_type [String], Free text feed type, Default:
common
- key_field [String], Source key field column, Default:
hostname
- facts_lookup_field [String], fact name lookup matched key_field, Default:
hostname
- target_dir [Stdlib::Absolutepath], Validated directory, Default:
/var/puppetlabs/data/node_info/validated
- basename [Boolean], Select basename on key_field, Default: true
- multiple [Boolean], Allow multiple recoards on same key_field and handle it as Hash of Array
- log_feed [Boolean], Logging feed name that being loaded
- post_puppet_run[Boolean], trigger Puppet run after loading successfully, for key_field matched facts_lookup_field with certname. Limitted to orchestrator target nodes size
- puppetdb_query_limit[Integer], limiter on nodes loader
- remove_existing_source_feed_type[Boolean], Remove existing soure feed type before loading new sets of data.
- debug[Boolean], enable additional logging message, Default: false
Example, prepare plan param file load_csv_cmdb.json and trigger using puppet plan run node_info::load_csv --params @load_csv_cmdb.json
,
{
"csv_filename": "/var/puppetlabs/data/node_info/in/cmdb_data.csv",
"feed_type": "cmdb",
"key_field": "server_name",
"post_puppet_run": true,
"skipped_field": ["server_name","vm"]
}
Verify plan result for any error or duplicate CSV entry, ensure key_field
param was specified correctly. Valid data stored under /var/puppetlabs/data/node_info/validate
and invalid data will store under /var/puppetlabs/data/node_info/out
.
Run succeeded: {csv_header => [server_name, role, business_criticality, environment, datacenter, location, status, application_name, application_owner_1, application_owner_2, remark], total_size => 4, unchanged => 3, changed => 0, duplicate => 0, error => 0, new => 1}
For each data sources loaded a record will created under node_info_source
fact on Puppet server.
{
"cmdb" : {
"csv_filename" : "/var/puppetlabs/data/node_info/in/cmdb_data.csv",
"key_field" : "server_name",
"load_result" : {
"changed" : 0,
"csv_header" : [ "server_name", "role", "business_criticality", "environment", "datacenter", "location", "status", "application_name", "application_owner_1", "application_owner_2", "remark" ],
"duplicate" : 0,
"error" : 0,
"new" : 0,
"total_size" : 4,
"unchanged" : 4
},
"multiple" : false,
"target_dir" : "/var/puppetlabs/data/node_info/validated",
"updated" : "2021-04-18 18:37:14 +0800"
}
}
Node info fact
On agent, following example node_info contain 2 feed_type
cmdb and snapshot.
{
"cmdb" : {
"application_name" : "Test base - RHEL family",
"business_criticality" : "1-Negligible",
"datacenter" : "VM01",
"environment" : "UAT",
"location" : "Singapore",
"role" : "tst-base",
"status" : "Live"
},
"last_updated" : "2021-04-18 16:14:33 +0800",
"snapshot" : {
"created" : "8/1/2019 4:53:35 PM",
"description" : "Security Finding",
"hostname" : "tst01",
"iscurrent" : "True",
"name" : "SNAPSHOT BEFORE HARDEN",
"powerstate" : "PoweredOn",
"sizemb" : 75732.1372499466,
"vm" : "tst01"
}
}
Limitation
- On Puppet compiler, File_sync
validated
folder require from Puppet Master. - Currently only tested on Primary Puppet server.
Development
Just fork and raise a PR.
What are tasks?
Modules can contain tasks that take action outside of a desired state managed by Puppet. It’s perfect for troubleshooting or deploying one-off changes, distributing scripts to run across your infrastructure, or automating changes that need to happen in a particular order as part of an application deployment.
Tasks in this module release
What are plans?
Modules can contain plans that take action outside of a desired state managed by Puppet. It’s perfect for troubleshooting or deploying one-off changes, distributing scripts to run across your infrastructure, or automating changes that need to happen in a particular order as part of an application deployment.
Changelog
All notable changes to this project will be documented in this file.
2021-05-11 Release 0.2.3
Features 0.2.3
- Improve lookup fact to matched more than one key fields.
- include examples json params
2021-03-02 Release 0.2.2
Features 0.2.2
- Improve deploy puppet job run, now tasks can wait until jobs reach expected states, example
finished
,failed
or tasks will timeout instate_wait_timeout
cycle withstate_wait_sleep
in seconds.
Bugfix 0.2.2
- Serialize tasks result.
2021-03-02 Release 0.2.1
Features 0.2.1
- covert to PDK 2
Bugfix 0.2.1
- Update module metadata and README doc
2020-12-08 Release 0.2.0
Bugfix 0.2.0
- Improve node_info function warning logging
- change case insensitve on key_field for post_run and source_clear
2020-10-19 Release 0.1.0
Features - 0.1.0
- Initial release
*Known Issues