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, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2016.4.x
- Puppet >= 4.10.0 < 9.0.0
- CentOS, OracleLinux, RedHat, Scientific, Debian, Ubuntu, SLES, Fedora
Plans:
- approle_agent
Start using this module
Add this module to your Puppetfile:
mod 'southalc-vault_secrets', '0.6.1'
Learn more about managing modules with a PuppetfileDocumentation
vault_secrets
Table of Contents
NOTICE
Version 0.6.0 of the module changes the following properties of the custom 'vault_cert" type:
- Old "ca_chain_file" property is now "cert_chain_file"
- Old "ca_chain_owner" property is now "cert_chain_owner"
- Old "ca_chain_group" property is now "cert_chain_group"
- Old "ca_chain_mode" property is now "cert_chain_mode"
- Old "ca_chain" property is now "cert_chain"
The format of the "cert_chain_file" begins with the host certificate followed by any subordinate CA certificates and ending with the root certificate.
You can now specify the "ca_trust" parameter with the "vault_cert" and "vault_ssh_cert" types. This allows the types to be used on operating systems other than RedHat and Debian variants.
Description
This module provides functions, types, and providers to integrate Hashicorp Vault with Puppet, and uses the main module class to enable issuing and renewing host certificates from a Vault PKI secrets engine. If you only want to use the functions without issuing host certificates from Vault, add the module to an environment without assigning it to any nodes.
The custom hiera backend vault_hiera_hash
enables the puppet server to use a Vault key/value secrets engine as a hiera
data_hash. This allows storing multiple key/value pairs on a given Vault path and using it from hiera much like local
YAML files. The function supports both v1 and v2 of the Vault key/value secrets engine and is useful to easily separate
secrets from other version controlled hiera data. The vault_secrets::approle_agent
plan can be used to obtain a Vault
token for use with hiera, or the Puppet certificate can be used for certificate authentication to Vault.
The vault_hash
and vault_key
functions also support Vault key/value secrets engines version 1 and 2 and can be used
in manifests to get secrets from Vault. With Puppet agents 6 and later you can also use
deferred functions to enable clients to get secrets
directly from Vault without passing them through the Puppet server in a catalog.
The vault_cert
custom resource type can be used to manage TLS certificates for use by other applications. These are
issued by Vault directly to agents (private keys are not stored on puppet servers or in the catalog), and renewed
automatically as needed. Note that this requires puppet agents to authenticate to Vault using the agent certificate
and request a Vault certificate from a configured role on a PKI secrets engine.
Setup
The module does not require any extra ruby gems on the Puppet server or agents. Obviously you need to have a working Hashicorp Vault deployment first. The following describes a basic Vault configuration to support puppet integration.
Complete the following steps on the Vault server:
- Enable a kv secrets engine on path 'puppet/'. This example is for version 1 of the k/v engine:
vault secrets enable -path=puppet -description="Puppet data" -version=1 kv
-
Use the Vault UI or command line to create a secret under the 'puppet/' path. This example will use the name "common" as the secret name for storing key/value secrets common to all nodes.
-
Configure Vault to enable authentication with certificates issued by the puppet certificate authority. From a puppet node you can reference the puppet CA certificate from: '/etc/puppetlabs/puppet/ssl/certs/ca.pem'. When using PKI authentication, the module functions will authenticate every Vault request independently, so use a low "ttl" value to keep from building up many active Vault tokens. You can skip this step if you only want to use Vault as a backend for hiera and will not be using deferred functions or the
vault_cert
type.
vault auth enable -path=puppet-pki -description="PKI authentication with Puppet certificates" cert
vault write auth/puppet-pki/certs/puppetCA \
display_name="Puppet CA" \
policies=puppet \
certificate=@/etc/puppetlabs/puppet/ssl/certs/ca.pem \
ttl=60
- Optionally enable a PKI secrets engine on Vault to serve as a certificate authority and get dynamic provisioning of X.509 certificates.
vault secrets enable -description="PKI service" -path=pki pki
With the 'pki' secrets engine enabled, create a certificate authority for Vault. There are several options to set this up, depending on your security requirements. Choose one of the following methods:
Option 1 - Create a new root CA in Vault. When setting up a root CA, you will likely want to increase the max lifetime of the certificate first. It seems Vault doesn't understand logical units for days or years, so we are forced in to using hours (this example is ~10 years in hours):
vault secrets tune -max-lease-ttl=87600h pki
With the max lifetime set to a reasonable value for a root CA, generate the new root certificate in Vault, using the max TTL:
vault write pki/root/generate/internal common_name='Vault Root CA' ttl=87600h
Option 2 - From Vault, create a certificate signing request for a subordinate certificate authority. Submit the CSR to an external CA for signing, then import the signed certificate into Vault. First, set the max lifetime of certificates to a good working value for a subordinate CA. This example is 5 years, in hours:
vault secrets tune -max-lease-ttl=43800h pki
Generate the subordinate CSR from Vault, using a common name as you like and using the max TTL we just defined:
vault write pki/intermediate/generate/internal common_name="Sub CA" ttl=43800h
Capture the CSR from the output of the last command and submit it to the upstream CA for signing. When you get the signed certificate back, import the upstream CA certificate into Vault, then import the the signed subordinate CA certificate:
vault write pki/intermediate/set-signed certificate=@signed_certificate.pem
Option 3 - Externally from Vault, generate a signed certificate for a subordinate CA. Create a certificate chain beginning with the private key of the subordinate CA, the signed subordinate certificate, any intermediate CA certificates, and finally the root CA certificate. The private key of the new subordinate CA will need to be in decrypted form for the certificate chain to be imported into to Vault:
vault write pki/config/ca pem_bundle=@subca-chain.pem
With the certificate authority established, define the endpoints for issuing certificates and revocation lists. These can be modified later if needed:
vault write pki/config/urls \
issuing_certificates="http://vault.example.local:8200/v1/pki/ca" \
crl_distribution_points="http://vault.example.local:8200/v1/pki/crl"
Configure one or more roles for the pki service. The role is where the certificate attributes can be defined. Policy can be used to enable access to different roles as needed:
vault write pki/roles/example-local \
allowed_domains=example.local \
allow_subdomains=true max_ttl=168h \
organization=Example \
ou=Automation \
country=US \
To view all the possible settings that could be defined by the role:
vault read pki/roles/example-local
To issue a certificate from the pki service, invoke a write to the role. We'll be using this Puppet module to automate this and to automatically renew certificates as they near the expiration date.
vault write pki/issue/example-local common_name=myhost.example.local
- Create a policy on Vault to enable access to Puppet data. This policy example grants read access to everything under the Vault path "puppet/nodes" and the specific Vault path "puppet/common". The "pki/issue/example-local" is granted 'update' access to enable Puppet to obtain PKI certificates from the configured role on the Vault certificate authority. Applying this policy to the 'puppet-pki' authentication path will enable any Puppet certificate to authenticate and access these Vault paths. Review the Vault documentation for managing access to Vault with policies. Save the policy to a file:
path "puppet/nodes/*" {
capabilities = ["read"]
}
path "puppet/common" {
capabilities = ["read"]
}
path "pki/issue/example-local" {
capabilities = ["update"]
}
path "ssh-host/sign/puppet" {
capabilities = ["create", "update"]
}
Write the policy to Vault on the 'puppet-pki' authentication path:
vault policy write puppet-pki <file>
Usage
Here are some examples of using the module functions to obtain secrets from Vault. The 'vault_hash' function returns a hash of all keys/values from a Vault server on a given path, authenticating with the 'puppet-pki' method:
$vault_hash = vault_hash('https://vault.example.com:8200/v1/puppet/common', 'puppet-pki')
notify { 'hash_example' :
message => $vault_hash,
}
The 'vault_key' function returns only the value from the specified Vault URI, path, and key:
$vault_value = vault_key('https://vault.example.com:8200/v1/puppet/common', 'puppet-pki', 'secret_key')
notify { 'key_example' :
message => $vault_value,
}
Functions may be deferred so they run from the managed node instead of the Puppet server. This way the secret is passed directly from Vault to the client where it is needed:
$deferred_hash = Deferred('vault_hash', ['https://vault.example.com:8200/v1/puppet/common', 'puppet-pki'])
notify { 'deferred_example' :
message => $deferred_hash,
}
$deferred_value = Deferred('vault_key', ['https://vault.example.com:8200/v1/puppet/common', 'puppet-pki', 'secret_key'])
notify { 'deferred_example' :
message => $deferred_value,
}
Vault as a hiera backend
Configure an environment to use the custom hiera backend by using the 'vault_hiera_hash' function for the data_hash. This enables the Puppet server to lookup all key/value pairs stored on a Vault secrets path in a single lookup. You can also pass an array of 'uris' that may include variable references to be interpolated at runtime. Note that each uri results in a separate Vault request and will incur some overhead on the Puppet server.
hierarchy:
- name: "Secrets from Vault"
data_hash: vault_hiera_hash
uri: "https://vault.example.com:8200/v1/puppet/common" # Secrets common to all nodes
options:
timeout: 3
auth_path: "puppet-pki"
Example configuration using Vault for hiera data using multiple search paths and a pre-staged Vault token to avoid authentication overhead with each lookup. When using a Vault token, ensure the 'token_file' has read permissions by the user running the Puppet server process. Obviously this is a security sensitive file that should be protected from all other access. A Vault agent with an app role is useful for this.
hierarchy:
- name: "Secrets from Vault"
data_hash: vault_hiera_hash
uris:
- "https://vault.example.com:8200/v1/puppet/nodes/%{fqdn}" # Node specific secrets
- "https://vault.example.com:8200/v1/puppet/common" # Secrets common to all nodes
options:
token_file: "/run/vault-puppet/puppetserver.token" # Sink file from 'vault_secrets::approle_agent' plan
Vault agent for use with the hiera backend
The Vault AppRole method is used by applications to authenticate to Vault and obtain a token. An AppRole defines a token policy and will issue a token when an application authenticates to the AppRole using the role ID and secret ID. The following steps will enable an AppRole on Vault for use with hiera lookup from the Puppet server:
- Enable the AppRole authentiation method:
vault auth enable approle
- Define an app role by specifying the token policies and TTL (period). Note that a periodic token is the only type that may be renewed indefinately, which is what we want for long-running application services like hiera on Puppet. We will re-use the "puppet" policy defined in the previous Vault setup steps:
vault write auth/approle/role/puppet policies="puppet" period="24h"
- Get the role ID for the defined role:
vault read -format=json auth/approle/role/puppet/role-id | jq -r ".data.role_id"
- Generate a secret ID for the role:
vault write -f -format=json auth/approle/role/puppet/secret-id | jq -r ".data.secret_id"
- Authenticating to the AppRole with the role ID and secret ID results in a token being issued per the assigned role policy. This step is shown just for demonstration purposes:
vault write auth/approle/login role_id=<role_id> secret_id=<secret_id>
With the Vault AppRole in place we can configure the Puppet server to perform hiera lookups from Vault using a token issed by the AppRole to a Vault agent. This is more efficient than using Puppet certificates to authenticate to Vault for every request. To simplify configuration of the Vault agent, the module includes the defined type "vault_secrets::approle_agent" and a plan of the same name. The plan and type can install Vault and configure the Vault agent using an existing AppRole. The Vault agent will be configured to run as a systemd service to ensure it starts automatically on boot-up and the token will be available for hiera lookups. The Vault agent service also handles renewal of the token as needed.
You can use the defined type in Puppet manifests to deploy Vault agents to nodes, but the "role_id" and "secret_id" values are sensitive and should be probably be stored in Vault. To deploy the Vault agent to the puppet server itself without storing these values in hiera, run the plan either with Bolt or from the PE console.
If you haven't used Bolt to run plans before, you'll need to:
- Initialize a project directory with the required modules:
mkdir approle_agent
cd approle_agent
bolt project init approle_agent --modules southalc/vault_secrets
-
Update the project inventory.yaml to include the targets you want to manage.
-
Run the plan. This example configures a Vault agent on server "puppet.example.com" with the sink file owner set to "pe-puppet". The sink file is where the Vault token will be saved and uses a fixed path of "/run/vault-${owner}/${application}.token" where "owner" and "application" are the values passed to the plan:
bolt plan run vault_secrets::approle_agent \
--targets puppet.example.com \
'vault_addr=https://vault.example.com:8200' \
role_id=<YOUR_ROLE_ID> \
secret_id=<YOUR_SECRET_ID> \
application=puppetserver \
owner=puppet \
--run-as root
Note that the "vault_secrets::approle_agent" type and plan rely on systemd and will only work on Linux systems. Also, automatic Vault installation will only work for RedHat and Debian variants supported by hashi_stack.
Vault-issued certificates directly to nodes
Include the vault_secrets::vault_cert
class to ensure required directories are created
and then use the vault_cert
resource type for each certificate you wish to manage.
This resource will authenticate to vault using the agent's Puppet certificate, and write
the key, certificate and chain files so they can be consumed by another application.
The private key is written only on the agent, and is not revealed to the puppet server
or included in the catalog.
Certificates will be renewed automatically when puppet runs and there are fewer days
remaining than the renewal_threshold
parameter is set to, or if the certificate is
found to already be expired.
By default, all files are written to the directory specified by the $::vault_cert_dir
fact, however the issued certificate and key files can be written to arbitrary locations.
File ownership and permissions can also be customised as shown below.
include vault_secrets::vault_cert
vault_cert { 'test':
ensure => present,
vault_uri => 'https://vault.example.com:8200/v1/pki/issue/role',
auth_path => 'puppet-pki', # mount point for the pki auth engine
auth_name => 'puppetCA', # optionally limit to this auth role name
cert_data => {
'common_name' => 'test.example.com',
'alt_names' => ['alias.exmaple.com', 'localhost'].join(','),
'ip_sans' => [$::facts['networking']['ip'], '127.0.0.1'].join(','),
'ttl' => '2160h', # 90 days
},
# Optional
renewal_threshold => 5,
cert_chain_file => '/srv/myapp/ca.crt',
cert_chain_owner => 'myapp',
cert_chain_group => 'myapp',
cert_file => '/srv/myapp/server.crt',
cert_owner => 'myapp',
cert_group => 'myapp',
key_file => '/srv/myapp/server.key',
key_owner => 'myapp',
key_group => 'myapp',
}
You can purge certificates from the system which are no longer included in the puppet
catalog by setting vault_sercrets::vault_cert::purge: true
in hiera, or like the below:
class { 'vault_secrets::vault_cert':
purge => true,
}
vault_cert
resources will autorequire any File
resources coresponding to
the parent directories of the cert_chain_file
, cert_file
and key_file
properties. Any User
or Group
resources corresponding to the *_owner
or *_group
properties will also be autorequired.
Issue SSH certificates from Vault
The vault_ssh_cert
type can be used to deploy signed SSH certificates issued by
the SSH Secrets Engine in Vault. This type will authenticate to Vault during catalog
apply using the host's puppet certificate and then attempt to sign an existing
public key from disk if a corresponding certificate does not exist or is past
the expiration threshold. Certificates will be automatically renewed when past the
renewal_threshold
number of days before expiration.
vault_ssh_cert {
'/etc/ssh/ssh_host_rsa_key.pub':
ensure => present,
vault_uri => "${vault_address}/v1/ssh-host/sign/puppet",
auth_path => 'puppet-pki',
valid_principals => [$trusted['certname']];
}
You can setup vault to allow this using something like the following, in addition to the general setup instructions above.
vault secrets enable -path ssh-host ssh
vault write ssh-host/config/ca generate_signing_key=true
vault write ssh-host/roles/puppet key_type=ca allowed_domains=example.com allow_subdomains=true
Note, this will allow puppet nodes to issue certificates valid for any hostname, and this may not be secure enough for production use. You may wish to tweak the ssh secret engine role to further lock down what certificates may be issued to each node.
Limitations
Should work with all supported releases of Puppet server, but has been only minimally tested. Deferred functinos require Puppet 6 or later.
Reference
Table of Contents
Classes
vault_secrets
: Issue and renew PKI certificates from Hashicorp Vaultvault_secrets::vault_cert
: Manage paths and files for Vault certificates
Defined types
vault_secrets::approle_agent
: Configure a Vault agent for use with an existing AppRole and save the resulting token to a sink file at "/run/vault-${owner}/${title}.token"
Resource types
vault_cert
: A type representing a certificate issued by Hashicorp Vaultvault_ssh_cert
: A type representing an SSH certificate issued by Hashicorp Vault
Functions
vault_cert
: Obtain a host certificate from a Vault PKI secrets enginevault_hash
: Return a hash from a Vault key/value secrets engine pathvault_hiera_hash
: Custom hiera back-end for Hashicorp Vault key/value secrets engines v1 and v2vault_key
: Return the value from a Vault key/value secrets engine from a given path and key
Plans
vault_secrets::approle_agent
: Plan configures a Vault agent for use with an existing AppRole
Classes
vault_secrets
Issue and renew PKI certificates from Hashicorp Vault
Examples
Issue a host certificate from a Vault server with PKI secrets engine
class { 'vault_secrets':
vault_uri => 'https://vault.example.com:8200/v1/pki/issue/example-com',
auth_path => 'puppet-pki',
}
Parameters
The following parameters are available in the vault_secrets
class:
vault_uri
Data type: String
The complete URL of the the Hashicorp Vault certificate issuing role API endpoint
auth_path
Data type: String
The Vault mount path of the authentication provider used by Puppet certificates. ('path' shown by 'vault secrets list')
days_before_renewal
Data type: Integer[1, 30]
The number of days before expiration where the host certificate will be re-issued.
Default value: 3
cert_data
Data type: Hash
A hash of values to be submitted with the certificate request. The hash contents should adhere to the keys/values supported/permitted by the PKI role and policy. Basic default values are defined in module hiera.
Default value: {}
vault_secrets::vault_cert
Manage paths and files for Vault certificates
Parameters
The following parameters are available in the vault_secrets::vault_cert
class:
purge
Data type: Boolean
Clean up certificate files no longer managed by puppet.
Default value: false
Defined types
vault_secrets::approle_agent
Configure a Vault agent for use with an existing AppRole and save the resulting token to a sink file at "/run/vault-${owner}/${title}.token"
-
Note The defined type name permits only alpha-numeric characters and underscores.
-
See also
Examples
Create a Vault agent for use with vault_hiera_hash
vault_secrets::approle_agent { 'puppetserver':
vault_addr => 'https://vault.example.com:8200',
role_id => 'your_roleId_guid',
secret_id => 'your_secretId_guid',
owner => 'pe-puppet',
}
Parameters
The following parameters are available in the vault_secrets::approle_agent
defined type:
ensure
Data type: Enum['present', 'absent']
Add or remove the Vault agent configuration.
Default value: 'present'
vault_addr
Data type: String
The URL of the Vault service.
role_id
Data type: String
The RoleID of the Vault AppRole.
secret_id
Data type: String
The SecretID of the Vault AppRole.
owner
Data type: String
The user name that will own the Vault agent sink file.
install_vault
Data type: Boolean
Install Vault using the "hashi_stack::repo" class. Use hiera to set parameters for customizing the installation.
Default value: true
Resource types
vault_cert
A type representing a certificate issued by Hashicorp Vault
Properties
The following properties are available in the vault_cert
type.
cert
Valid values: auto
Read-only property which contains the value of the certificate
Default value: auto
cert_chain
Valid values: auto
Read-only property which contains the value of the CA chain
Default value: auto
cert_chain_file
Where the CA chain file should be written
cert_chain_group
The group which the cert_chain_file should be owned by
Default value: root
cert_chain_mode
The file mode the cert_chain_file should be written with
Default value: 0644
cert_chain_owner
The user which the cert_chain_file should be owned by
Default value: root
cert_data
The attributes of the certificate to be issued
cert_file
Where the certificate file should be written
cert_group
The group which the cert_file should be owned by
Default value: root
cert_mode
The file mode the cert _file should be written with
Default value: 0644
cert_owner
The user which the cert_file should be owned by
Default value: root
ensure
Valid values: present
, absent
The basic property that the resource should be in.
Default value: present
expiration
Valid values: auto
Read-only property showing the expiration time of the certificate
Default value: auto
info_cert
Valid values: auto
Read-only property which contains the value of the cerificate from the info file
Default value: auto
info_cert_chain
Valid values: auto
Read-only property which contains the value of the CA chain from the info file
Default value: auto
info_group
The group which the info_file should be owned by
Default value: root
info_key
Valid values: auto
Read-only property which contains the value of the private key from the info file
Default value: auto
info_mode
The file mode the info_file should be written with
Default value: 0600
info_owner
The user which the info_file should be owned by
Default value: root
key
Valid values: auto
Read-only property which contains the value of the privat ekey
Default value: auto
key_file
Where the key file should be written
key_group
The group which the key_file should be owned by
Default value: root
key_mode
The file mode the key file should be written with
Default value: 0600
key_owner
The user which the key_file should be owned by
Default value: root
Parameters
The following parameters are available in the vault_cert
type.
auth_name
The named certificate role used to authenticate puppet agent to vault
auth_path
The path used to authenticate puppet agent to vault
Default value: puppet-pki
ca_trust
Optional path to the file containing trusted certificate authorities
name
namevar
The name of the certificate
provider
The specific backend to use for this vault_cert
resource. You will seldom need to specify this --- Puppet will usually
discover the appropriate provider for your platform.
renewal_threshold
Certificate should be renewed when fewer than this many days remain before expiry
Default value: 3
timeout
Length of time to wait on vault connections
Default value: 5
vault_uri
The full URI of the vault PKI secrets engine
vault_ssh_cert
A type representing an SSH certificate issued by Hashicorp Vault
Properties
The following properties are available in the vault_ssh_cert
type.
ensure
Valid values: present
, absent
The basic property that the resource should be in.
Default value: present
expiration
Valid values: auto
Read-only property showing the expiration time of the certificate
Default value: auto
file
Path the signed certificate should be written
group
The group which the certificate file should be owned by
Default value: root
mode
The file mode the certificate file should be written with
Default value: 0640
owner
The user which the certificate file should be owned by
Default value: root
valid_principals
Users or hostnames which the issued certificate should be valid for
Default value: []
Parameters
The following parameters are available in the vault_ssh_cert
type.
auth_name
The named certificate role used to authenticate puppet agent to vault
auth_path
The path used to authenticate puppet agent to vault
Default value: puppet-pki
ca_trust
Optional path to the file containing trusted certificate authorities
cert_type
Cert type to issue ("user" or "host")
Default value: host
name
namevar
Path to the public key the certificate should be issued for
provider
The specific backend to use for this vault_ssh_cert
resource. You will seldom need to specify this --- Puppet will
usually discover the appropriate provider for your platform.
renewal_threshold
Certificate should be renewed when fewer than this many days remain before expiry
Default value: 3
timeout
Length of time to wait on vault connections
Default value: 5
ttl
Lifetime to request any newly issued certificates should be valid for
vault_uri
The full URI of the vault PKI secrets engine
Functions
vault_cert
Type: Ruby 4.x API
Obtain a host certificate from a Vault PKI secrets engine
vault_cert(String $vault_uri, String $auth_path, Hash $data, Optional[Integer] $timeout, Optional[String] $ca_trust)
Obtain a host certificate from a Vault PKI secrets engine
Returns: Hash
The returned hash contains the certificate, private key, and supporting data
vault_uri
Data type: String
The complete API path to a Vault PKI role for issuing certificates.
auth_path
Data type: String
The Vault mount path of the "cert" authentication type used with Puppet certificates.
data
Data type: Hash
A hash of values to be submitted with a certificate request. The hash contents must adhere to the constructs of the Vault PKI role and policy being used at the 'vault_uri' endpoint.
timeout
Data type: Optional[Integer]
Value in seconds to wait for Vault connections. Default is 5.
ca_trust
Data type: Optional[String]
The path to the trusted certificate authority chain file. Some OS defaults will be attempted if nil.
vault_hash
Type: Ruby 4.x API
Return a hash from a Vault key/value secrets engine path
vault_hash(String $vault_uri, String $auth_path, Optional[String] $version, Optional[Integer] $timeout, Optional[String] $ca_trust)
Return a hash from a Vault key/value secrets engine path
Returns: Hash
Contains all the key/value pairs from the given path.
vault_uri
Data type: String
The full URI to the Vault API endpoint for a key/value secrets engine path.
auth_path
Data type: String
The Vault mount path of the 'cert' authentication type used with Puppet certificates.
version
Data type: Optional[String]
Set this value to 'v2' to use version 2 of the Vault key/value secrets engine.
timeout
Data type: Optional[Integer]
Value in seconds to wait for Vault connections.
ca_trust
Data type: Optional[String]
The path to the trusted certificate authority chain file. Some OS defaults will be attempted if nil.
vault_hiera_hash
Type: Ruby 4.x API
Custom hiera back-end for Hashicorp Vault key/value secrets engines v1 and v2
vault_hiera_hash(Hash $options, Puppet::LookupContext $context)
Custom hiera back-end for Hashicorp Vault key/value secrets engines v1 and v2
Returns: Hash
All key/value pairs from the given Vault path will be returned to hiera
options
Data type: Hash
uri, ca_trust, token_file, auth_path, version, timeout, fail_hard
Options:
- :uri
String
: Required. The complete URL to the API endpoint for Hashicorp Vault key/value secrets. - :ca_trust
String
: Optional path to a trusted CA certificate chain file. Will try system defaults for RedHat/Debian if not set. - :token_file
String
: The path to a file that contains a Vault token. When not defined it will try PKI auth with Puppet cert. - :auth_path
String
: Optional. The Vault path for the "cert" authentication type used with Puppet certificates. - :version
String
: The Vault key/value secrets engine will always use 'v1' unless set to 'v2' here. - :timeout
Integer
: Optional value for tuning HTTP timeouts. Default is 5 seconds. - :fail_hard
Boolean
: Optional Raise an exception on errors when true, or return an empty hash when false. (false)
context
Data type: Puppet::LookupContext
vault_key
Type: Ruby 4.x API
Return the value from a Vault key/value secrets engine from a given path and key
vault_key(String $vault_uri, String $auth_path, String $key, Optional[String] $version, Optional[Integer] $timeout, Optional[String] $ca_trust)
Return the value from a Vault key/value secrets engine from a given path and key
Returns: String
The value of the secret from the @vault_uri and @key
vault_uri
Data type: String
The complete API path to a Vault key/value secret
auth_path
Data type: String
The Vault mount path of the "cert" authentication type used with Puppet certificates.
key
Data type: String
The name of a specific secret at the given 'vault_uri'
version
Data type: Optional[String]
Set this value to 'v2' to use version 2 of the Vault key/value secrets engine
timeout
Data type: Optional[Integer]
Value in seconds to wait for a response from Vault
ca_trust
Data type: Optional[String]
The path to the trusted certificate authority chain file. Some OS defaults will be attempted if nil.
Plans
vault_secrets::approle_agent
Plan configures a Vault agent for use with an existing AppRole
Parameters
The following parameters are available in the vault_secrets::approle_agent
plan:
action
Data type: Enum['install', 'remove']
Install or remove the specified Vault agent service
Default value: 'install'
application
Data type: String
Used as a component resource names. The Vault agent sink is: "/run/vault-${owner}/${application}.token"
vault_addr
Data type: String
The URL of the Vault service.
role_id
Data type: Sensitive
String - The RoleID of the Vault AppRole.
secret_id
Data type: Sensitive
String - The SecretID of the Vault AppRole.
owner
Data type: String
The user name that will own the Vault agent sink file.
install_vault
Data type: Boolean
Install Vault using the "hashi_stack::repo" class. Set parameters for "hashi_stack::repo" in hiera to customize the installation.
Default value: true
targets
Data type: TargetSpec
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
Release 0.6.1
- Bugfix. Fix approle services #20. Submitted by dmaes
- Bumped module metadata to support latest puppet and dependency versions.
Release 0.6.0
- Certificate chain with intermediate authority #17. Requested by Enucatl. This changes the behavior of the 'vault_cert' custom type so the content of the certificate chain file begins with the host certificate followed by the issuing CA chain.
- New optional 'ca_trust' parameter for both the 'vault_cert' and 'vault_ssh_cert' types should enable support for OS distro/variants other than RedHat and Debian.
- Updated the 'vault_cert' fact to enable expanded operating system support and replaced openssl commands with native ruby methods. This is only used only when issuing Vault certificates through the Puppet server instead of directly to agents.
Release 0.5.2
Bugfix - Enable the vault-token service service in the approle_agent
Release 0.5.1
Bugfix - Data type correction. Contributed by luckyraul
Release 0.5.0
- New 'vault_ssh_cert' custom type to manage signed SSH host keys with Vault. Contributed by optiz0r.
Release 0.4.5
- Make fail_hard configurable from vault_hiera_hash #11. Contributed by gibbs
- Include full URLs in failure messages instead of just the relative path.
Release 0.4.4
Bugfix - Rename the "Vault" ruby class to avoid naming conflicts with Puppet module "jsok/vault".
Release 0.4.3
Bugfix - Use gsub instead of delete_prefix to support older puppet/ruby versions. Contributed by dmaes
Release 0.4.2
- Update the 'vault_cert' provider handling for certificate expiration. Contributed by optiz0r.
Release 0.4.1
- Update approle_agent so the systemd "vault-token" service will use "oneshot" instead of "simple". Contributed by dmaes
Release 0.4.0
- Add defined type "vault_secrets::approle_agent" to configure a Vault agent for use with an existing AppRole and save the Vault token to a fixed sink file.
- Add plan "vault_secrets::approle_agent" to apply the defined type on targets
Release 0.3.2
Bugfix - Update post method in the Vault ruby class to use request.body instead of request.set_form_data Bugfix - The puppet "vault_secrets" class should handle "unknown" as the value of "days_remaining"
Release 0.3.1
- Refactor shared functions as a ruby class and update references
Release 0.3.0
- Added custom provider with the 'vault_cert' type to enable puppet nodes to directly manage a Vault certificate without the request being issued through the puppet master and being stored in the catalog. Contributed by optiz0r.
Release 0.2.1
Bugfix - Module hiera update for new module name
Release 0.2.0
- Module renamed to "vault_secrets" to avoid naming conflict
- Updated error handling in functions
- vault_hiera_hash function now uses 'token_file' instead of 'token'
Release 0.1.1
Bugfix - Set 'show_diff' to false when updating certificate and private key file content
Release 0.1.0
Initial release - See README for features
Dependencies
- puppetlabs/stdlib (>= 4.19.0 < 10.0.0)
- puppet/systemd (>= 3.0.0 < 6.0.0)
- puppet/hashi_stack (>= 2.0.0 < 3.0.0)