Scaling Puppet Server

To scale Puppet Server for many thousands of nodes, you'll need to add more Puppet Server instances dedicated to catalog compilation. These Servers are known as compilers, and are simply additional load-balanced Puppet Servers that receive catalog requests from agents and synchronize the results with each other.

If you're using Puppet Enterprise (PE), consult its documentation instead of this guide for PE-specific requirements, settings, and instructions:

Planning your load-balancing strategy

The rest of your configuration depends on how you plan on distributing the agent load. Determine what your deployment will look like before you add any compilers, but implement load balancing as the last step only after you have the infrastructure in place to support it.

Using round-robin DNS

Leave all of your agents pointed at the same Puppet Server hostname, then configure your site's DNS to arbitrarily route all requests directed at that hostname to the pool of available servers.

For instance, if all of your agent nodes are configured with server = puppet.example.com, configure a DNS name such as:

# IP address of server 1:
puppet.example.com. IN A 192.0.2.50
# IP address of server 2:
puppet.example.com. IN A 198.51.100.215

For this option, configure your servers with dns_alt_names before their certificate request is made.

Using a hardware load balancer

You can also use a hardware load balancer or a load-balancing proxy webserver to redirect requests more intelligently. Depending on your configuration (for instance, SSL using either raw TCP proxying or acting as its own SSL endpoint), you might also need to use other procedures in this document.

Configuring a load balancer depends on the product, and is beyond the scope of this document.

Using DNS SRV Records

You can use DNS SRV records to assign a pool of Puppet Servers for agents to communicate with. This requires a DNS service capable of SRV records, which includes all major DNS software.

Note: This method makes a large number of DNS requests. Request timeouts are completely under the DNS server's control and agents cannot cancel requests early. SRV records don't interact well with static servers set in the config file. Please keep these potential pitfalls in mind when configuring your DNS!

Configure each of your agents with a srv_domain instead of a server in puppet.conf:

[main]
use_srv_records = true
srv_domain = example.com

Agents will then lookup a SRV record at _x-puppet._tcp.example.com when they need to talk to a Puppet server.

# Equal-weight load balancing between server-a and server-b:
_x-puppet._tcp.example.com. IN SRV 0 5 8140 server-a.example.com.
_x-puppet._tcp.example.com. IN SRV 0 5 8140 server-b.example.com.

You can also implement more complex configurations. For instance, if all devices in site A are configured with a srv_domain of site-a.example.com, and all nodes in site B are configured to site-b.example.com, you can configure them to prefer a server in the local site but fail over to the remote site:

# Site A has two servers - server-1 is beefier, give it 75% of the load:
_x-puppet._tcp.site-a.example.com. IN SRV 0 75 8140 server-1.site-a.example.com.
_x-puppet._tcp.site-a.example.com. IN SRV 0 25 8140 server-2.site-a.example.com.
_x-puppet._tcp.site-a.example.com. IN SRV 1 5 8140 server.site-b.example.com.

# For site B, prefer the local server unless it's down, then fail back to site A
_x-puppet._tcp.site-b.example.com. IN SRV 0 5 8140 server.site-b.example.com.
_x-puppet._tcp.site-b.example.com. IN SRV 1 75 8140 server-1.site-a.example.com.
_x-puppet._tcp.site-b.example.com. IN SRV 1 25 8140 server-2.site-a.example.com.

Centralizing the Certificate Authority

Additional Puppet Servers should only share the burden of compiling and serving catalogs, which is why they're typically referred to as "compilers". Any certificate authority functions should be delegated to a single server.

Before you centralize this functionality, ensure that the single server that you want to use as the central CA is reachable at a unique hostname other than (or in addition to) puppet. Next, point all agent requests to the centralized CA server, either by configuring each agent or through DNS SRV records.

Directing individual agents to a central CA

On every agent, set the ca_server setting in puppet.conf (in the [main] configuration block) to the hostname of the server acting as the certificate authority. If you have a large number of existing nodes, it is easiest to do this by managing puppet.conf with a Puppet module and a template.

Note: Set this setting before provisioning new nodes, or they won't be able to complete their initial agent run.

Pointing DNS SRV records at a central CA

If you use SRV records for agents, you can use the _x-puppet-ca._tcp.$srv_domain DNS name to point clients to one specific CA server, while the _x-puppet._tcp.$srv_domain DNS name handles most of their requests to servers and can point to a set of compilers.

Creating and configuring compilers

To add a compiler to your deployment, begin by installing and configuring Puppet Server on it.

Before running puppet agent or starting Puppet Server on the new server:

  1. In the compiler's puppet.conf, in the [main] configuration block, set the ca_server setting to the hostname of the server acting as the certificate authority.

  2. In the compiler's webserver.conf file, add and set the following SSL settings:

    • ssl-cert

    • ssl-key

    • ssl-ca-cert

    • ssl-crl-path

  3. Disable Puppet Server's certificate authority services.

    If you're using the individual agent configuration method of CA centralization, set ca_server in puppet.conf to the hostname of your CA server in the [main] config block. If an ssldir is configured, make sure it's configured in the [main] block only.

  4. If you're using the DNS round robin method of agent load balancing, or a load balancer in TCP proxying mode, provide compilers with certificates using DNS Subject Alternative Names.

    Configure dns_alt_names in the [main] block of puppet.conf to cover every DNS name that might be used by an agent to access this server.

    dns_alt_names = puppet,puppet.example.com,puppet.site-a.example.com

    If the agent has been run or the server started and already created a certificate, remove it by running sudo puppet ssl clean. If an agent has requested a certificate from the server, delete it there to re-issue a new one with the alt names: puppetserver ca clean server-2.example.com.

  5. Request a new certificate by running puppet agent --test --waitforcert 10.

  6. Log into the CA server and run puppetserver ca sign server-2.example.com.

Centralizing reports, inventory service, and catalog searching (storeconfigs)

If you use an HTTP report processor, point your server and all of your Puppet compilers at the same shared report server in order to see all of your agents' reports.

If you use the inventory service or exported resources, use PuppetDB and point your server and all of your Puppet compilers at a shared PuppetDB instance. A reasonably robust PuppetDB server can handle many Puppet compilers and many thousands of agents.

See the PuppetDB documentation for instructions on deploying a PuppetDB server, then configure every Puppet compiler to use it. Note that every Puppet primary server and compiler must have its own allowlist entry if you're using HTTPS certificates for authorization.

Keeping manifests and modules synchronized across compilers

You must ensure that all Puppet compilers have identical copies of your manifests, modules, and external node classifier data. Examples include:

  • Using a version control system such as r10k, Git, Mercurial, or Subversion to manage and sync your manifests, modules, and other data.

  • Running an out-of-band rsync task via cron.

  • Configuring puppet agent on each compiler to point to a designated model Puppet Server, then use Puppet itself to distribute the modules.