Configuring the Provisioner requires exact knowledge of your deployment needs, we suggest you start with first configuring servers by hand while exploring your needs, once the specific configuration file contents and security needs are defined those can be configured into the Provisioner system.
Deploying a Provisioner should not be the first thing you do.
General Requirements
Choria Broker
You must be running the Choria Broker and it will need a few extra configuration items.
JWT files or custom binaries
You can enable Provisioning mode in the standard Open Source Choria Server by placing a provisining.jwt in the right place. Those doing custom builds can also apply build-time defaults that has no external dependencies.
Helper Script
Provisioner calls into a user-supplier helper, written in a language like Ruby but any language can be used, to generate the per-node configuration properties.
Certificate Authorities
If you have a x509 based Choria deployment (the default) you will need to be able to generate or sign certificates for your nodes. To do this your CA needs to have a API that you can call to issue certificates.
There are other options requiring JWT files to be signed also if that is not possible.
Authorization Policies
In this mode typically nodes do not have any Policies controlling who can invoke Agents and Actions. You will probably want to write a Open Policy Agent policy that the Provisioner will deploy
Monitoring
We expose metrics to Prometheus, for in-depth monitoring you will need Prometheus or a compatible system.
Subsections of Configuration
Server Setup
The Choria Server has the required RPC Agent embedded and is ready to be used in a Provisioner managed network but it is disabled by default. Custom binaries can enable provisioning at compile time for an always-on experience.
Provisioning is enabled in the Open Source server by means of a JWT token that you create and place on the server. The JWT token holds all of the information the server needs to find it’s provisioning server and will present that token also to the provisioning server for authentication.
The token is signed using a trusted private key, the provisioner will only provision nodes presenting a trusted key.
Credentials
If you are using a x509 based setup you really just need any RSA Key pair to sign the JWT with:
For the Organization Issuer based deploys you would sign it using your Issuer.
Creating the JWT
Choria JWTs are creating using the choria jwt command, for provisioning specifically choria jwt provisioning.
Creating the JWT:
$ choria jwt provisioning.jwt provisioning-jwt-signer-key.pem --srv choria.example.net --token toomanysecrets
Saved token to provisioning.jwt, use 'choria jwt view provisioning.jwt' to view it
$ choria jwt provisioning.jwt
Unvalidated Provisioning Token x.jwt
Token: *****
Secure: true
SRV Domain: choria.example.net
Provisioning by default: false
Standard Claims: {
"purpose": "choria_provisioning",
"iss": "Choria Tokens Package v0.26.2",
"sub": "choria_provisioning",
"nbf": 1669805752,
"iat": 1669805752,
"jti": "2c99227346f641bbba34faf0a6991d05"
}
Here we create a provisioning.jwt that will instruct Choria to look for _choria-provisioner._tcp.choria.example.net SRV records to find the server to connect to.
Other options can be set for example to hard code provisioning URLs, username and passwords and more.
Version Hint
This table is correct for Choria 0.27.0 and newer which is due to ship early 2023. Review --help for your version.
Option
Description
Default
Required
signing-key
The token must be signed using a private key, this can be a file with either RSA or ed25519 private key.
yes
--[no]-insecure
During provisioning the protocol security system cannot be active as no private credentials exist, this disables that
since 0.27.0
no
--token
A basic shared secret that the provisioner must present to perform certain actions
no
--urls
A static, comma seperated, list of servers to connect to for provisioning
no
--srv
A domain name to query for SRV records
no
--default
Enables provisioning by default. Else requires plugin.choria.server.provision to be set
false
no
--registration
Path to a file to publish as registration data while in provisioning mode
no
--facts
Path to a file to use as fact source data while in provisioning mode
no
--username
A NATS user to use when connecting to the broker
no
--password
Password to use when connecting to the broker
no
--extensions
Additional free-form data to embed in the JWT as JSON text
no
--org
The Organization this server belongs to
choria
yes
--vault
Use Hashicorp Vault for signing the token, the signing-key is then the name of the vault key
false
no
--protocol-v2
Enables the choria security system and version 2 protocol. Set for Org Issuer based networks
false
no
When this file is placed in /etc/choria/provisioning.jwt and Choria starts without a configuration it will provision via these settings.
Choria also support provisioning plugins to resolve this information dynamically but this requires custom binaries and should in general be avoided.
Confirming
Without the JWT in place Provisioning is not enabled:
Now provisioning is on with the settings we provided in the token.
Broker Setup
Choria Broker supports a concept called an Account or Organization, these are like a VLAN on your network switches.
Nodes partitioned into one Organization cannot communicate with nodes in any other Organizations unless special arrangements are made to facilitate that.
We use this feature to create an isolated network where unprovisioned servers wait for provisioning. When Choria Provisioner connects using fully verified credentials it gains access to these isolated Servers and can provision them.
Here we show one Choria Broker Cluster with a Choria Account and a Provisioning Account active. Unverified connections enter the Provisioning Account automatically. The Provisioner connects with its fully verified credentials that identify it as a Provisioner and gains access to the unprovisioned servers.
Restrictions in the Choria Broker authentication layer ensures this separation is not optional and enforce control over what software gains access to the unprovisioned fleet.
Enabling the System Account
We suggest enabling the Choria Broker system account to allow introspection of nodes waiting to be provisioned and more.
Configure this in both your Broker and Client configurations.
The Choria Provisioner will connect using its normal Certificate or JWT token which means it will appear just like any other client. To differentiate it we force it to connect to a specific user and password.
The password is unique per environment and should be configured in the broker:
Once configured you can run the command choria broker server report conns --account provisioning to both confirm the account is active and it will show any connections made to this account. The Choria Provisioner will appear there as well as any machines being provisioned.
Writing a Helper
The Helper is a script or program written in any language that is in charge of handling the steps that are unique to your environment.
Essentially it receives Server Metadata on its STDIN and writes a response to STDOUT that is used to configure the server.
See the sections below for sample Helper scripts.
Input
Let’s look at what you might receive as input on STDIN. The specifics will vary a bit between scenarios which we will call out in specific sections. The data you will get will all already have been validated. For example the JWT would have been parsed already and known to be valid.
The configuration must set plugin.choria.server.provision to disable provisioning, else the node will keep being reprovisioned forever.
Response keys used by scenarios:
Key
Description
defer
Defers the provisioning, this is a soft state meaning the server will come back and be retried later
shutdown
Issues a shutdown on the server with exit code 0, systemd will not restart it.
msg
A message to log on the Server to explain why it is being deferred or shut down
configuration
A JSON Object of configuration items in key-value pairs, will be written to the server config
action_policies
A JSON Object of Action Policy policies in key-value pairs, where the key is an agent name
opa_policies
A JSON Object of Open Policy Agent policies in key-value pairs, where the key is an agent name or default
When using the pki feature used to enroll with a Certificate Authority:
Key
Description
key
An optional x509 private key that the server should use, will be encrypted using a unique one-time password in transit
certificate
The signed certificate in PEM format
ca
The Certificate Authority public key in PEM format
ssldir
What directory to store the key, certificate and ca in on the server
When using the jwt feature to create server JWT tokens for Organization Issuer based networks:
Key
Description
server_claims
The Choria Server token claims to base the server JWT on
When using the upgrades feature to in-place upgrade servers:
Key
Description
upgrade
The version to upgrade the server to before provisioning
Enrolling nodes with a Certificate Authority
Most typically you have a Enterprise Certificate Authority or you made your own using something like cfssl.
In this mode Choria Server will generate a private key on its disk, create a CSR and your helper will receive the CSR in PEM format. In your helper you then simply interact with your CA to sign the CSR and respond with the signed Certificate and CA public key. This way once provisioned your server will be fully enrolled for mTLS.
To enable the Provisioner to request the CSR the pki feature needs to be enabled in the Provisioner Configuration.
The csr input field will then be a JSON Object with:
Key
Description
csr
The PEM encoded CSR the node is sending
public_key
The public part of the key the server created
ssldir
The directory the server created the private key in so it can be used in the generated configuration
Once you have this data you can use your CA API to enroll the node and get a signed certificate back. Simply put the resulting PEM data in the certificateand ca keys in the reply. You can set a SSL directory but typically just set ssldir to what was received in the input.
Info
A basic sample helper that enrolls in a cfssl based CA can be seen in cfssl-helper.rb
In general the Private key stays on the node and you do not need it. Some Certificate Authorities require the private key to be accessible when signing a request. Provisioner support that, if you generate a key in the provisioner and add it to the reply in the key JSON field a single use Shared Secret negotiated using Diffie-Hellman will be used to encrypt the key in transit.
I would not suggest ever to use a CA that requires you to transmit the Private Key during enrollment, it’s best to assume your CA is unusable at that point and consider a Organization Issuer based deployment.
Enrolling nodes with an Organization Issuer
In cases where a Certificate Authority is not available or it is operated in a way that makes it unsuitable for mTLS use you might opt to deploy Choria in an Organization Issuer based setup. The basic setup of that mode is out of scope for this document.
Version Hint
This applies only to Choria 0.27.0 and newer which is due to ship early 2023
To enrol nodes in an Organization Issuer based network you need to enable the ed25519 feature in the Provisioner Configuration.
Once enabled the ed25519_pubkey field will hold a JSON Object with these values:
Key
Description
public_key
The ed25519 public key unique to the server
directory
The directory that will hold server.seed and where server.jwt will be saved to later
signature
A signature of the request made using the private key matching the public_key, this can be ignored as it would already be validated
Once you received these you can include a server_claims in your reply to give the server access to specific features in its JWT claims. The list here is correct for 0.27.0. For an up-to-date list see the Go Documentation for your version of Choria.
The claims can include permissions that have these properties.
Allows the server to access Choria Streams for example to read KV buckets from autonomous agents
governor
Allows the server to access Choria Governor from autonomous agents
service_host
Allows the server to host Services
You can also use them to restrict it to a specific sub collective and more. Most values will default to sane defaults when not given.
Upgrading Servers
Choria Server can be upgraded in-place to a new version. This is done by overwriting the binary at run-time with one downloaded from a specifically prepared repository.
This can only be done during Provisioning and requires the upgrades feature to be enabled.
Version Hint
This applies only to Choria 0.27.0 and newer which is due to ship early 2023
Compatible nodes will have the upgradable key in the inventory received and will be set to true when upgrades are enabled. If you only want to support the latest nodes you can use this to determine if a upgrade is needed along with the version key in the inventory. On nodes that are too old set shutdown or defer.
You would have to configure the Provisioner with a repository location and set up a repository on a HTTP server as per the guidelines from go-updater.
With all of this in place you can add the upgrade key to the helper response that should just be a desired version like 0.28.0. Provisioner will then attempt to upgrade the node.
Configuration File
Provisioner is configured using /etc/choria-provisioner/choria-provisioner.yaml typically. It’s a YAML format file with a few required settings and a number of optional ones. Changes to the file requires the process to be restarted.
Choria Client Configuration
As the Provisioner connects to the Choria Broker as a client it needs a configuration that allows it access. Create /etc/choria-provisioner/choria.cfg with the following based on needs. These settings will augment those in /etc/choria/client.cfg.
How many concurrent helpers to call while provisioning
number of cores
interval
How often to perform a discovery against the network for new machines
1m
logfile
Where to write the log
loglevel
The level to log at, debug, info, warn or error
info
helper
Path to the helper script
token
The value of the token set using --token in the provisioning.jwt
site
A unique name for this installation, surfaced in monitoring data
monitor_port
The post to listen on for monitoring requests
broker_provisioning_password
The password configured in the broker plugin.choria.network.provisioning.client_password
features.jwt
Enables fetching and validating provisioning.jwt, should almost always be true
false
features.ed25519
Enables JWT processing for Organization Issuer based networks
false
features.pki
Enables x509 enrollment
false
features.upgrades
Enables server version upgrades
false
PKI / x509 Enrollment
When enabled the Provisioner will fetch a CSR from the node and ask the node to create a private key that stays on the node. The helper can then get the certificate signed and the signed certificate will be sent to the node.
To enable set features.pki to true.
Here we reference our x509 key and certificate
Item
Description
Default
jwt_verify_cert
Full path to the public certificate used to sign provisioning.jwt
jwt_signing_key
Full path to our private key, also used in choria.conf
Organization Issuer based Enrollment
When enabled the Provisioner will sign and issue server JWTs with custom claims and signatures. No x509 steps will be done.
To enable set features.ed25519 to true.
Here we reference our JWT that gives us the right to provision and issue new JWTs
Item
Description
Default
jwt_verify_cert
The hex encoded public key of your Organization Issuer
jwt_signing_key
The private ed25519 key, also used in choria.conf
jwt_signing_token
The JWT token, also used in choria.conf
Choria Server Upgrades
Choria Provisioner can upgrade Choria Servers using a go-updated repository.
To enable set features.upgrades to true.
Here we configure the updates repository and say how failures are handled
Item
Description
Default
upgrades_repository
URL to your updates repository
upgrades_optional
Continue provisioning even if upgrading fails
false
Clustered Deployments
The Provisioner is generally fast enough to not need a cluster of active-active servers, so we support deploying multiple instances of Provisioner and using Leader Elections to elect one in the cluster as a leader that will be actively provisioning nodes.
To enable this the client needs access to Streams and Leader Elections so need --stream-user and --elections-user passed when creating its JWT.
Campaigning will be on a backoff schedule up to 20 second between campaigns, this means there can be up to a minute of downtime during a failover scenario, generally that’s fine for the Provisioner.
If a Provisioner was on standby and becomes leader it will immediately perform a discovery to pick up any nodes ready for provisioning.