Configuring Puppet Provisioner
1. Setting Manifest File
| Property | Values | Description |
|---|---|---|
| manifest_file | manifest.pp |
Path to the Puppet manifest file to be applied. Can be relative to the Vagrantfile or an absolute path. |
| manifest_dir | /vagrant |
Directory where Puppet manifests are located. Defaults to the Vagrant project root. |
Example: Configure manifest file
Vagrant.configure("2") do |config|
config.vm.provision :puppet do |puppet|
puppet.manifest_file = "site.pp"
end
end
2. Configuring Manifests Path
| Option | Values | Description |
|---|---|---|
| manifests_path | manifests |
Path to the directory containing Puppet manifests. Defaults to manifests in the Vagrant root. |
| manifests_path | site/manifests |
Custom path to Puppet manifests directory, relative to Vagrant root. |
Example: Setting Custom Manifests Path
Vagrant.configure("2") do |config|
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "custom/manifests"
end
end
3. Using Module Path
| Option | Values | Description |
|---|---|---|
| module_path | modules/ |
Path to the directory containing Puppet modules |
| module_path | ["/path/to/modules", "/another/path"] |
List of paths to directories containing Puppet modules |
Example: Setting Module Path
# Vagrantfile
Vagrant.configure("2") do |config|
config.vm.provision :puppet do |puppet|
puppet.module_path = ["modules", "/opt/puppet/modules"]
end
end
4. Setting Hiera Config
| Option | Values | Description |
|---|---|---|
| hiera_config | string |
Path to the Hiera configuration file. Defaults to /etc/puppetlabs/puppet/hiera.yaml. |
| hiera_data_dir | string |
Directory where Hiera data files are stored. Defaults to /etc/puppetlabs/puppet/hieradata. |
Example: Setting Hiera Config in Vagrantfile
Vagrant.configure("2") do |config|
config.vm.provision :puppet do |puppet|
puppet.hiera_config = "/etc/puppetlabs/puppet/hiera.yaml"
puppet.hiera_data_dir = "/etc/puppetlabs/puppet/hieradata"
end
end
5. Configuring Facter Variables
| Variable | Description | Example Value |
|---|---|---|
| facter.custom_var | Custom variable to be set in Facter | production |
| facter.environment | Environment variable for Puppet runs | production |
Example: Setting Facter Variables in Vagrantfile
Vagrant.configure("2") do |config|
config.vm.provision :puppet do |puppet|
puppet.facter = {
"custom_var" => "production",
"environment" => "production"
}
end
end
6. Using Puppet Options
| Option | Description | Default | Notes |
|---|---|---|---|
| puppet.options | Additional command-line options to pass to the Puppet agent | "" |
Can be used to pass custom flags or configurations to Puppet |
| puppet.verbose | Enable verbose output from Puppet | false |
Set to true for detailed logging during provisioning |
| puppet.facter | Additional Facter facts to pass to Puppet | {} |
Allows custom facts to be set before Puppet runs |
Example: Setting Puppet Options
# Vagrantfile
Vagrant.configure("2") do |config|
config.vm.provision :puppet do |puppet|
puppet.options = "--debug --verbose"
puppet.verbose = true
puppet.facter = {
"custom_fact" => "custom_value"
}
end
end
7. Setting Working Directory
| Option | Values | Description |
|---|---|---|
| config.provisioner.puppet.working_directory | /tmp/puppet |
Directory where Puppet manifests and modules are copied to during provisioning |
Example: Setting Working Directory
config.provisioner :puppet do |puppet|
puppet.working_directory = "/opt/puppet"
end
8. Configuring Puppet Server
| Option | Values | Notes |
|---|---|---|
| puppet_server | server.example.com |
Hostname or IP of the Puppet server |
| puppet_server_port | 8140 |
Port on which Puppet server listens |
| puppet_server_ssl | true |
Enable SSL for secure communication |
| puppet_server_ca | /etc/puppetlabs/puppet/ssl/certs/ca.pem |
Path to CA certificate file |
Example: Puppet Server Configuration
config.vm.provision :puppet do |puppet|
puppet.server = "puppet.example.com"
puppet.port = 8140
puppet.ssl = true
puppet.ca_file = "/etc/puppetlabs/puppet/ssl/certs/ca.pem"
end
Note: Ensure the Puppet server is accessible from the Vagrant box and that certificates are properly configured for secure communication.
9. Using Environment
| Option | Values | Notes |
|---|---|---|
| environment | production |
Environment name to pass to Puppet |
| environment_file | /etc/puppet/environments/production |
Path to environment file |
Example: Setting Environment in Vagrantfile
Vagrant.configure("2") do |config|
config.vm.provision :puppet do |puppet|
puppet.environment = "production"
end
end
Note: Ensure Puppet environment is properly configured on the guest machine.
10. Setting Structured Facts
| Property | Description | Example |
|---|---|---|
| facts | Hash of structured facts to be set on the guest machine | |
Example: Setting Structured Facts
# In Vagrantfile
config.vm.provision "puppet" do |puppet|
puppet.facts = {
"environment" => "production",
"application" => "webapp"
}
end
Note: Structured facts are passed to Puppet as
facts and can be accessed in your Puppet manifests using facter or $facts.