Puppet Class: puppet::agent
- Defined in:
- manifests/agent.pp
Summary
Manages the installation, configuration, and scheduling of the Puppet agent.Overview
The ‘puppet::agent` class centralizes the setup of the Puppet agent by incorporating package installation, configuration, and scheduling. It organizes and coordinates the key components required for the agent to function, including repository management, configuration file setup, and scheduled execution.
**Class Workflow:**
-
**Installation (‘puppet::agent::install`):** Ensures the Puppet agent package is installed.
-
**Configuration (‘puppet::agent::config`):** Configures agent-specific settings, including the Puppet server to connect to, optional CA server, environment, and certname. This step is controlled by the `manage_config` parameter.
-
**Setup (‘puppet::setup`):** Optionally updates the hosts file for Puppet server resolution, and creates any necessary directories or helper scripts.
-
**Scheduling (‘puppet::agent::schedule`):** Configures periodic or on-boot scheduling for the Puppet agent to enforce policies as required.
**Dependencies and Optional Settings:**
-
Includes optional updates to the hosts file if ‘$hosts_update` is enabled.
-
Allows specifying a unique certname for agent identification (‘$certname`).
-
The configuration step can be skipped by setting ‘manage_config` to `false`.
**Execution Order:**
-
Ensures ‘puppet::agent::install` completes before running configuration (`puppet::agent::config`), followed by scheduling (`puppet::agent::schedule`). If `manage_config` is `false`, `puppet::agent::config` is skipped, and `puppet::agent::schedule` follows directly after installation.
**Example Usage:** “‘puppet class { ’puppet::agent’:
server => 'puppet.example.com',
hosts_update => true,
ca_server => 'ca.example.com',
certname => 'agent01.example.com',
manage_config => false,
} “‘
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'manifests/agent.pp', line 54
class puppet::agent (
String $server = 'puppet',
Boolean $hosts_update = false,
Optional[String] $ca_server = undef,
Optional[String] $certname = undef,
Boolean $manage_config = true,
) {
class { 'puppet::agent::install': }
contain puppet::agent::install
if $manage_config {
class { 'puppet::agent::config':
server => $server,
ca_server => $ca_server,
# lint:ignore:top_scope_facts
node_environment => $::environment,
# lint:endignore
certname => $certname,
}
Class['puppet::agent::install']
-> Class['puppet::agent::config']
-> Class['puppet::agent::schedule']
}
class { 'puppet::setup':
hosts_update => $hosts_update,
}
include puppet::agent::schedule
Class['puppet::agent::install']
-> Class['puppet::agent::schedule']
}
|