node_orchestration
Version information
This version is compatible with:
- Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 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
- Puppet >= 6.21.0 < 9.0.0
- , , , , ,
Plans:
- bootstrap_agent
- create_azure_vm
- launch_ec2_instance
Start using this module
Add this module to your Puppetfile:
mod 'jtl-node_orchestration', '0.1.0'
Learn more about managing modules with a PuppetfileDocumentation
node_orchestration
Tasks and plans for automatically provisioning cloud instances, registering them to Puppet Enterprise, and bootstrapping Puppet agent on them.
Table of Contents
- Description
- Setup - The basics of getting started with node_orchestration
- Usage - Configuration options and additional functionality
- Limitations - OS compatibility, etc.
Description
This module wraps low-level automation for cloud providers to provide reasonable default settings and a simple user interface to create new nodes in Puppet Enterprise. The plans provided in this module will launch an instance, register it with the PE inventory service, and bootstrap Puppet agent on the new node. By looking up common organization settings from Hiera, consistency among the nodes managed by this automation is ensured. Puppet Orchestrator also provides granular access control that can eliminate the need for direct user access to the cloud providers.
Setup
Puppet Enterprise Requirements
- Define a
plan_hierarchy
in Hiera as described at https://www.puppet.com/docs/bolt/latest/hiera.html#outside-apply-blocks. - Create a new PE user role called "Inventory Manager" with the permissions
from type "Nodes" with action "add and delete connection information from
inventory service." Assign a new service account to this role and generate a
long-lived API token for the account, such as with the command:
puppet access login --lifetime 1y --print
. Provide the token in the Hiera plan hierarchy under the keynode_orchestration::api_token
. EYAML is suggested. - Tell the plan where to run its tasks with the Hiera plan hierarchy key
node_orchestration::task_server
. This is the server where you declared thenode_orchestration::aws
class. If this differs from your main Puppet server, also set thenode_orchestrator::puppet_server
key so the plan knows against which server to bootstrap the new agent.
AWS Requirements
- Create an IAM user with the
AmazonEC2FullAccess
policy. This policy is sufficient, but not necessarily required. There may be a reduced set of privileges that can be associated with this user. Create an access key for this user. Pass the key information to thenode_orchestration::aws
class which you should declare on your Puppet server, like:
These values can of course be set in Hiera.class { 'node_orchestration::aws': access_key_id => 'AKIASUQFAKEACCESSKEY', secret_access_key => Sensitive('the-secret-access-key'), region => 'us-east-1', # the default region to interact with }
- Create the following AWS resources: SSH key pair (note name and private key content), named subnet (VPC subnets have no names out of the box), and one or more named security groups.
- Somewhere in the Hiera plan hierarchy, define the following settings:
--- node_orchestration::ec2_key_name: 'the-key-name' node_orchestration::ec2_subnet: 'the-subnet-name' node_orchestration::ec2_security_groups: ['sg1', 'sg2', etc...] node_orchestration::ssh_private_key: > ENC[PKCS7,MII...the-eyaml-encrypted-private-key-contents]
Azure Requirements
- Create a new Enterprise Application object in the Azure Active Directory to represent this module. Take note of the resulting client ID and secret.
- Create a new Resource Group and Virtual Network to contain the VMs managed by this module.
- In the new Resource Group's access control (IAM) settings, add a "Contributor" role assignment for your new application principal.
- Declare the
node_orchestration::azure
class on your Puppet server to configure the Azure CLI for this module to use, like:class { 'node_orchestration::azure': tenant_id => 'ea383a66-fake-fake-fake-f3524734e142', # Active Directory ID client_id => '6b7f97e9-fake-fake-fake-ad4c99440348', client_secret => Sensitive('the-secret-access-key'), }
- Somewhere in the Hiera plan hierarchy, define the following settings:
--- node_orchestration::az_resource_group: 'ResourceGroupName' # that you created in step 2 node_orchestration::az_admin_password: > ENC[PKCS7,MII...the-eyaml-encrypted-initial-virtual-machine-password]
Beginning with node_orchestration
When the setup requirements are satisfied, the plans provided by this module can be run from the PE console.
Usage
node_orchestration::launch_ec2_instance
Create an EC2 instance with default settings.
instance_name
: The name of the instance to createsize
: The type of instance to create (small, medium, large)image_id
: Overrides the default AMI set in Hieraami_user
: Overrides the default AMI username set in Hierakey_name
: Overrides the default SSH key name set in Hierapublic_ip_address
: Overrides Hiera setting on whether to assign a public IP address. Subnet default takes priority.security_groups
: Overrides the default SG or list of SGs set in Hierasubnet
: Overrides the default subnet name set in Hieraregion
: Overrides the default region set in Hieraos_disk_size
: If set, the size of the OS disk in GB. Otherwise, use EC2 defaults.role
: Set thepp_role
extension request (trusted fact) to this value
The available sizes: small, medium, large; map to EC2 instance types t3.small,
t3.medium, and t3.large by default. This can be overridden with the
node_orchestration::ec2_instance_types
Hiera plan data hash to provide
reasonable organization defaults. Likewise, many of the plan parameters can be
expressed as defaults in Hiera plan data.
node_orchestration::create_azure_vm
Create an Azure VM with default settings.
vm_name
: The name of the VM to createsize
: The type of VM to create (small, medium, large)image_id
: Overrides the default image ID set in Hieraadmin_user
: Overrides the initial VM username set in Hieraadmin_password
: Overrides the initial VM password set in Hierapublic_ip_address
: Overrides Hiera setting on whether to assign a public IP addressresource_group
: Overrides the resource group set in Hieraos_disk_size
: If set, the size of the OS disk in GB. Otherwise, use Azure defaults.data_disk_sizes
: The sizes of the data disks to attach in GBrole
: Set thepp_role
extension request (trusted fact) to this value
The available sizes: small, medium, large; map to VM sizes Standard_B1s,
Standard_B2s, and Standard_D2s_v3 by default. This can be overridden with the
node_orchestration::az_vm_sizes
Hiera plan data hash to provide reasonable
organization defaults. Likewise, many of the plan parameters can be expressed
as defaults in Hiera plan data.
Limitations
This is a proof-of-concept module that provides basic support for AWS and Azure. Not all the settings you might want to control are exposed, but the plans as implemented aim to demonstrate various ways those settings can be defined: as parameters, in module data, and Hiera. Implementations for other cloud providers may look very different from these initial versions. Please open an issue with features you'd like to see.
Support for Windows nodes has been tested in Azure but not EC2. In Azure,
bootstrapping a Windows node can be triggered by passing an image_id
containing Win
, as all the Azure-provided Windows images have. This interface
is subject to change based on future development and feedback.
Reference
Table of Contents
Classes
node_orchestration::aws
: Configure pre-requisites for puppetlabs-aws modulenode_orchestration::azure
: Configure Azure CLI needed by this module's plans
Plans
node_orchestration::bootstrap_agent
: Register a new node in the PE inventory and run pe_bootstrap against itnode_orchestration::create_azure_vm
: Create an Azure VM with default settingsnode_orchestration::launch_ec2_instance
: Create an EC2 instance with default settings
Classes
node_orchestration::aws
Configure pre-requisites for puppetlabs-aws module
Parameters
The following parameters are available in the node_orchestration::aws
class:
access_key_id
Data type: String
IAM access key with EC2 privileges
secret_access_key
Data type: Sensitive
IAM secret access key associated with the access key ID
region
Data type: String
The default AWS region to interact with
node_orchestration::azure
Configure Azure CLI needed by this module's plans
Parameters
The following parameters are available in the node_orchestration::azure
class:
tenant_id
Data type: String
The Azure AD tenant ID containing your app registration
client_id
Data type: String
The ID associated with your app registration
client_secret
Data type: Sensitive
The password assigned to your app registration
Plans
node_orchestration::bootstrap_agent
Register a new node in the PE inventory and run pe_bootstrap against it
Parameters
The following parameters are available in the node_orchestration::bootstrap_agent
plan:
name
Data type: String
The desired node certname
hostname
Data type: Stdlib::Host
The real hostname or IP address of the node to bootstrap
user
Data type: String
The SSH user to bootstrap with
password
Data type: Optional[Sensitive]
Default value: undef
role
Data type: Optional[String]
Default value: undef
node_orchestration::create_azure_vm
Create an Azure VM with default settings
Parameters
The following parameters are available in the node_orchestration::create_azure_vm
plan:
vm_name
size
image_id
admin_user
admin_password
public_ip_address
resource_group
os_disk_size
data_disk_sizes
role
vm_name
Data type: String
The name of the VM to create
size
Data type: Enum['small', 'medium', 'large']
The type of VM to create (small, medium, large)
image_id
Data type: Optional[String]
Overrides the default image ID set in Hiera
Default value: undef
admin_user
Data type: Optional[String]
Overrides the initial VM username set in Hiera
Default value: undef
admin_password
Data type: Optional[Sensitive]
Overrides the initial VM password set in Hiera
Default value: undef
public_ip_address
Data type: Optional[Boolean]
Overrides Hiera setting on whether to assign a public IP address
Default value: undef
resource_group
Data type: Optional[String]
Overrides the resource group set in Hiera
Default value: undef
os_disk_size
Data type: Optional[Integer]
If set, the size of the OS disk in GB. Otherwise, use Azure defaults.
Default value: undef
data_disk_sizes
Data type: Array[Integer]
The sizes of the data disks to attach in GB
Default value: []
role
Data type: Optional[String]
Set the pp_role
extension request (trusted fact) to this value
Default value: undef
node_orchestration::launch_ec2_instance
Create an EC2 instance with default settings
Parameters
The following parameters are available in the node_orchestration::launch_ec2_instance
plan:
instance_name
size
image_id
ami_user
key_name
public_ip_address
security_groups
subnet
region
os_disk_size
role
instance_name
Data type: String
The name of the instance to create
size
Data type: Enum['small', 'medium', 'large']
The type of instance to create
image_id
Data type: Optional[String]
Overrides the default AMI set in Hiera
Default value: undef
ami_user
Data type: Optional[String]
Overrides the default AMI username set in Hiera
Default value: undef
key_name
Data type: Optional[String]
Overrides the default SSH key name set in Hiera
Default value: undef
public_ip_address
Data type: Optional[Boolean]
Overrides Hiera setting on whether to assign a public IP address. Subnet default takes priority.
Default value: undef
security_groups
Data type: Optional[Array[String]]
Overrides the default SG or list of SGs set in Hiera
Default value: undef
subnet
Data type: Optional[String]
Overrides the default subnet name set in Hiera
Default value: undef
region
Data type: Optional[String]
Overrides the default region set in Hiera
Default value: undef
os_disk_size
Data type: Optional[Integer]
If set, the size of the OS disk in GB. Otherwise, use EC2 defaults.
Default value: undef
role
Data type: Optional[String]
Set the pp_role
extension request (trusted fact) to this value
Default value: undef
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.
Release 0.1.0
Initial release.
Features
Provision basic nodes into AWS and Azure and bootstrap them with Puppet Agent.
Bugfixes
None.
Known Issues
The launch_ec2_instance
plan depends on the deprecated
puppetlabs/aws
module.
Dependencies
- puppetlabs-aws (>= 2.0.0 < 3.0.0)
- puppetlabs-inifile (>= 5.0.0 < 7.0.0)
- puppetlabs-stdlib (>= 8.0.0 < 10.0.0)