device_manager
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
- , , , , ,
This module has been deprecated by its author since Jun 11th 2024.
Tasks:
- run_puppet_device
Start using this module
Documentation
device_manager
Table of Contents
Description
Agentless devices require a proxy Puppet agent to request certificates, collect facts, retrieve and apply catalogs, and store reports. This module manages the configuration files used by the puppet device
command, installs libraries required by device modules, and provides additional resources for scheduling and orchestrating puppet device
runs on those proxy Puppet agents.
What does this module provide?
- Allows for the configuration of devices in
device.conf
via a manifest, Hiera, and/or the Classifier - Defines a
devices
fact on the proxy Puppet agent identifying the devices for which it is a proxy - Installs libraries required by associated device modules the proxy Puppet agent
- Provides an option for scheduling of
puppet device
runs on the proxy Puppet agent - Provides an optional task for orchestration of
puppet device
runs on newer proxy Puppet agents
Usage
Install
On the server, install the device_manager
module:
puppet module install puppetlabs-device_manager
On the server, install the device-specific module associated with each device. For example:
puppet module install f5-f5
puppet module install puppetlabs-cisco_ios
Configure
You can declare individual devices via a manifest, or multiple devices via Hiera or the Classifier. Using Hiera allows you to encrypt sensitive information, such as passwords, at rest on the server, using the hiera-eyaml backend.
Note: If you declare the same device (identified by name) via Hiera and the Classifier, the declaration in the Classifier takes precedence.
Manage individual devices via a manifest:
Declare individual device_manager
resources via a manifest and apply to the proxy Puppet agent:
node 'agent.example.com' {
device_manager { 'bigip.example.com':
type => 'f5',
url => 'https://admin:password@10.0.0.245/',
run_interval => 30,
}
device_manager { 'cisco.example.com':
type => 'cisco_ios',
credentials => {
address => '10.0.0.246',
port => 22,
username => 'admin',
password => 'password',
enable_password => 'password',
},
}
}
Manage multiple devices via Hiera:
Declare multiple device_manager
resources via the device_manager::devices
key and apply to the proxy Puppet agent via Hiera:
---
device_manager::devices:
bigip1.example.com:
type: 'f5'
url: 'https://admin:password@10.0.1.245/'
run_interval: 30
bigip2.example.com:
type: 'f5'
url: 'https://admin:password@10.0.2.245/'
run_interval: 30
cisco1.example.com:
type: 'cisco_ios'
credentials:
address: '10.0.1.246'
port: 22
username: 'admin'
password: 'password'
enable_password: 'password'
run_interval: 60
cisco2.example.com:
type: 'cisco_ios'
credentials:
address: '10.0.2.246'
port: 22
username: 'admin'
password: 'password'
enable_password: 'password'
run_interval: 60
Declare the device_manager::devices
class in a manifest and apply to the proxy Puppet agent:
node 'agent.example.com' {
include device_manager::devices
}
Manage multiple devices via the Classifier:
Declare multiple device_manager
resources, via the devices
parameter, to the device_manager::devices
class and apply to the proxy Puppet agent via the Classifier:
{
'bigip1.example.com' => {
type => 'f5',
url => 'https://admin:password@10.0.1.245/',
run_interval => 30,
},
'bigip2.example.com' => {
type => 'f5',
url => 'https://admin:password@10.0.2.245/',
run_interval => 30,
},
'cisco1.example.com' => {
type => 'cisco_ios'
credentials => {
address => '10.0.1.246',
port => 22,
username => 'admin',
password => 'password',
enable_password => 'password',
},
run_interval => 60,
}
'cisco2.example.com' => {
type => 'cisco_ios',
credentials => {
address => '10.0.2.246',
port => 22,
username => 'admin',
password => 'password',
enable_password => 'password',
},
run_interval => 60,
}
}
Defaults when managing multiple devices via Hiera or the Classifier:
When using the device_manager::devices
class, you can declare defaults (for all devices and for each device type) for device parameters via the device_manager::devices::defaults
key and apply to the proxy Puppet agent via Hiera:
device_manager::devices::defaults:
type: 'cisco_ios'
run_interval: 45
f5:
run_interval: 30
cisco_ios:
run_interval: 60
credentials:
port: 22
username: 'admin'
password: 'password'
enable_password: 'password'
This allows for deduplication of common parameters:
---
device_manager::devices:
bigip1.example.com:
type: 'f5'
url: 'https://admin:password@10.0.1.245/'
bigip2.example.com:
type: 'f5'
url: 'https://admin:password@10.0.2.245/'
cisco1.example.com:
credentials:
address: '10.0.1.246'
cisco2.example.com:
credentials:
address: '10.0.2.246'
The order of precedence for parameters and defaults is:
- The parameter in the resource declaration
- The default in
device_manager::devices::defaults::<DEVICE TYPE>
- The default in
device_manager::devices::defaults
Hash parameters (such as credentials
) are merged using the same precedence.
Run puppet device
Declaring these resources will configure device.conf
and apply the base class (if one is defined) of associated device modules on the proxy Puppet agent, allowing it to execute puppet device
runs on behalf of its configured devices:
puppet device --verbose --target bigip.example.com
Signing certificates
The first run of puppet device
for a device will generate a certificate request for the device:
Info: Creating a new SSL key for bigip.example.com
Info: Caching certificate for ca
Info: csr_attributes file loading from /opt/puppetlabs/puppet/cache/devices/bigip.example.com/csr_attributes.yaml
Info: Creating a new SSL certificate request for bigip.example.com
Info: Certificate Request fingerprint (SHA256): ...
Info: Caching certificate for ca
Unless autosign is enabled, the following (depending upon waitforcert
) will be output:
Notice: Did not receive certificate
Notice: Did not receive certificate
Notice: Did not receive certificate
...
Or:
Exiting; no certificate found and waitforcert is disabled
On the server, execute the following to sign the certificate for the device:
puppet cert sign bigip.example.com
This will output that the certificate for the device has been signed:
Signing Certificate Request for:
"bigip.example.com" (SHA256) ...
Notice: Signed certificate request for bigip.example.com
Notice: Removing file Puppet::SSL::CertificateRequest bigip.example.com at '/etc/puppetlabs/puppet/ssl/ca/requests/bigip.example.com.pem'
Parameters
name
Data type: String
This parameter is optional, and defaults to the title of the resource.
Specifies the certname
of the device.
ensure
Data type: String
This parameter is optional, with valid options of 'present' (the default) and 'absent'.
Setting to 'absent' deletes the device from device.conf
and the devices
fact, and negates the effect of any other parameters.
type
Data type: String
Specifies the type of the device in device.conf
on the proxy Puppet agent. This identifies the module used to access the device.
url
Data type: String
This parameter is required for devices that do not use the Puppet Resource API: refer to the associated device module documentation for details regarding its format. The url
and credentials
parameters are mutually exclusive.
url => 'https://admin:password@10.0.0.245/'
Specifies the URL of the device in device.conf
on the proxy Puppet agent.
credentials
Data type: Hash
This parameter is required for devices that use the Puppet Resource API: refer to the associated device module documentation for details regarding its format. The credentials
and url
parameters are mutually exclusive.
credentials => {
address => '10.0.0.246',
port => 22,
username => 'admin',
password => 'password',
enable_password => 'password',
}
This saves the credentials of the device in a HOCON file in confdir/devices
and specifies that file as the url
of the device in device.conf
on the proxy Puppet agent.
debug
Data type: Boolean
This parameter is optional, with a default of false.
Specifies transport-level debugging of the device in device.conf
on the proxy Puppet agent, and is limited to debugging the telnet and ssh transports.
Note: This parameter specifies the debug
property defined in: Config Files: device.conf rather than the --debug
option defined in: Man Page: puppet device.
include_module
Data type: Boolean
This parameter is optional, with a default of true.
Specifies automatically including the base class (if one is defined) of the associated device module (specified by the type
parameter) on the proxy Puppet agent. Device modules may implement a base class that applies an install
class. Including that class will install libraries required by the device module.
run_interval
Data type: Integer
This parameter is optional, with a default of 0.
Setting run_interval
to a value between 1 and 1440 will create a Cron (or on Windows, a Scheduled Task) resource for the device that executes puppet device --target
every run_interval
minutes (with a randomized offset) on the proxy Puppet agent. When creating a Cron resource, values greater than thirty minutes will be rounded up to the nearest hour.
Note: On versions of Puppet (lower than Puppet 5.x.x) that do not support puppet device --target
, this parameter will instead create one Cron (or Scheduled Task) resource that executes puppet device
for all devices in device.conf
every 60 minutes (at a randomized minute) on the proxy Puppet agent.
run_user
Data type: String
This parameter is optional, with a default of $::identity['user']
.
Specifies the user to own the configuration files and any cron job or scheduled task for the device on the proxy Puppet agent.
Note: On versions of Puppet (lower than Puppet 5.x.x) that do not support puppet device --target
, this parameter will not set the user
of the one Cron (or Scheduled Task) resource.
run_group
Data type: String
This parameter is optional, with a default of $::identity['group']
.
Specifies the group to own the configuration files for the device on the proxy Puppet agent.
Orchestration
Puppet Tasks
On versions of Puppet Enterprise (2017.3.x or higher) that support Puppet Tasks, this module provides a device_manager::run_puppet_device
task which can be used by the puppet task
command to orchestrate a puppet device
run on the proxy Puppet agent. Help for this task is available via: puppet task show device_manager::run_puppet_device
command.
Examples:
To run puppet device
for all devices in device.conf
on the specified proxy Puppet agent:
puppet task run device_manager::run_puppet_device --nodes 'agent.example.com'
To run puppet device
for all devices in device.conf
on the proxy Puppet agent identified by a PuppetDB query:
puppet task run device_manager::run_puppet_device --query 'inventory { facts.devices."bigip.example.com" = true }'
To run puppet device --target
for a specific device in device.conf
on the proxy Puppet agent identified by a PuppetDB query:
puppet task run device_manager::run_puppet_device --query 'inventory { facts.devices."bigip.example.com" = true }' target=bigip.example.com
Reference
For more information, see:
Reference
Table of Contents
Classes
device_manager::conf
device_manager::devices
device_manager::fact
device_manager::run
device_manager::run::via_cron::untargeted
device_manager::run::via_exec::untargeted
device_manager::run::via_scheduled_task::untargeted
Defined types
device_manager
device_manager::conf::device
device_manager::fact::device
device_manager::run::via_cron::device
device_manager::run::via_exec::device
device_manager::run::via_scheduled_task::device
Functions
Tasks
run_puppet_device
: Run puppet device on a (proxy) Puppet agent
Classes
device_manager::conf
The device_manager::conf class.
device_manager::devices
The device_manager::devices class.
Parameters
The following parameters are available in the device_manager::devices
class:
devices
Data type: Hash
Default value: {}
defaults
Data type: Hash
Default value: {}
device_manager::fact
The device_manager::fact class.
device_manager::run
The device_manager::run class.
device_manager::run::via_cron::untargeted
The device_manager::run::via_cron::untargeted class.
device_manager::run::via_exec::untargeted
The device_manager::run::via_exec::untargeted class.
device_manager::run::via_scheduled_task::untargeted
The device_manager::run::via_scheduled_task::untargeted class.
Defined types
device_manager
The device_manager class.
Parameters
The following parameters are available in the device_manager
defined type:
type
Data type: String[1]
url
Data type: String
Default value: ''
credentials
Data type: Hash
Default value: {}
debug
Data type: Boolean
Default value: false
run_interval
Data type: Integer[0,1440]
Default value: 0
run_via_exec
Data type: Boolean
Default value: false
run_user
Data type: String
Default value: $::identity['user']
run_group
Data type: String
Default value: $::identity['group']
include_module
Data type: Boolean
Default value: true
ensure
Data type: Enum[present, absent]
Default value: present
device_manager::conf::device
The device_manager::conf::device class.
Parameters
The following parameters are available in the device_manager::conf::device
defined type:
type
Data type: String
url
Data type: String
credentials
Data type: Hash
run_user
Data type: String
run_group
Data type: String
debug
Data type: Boolean
Default value: false
ensure
Data type: Enum[present, absent]
Default value: present
device_manager::fact::device
The device_manager::fact::device class.
Parameters
The following parameters are available in the device_manager::fact::device
defined type:
ensure
Data type: Enum[present, absent]
Default value: present
device_manager::run::via_cron::device
The device_manager::run::via_cron::device class.
Parameters
The following parameters are available in the device_manager::run::via_cron::device
defined type:
ensure
Data type: String
run_interval
Data type: Integer
run_user
Data type: String
device_manager::run::via_exec::device
The device_manager::run::via_exec::device class.
device_manager::run::via_scheduled_task::device
The device_manager::run::via_scheduled_task::device class.
Parameters
The following parameters are available in the device_manager::run::via_scheduled_task::device
defined type:
ensure
Data type: String
run_interval
Data type: Integer
run_user
Data type: String
Functions
device_manager::interval_to_cron_time
Type: Puppet Language
The device_manager::interval_to_cron_time function.
device_manager::interval_to_cron_time(Integer[0,1440] $interval, Integer[0,59] $offset)
The device_manager::interval_to_cron_time function.
Returns: Hash
interval
Data type: Integer[0,1440]
offset
Data type: Integer[0,59]
Tasks
run_puppet_device
Run puppet device on a (proxy) Puppet agent
Supports noop? true
Parameters
target
Data type: Optional[Pattern[/^[a-z0-9._-]+$/]]
The name of a device in device.conf on the (proxy) Puppet agent
timeout
Data type: Optional[Variant[Integer, Pattern[/^[0-9]+$/]]]
The timeout in seconds for the puppet device command(s), defaults to 64
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
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
v4.1.0 - 2023-10-19
Added
v4.0.0 - 2022-05-23
Changed
- (maint) Remove support for Puppet 5 #91 (david22swan)
Added
v3.1.0 - 2020-12-02
Added
Fixed
- run_user and run_group for device_manager::devices #76 (bFekete)
- (maint) confine and variables and ensure #74 (tkishel)
- Manage devices' config folder #73 (JonasVerhofste)
- Do not require aio_agent_version to be present #66 (fizmat)
- (MODULES-9628, PUP-8736) don't purge device certificates on new puppet versions (3.0.1 hotfix) #58 (DavidS)
v3.0.1 - 2019-08-14
Added
v3.0.0 - 2019-06-11
Fixed
- (maint) Relax version requirement for concat #49 (DavidS)
- (FM-8238, FM-8137) Dependency fixes #48 (DavidS)
v2.7.1 - 2019-04-10
Fixed
- (maint) removing the aio_agent_version fact check #41 (Thomas-Franklin)
- Tighter version bounding on puppetlabs/hocon #40 (rnelson0)
- Fix build issues on Jenkins #39 (da-ar)
2.7.0 - 2018-10-02
Added
- (FM-7230) Specify defaults for multiple devices when using Hiera or Classifier #24 (tkishel)
- (FM-7148) logdest scheduled runs to system log #16 (tkishel)
- (FM 7115) return device certificates with task results #15 (tkishel)
Fixed
- CVE-2018-11748 (FM-7258) Update device config file permissions #32 (willmeek)
- (FM-7383) allow device manager to work with Puppet 6 #27 (Thomas-Franklin)
- Pass through credentials from device_manager::devices #21 (DavidS)
- (FM-7114) purge conf devices directory #18 (tkishel)
2.6.0 - 2018-06-01
2.5.0 - 2018-05-31
Dependencies
- puppetlabs/concat (>= 3.0.0 < 10.0.0)
- puppetlabs/hocon (>= 1.0.0 < 2.0.0)
- puppetlabs/stdlib (>= 4.13.1 < 10.0.0)
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2018 Thomas Kishel Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.