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

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.
主站蜘蛛池模板: 祁东县| 彰化市| 高安市| 合江县| 富宁县| 阳信县| 宁津县| 辉县市| 启东市| 灵石县| 澄城县| 叙永县| 罗源县| 杭锦旗| 门源| 高台县| 滨州市| 建昌县| 息烽县| 屏南县| 上杭县| 五家渠市| 涡阳县| 页游| 高唐县| 东乌| 大冶市| 甘谷县| 庐江县| 张家川| 吉安县| 陆良县| 教育| 海林市| 衡东县| 乌拉特前旗| 汶川县| 河津市| 海伦市| 铁岭县| 高碑店市|