官术网_书友最值得收藏!

Creating the master manifest

When you used Puppet locally in Chapter 1, Writing Your First Manifests, you specified a manifest file that puppet apply should compile. The master compiles manifests for many machines, but the agent does not get to choose which source file is to be used; this is completely at the master's discretion. The starting point for any compilation by the master is always the site manifest, which can be found in /opt/puppetlabs/code/environments/production/manifests/.

The significance of the environments/production part will be investigated in Chapter 5, Combining Classes, Configuration Files, and Extensions into Modules. In Puppet versions before 4.0, the site manifest is at another location, /etc/puppet/manifests/site.pp, and comprises just one file.

Each connecting agent will use all the manifests found here. Of course, you don't want to manage only one identical set of resources on all your machines. To define a piece of manifest exclusively for a specific agent, put it in a node block. This block's contents will only be considered when the calling agent has a matching common name in its SSL certificate. You can dedicate a piece of the manifest to a machine with the name of agent, for example:

node 'agent' {
$packages = [ 'apache2',
'libapache2-mod-php5',
'libapache2-mod-passenger', ]
package { $packages:
ensure => 'installed',
before => Service['apache2'],
}
service { 'apache2':
ensure => 'running',
enable => true,
}
}
The given example does not show best practice for node classification. It is merely used as an example. We will show the modern best practice node classification in Chapter 9, Puppet Roles and Profiles.

Before you set up and connect your first agent to the master, step back and think about how the master should be addressed. By default, agents will try to resolve the unqualified puppet hostname in order to get the master's address. If you have a default domain that is being searched by your machines, you can use this as a default and add a record for puppet as a subdomain (such as puppet.example.net).

Otherwise, pick a domain name that seems fitting to you, such as master.example.net or adm01.example.net. What's important is the following:

  • All your agent machines can resolve the name to an address
  • The master process is listening for connections on that address
  • The master uses a certificate with the chosen name as CN or DNS Alt Names

The mode of resolution depends on your circumstances; the hosts file on each machine is one ubiquitous possibility. The Puppet server listens on all the available addresses by default.

This leaves the task of creating a suitable certificate, which is simple. Configure the master to use the appropriate certificate name and restart the service. If the certificate does not exist yet, Puppet will take the necessary steps to create it. Put the following setting into your /etc/puppetlabs/puppet/puppet.conf file on the master machine:

[main] 
certname=puppetmaster.example.net 
In Puppet versions earlier than 4.0, the default location for the configuration file is /etc/puppet/puppet.conf.

Upon its next start, the master will use the appropriate certificate for all SSL connections. The automatic proliferation of SSL data is not dangerous, even in an existing setup, except for the certification authority. If the master were to generate a new CA certificate at any point in time, it would break the trust of all existing agents.

Make sure that the CA data is neither lost nor compromised. All previously signed certificates become obsolete whenever Puppet needs to create a new certification authority. The default storage location is /etc/puppetlabs/puppet/ssl/ca for Puppet 4.0 and higher, and /var/lib/puppet/ssl/ca for older versions.
主站蜘蛛池模板: 孝昌县| 峨边| 苍溪县| 长宁区| 买车| 惠来县| 万盛区| 五大连池市| 大姚县| 平武县| 丽江市| 乐平市| 容城县| 达州市| 延吉市| 临泽县| 常德市| 科技| 横峰县| 横山县| 博客| 五峰| 泊头市| 涿州市| 特克斯县| 岳阳县| 上栗县| 绥棱县| 长子县| 金乡县| 页游| 琼结县| 即墨市| 家居| 青岛市| 乳山市| 凤翔县| 枣庄市| 靖远县| 漳州市| 平果县|