Getting started with puppet

Source: Internet
Author: User
Tags ssl certificate

To do this, you must first sharpen your tools. When we need to manage the environment for dozens of machines at the same time, a suitable tool is very important. Here we will introduce puppet, The devops tool that Google is using. When a new tool is introduced, you will certainly have a question: How high is the cost of using this tool, making it difficult to run? This document will answer this question. The answer is that it is very easy to build a puppet runtime environment.

Of course, the first question is what puppet can do for us. Of course, puppet can help us manage a large number of machine environments. How does puppet achieve this?

I. Working Mode of puppet

Puppet manages the environment through the working mode of the master/agent. We use a server as our master. The most important responsibility of the master is to describe the environment status that needs to be applied to each agent node, the environment status is described by manifest.

The machines that need to be managed are called agents. They regularly go to the master to check whether there are new manifest applications required. If so, the applications will make their environments consistent with those required by the master, and return the execution result report.

Imagine that we are a chain hotel, such as a home manager. As a chain hotel, we need to maintain the consistency of the hotel style. So I found the master and I told him, there are two types of rooms. One is the standard room and the other is a single room. The status of the standard room indicates that manifesta is two beds. The status of the Single Room indicates that manifestb is a bed and you can do it. The manager replied, okay, no problem. The specific room is the agent. The manager first classifies these rooms. The rooms 1, 2, and 3 belong to the standard room, And the Rooms 4, 5, and 6 belong to the single room. The manager said to these rooms, manifesta should be used in the standard room with two beds, and manifestb should be used in a single room with one bed. As a result, the miracle occurred, and all the agents got their respective manifest, so the agents belonging to the standard room put two beds for themselves, the single-person Agent adds a bed for himself, and then tells the master about the execution result. Good. After another day, I made a fortune and wanted to add the TV manifest to the standard room. I said to the master, standard room, TV. So the agents did it again. But there is a problem. Some people protest that a single room has no TV. What should I do? I thought about it and decided that the standard room should not be on TV, that is, the status should be rolled back. What should I do? So I managed manifest using SVN and rolled back directly.

 

Ii. Install puppet

Well, we have learned how to install puppet? Well, wait. We seem to want to install the master and Agent modes. Yes, the master and agent are two different running modes, but they are installed in the same way. We need to install puppet on the master server and on all the machines to be managed.

To install puppet, you must first install its Dependencies. Puppet depends on Ruby and facter. Needless to say about Ruby, because puppet is written in Ruby. What does facter do? It is used to detect the machine environment, such as whether the machine is a physical machine or a virtual machine? What is the operating system installed on the machine? What is an IP address? With facter, you can do everything.

1. Install Ruby

When the source code is installed, ruby-1.8.7.tar.gz is already in the version library.

Ø decompress:

Gzip-D-C ruby-1.8.7.tar.gz | tar xf-

Ø Configuration:

CD ruby-1.8.7

./Configure

Installation:

Sudo make

Sudo make install

Ø run:

Ruby -- version

2. Install facter

Source code installation, facter-1.6.3.tar.gz is also in the version library.

Ø decompress:

Gzip-D-C facter-1.6.3.tar.gz | tar xf-

Installation:

CD facter-1.6.3

Sudo Ruby install. Rb

Ø run:

Facter -- version

3. Install puppet

2.7.6, source code installation, puppet-2.7.6.tar.gz is also in the version library.

Ø decompress:

Gzip-D-C puppet-2.7.6.tar.gz | tar xf-

Installation:

CDS puppet-2.7.6

Sudo Ruby install. Rb

Ø run:

Puppet -- version

 

3. Configure puppet

After the installation is complete, we start to configure the master, configure the agent, and establish a connection between the master and the agent.

1. Configure the master

Configure/etc/hosts

127.0.0.1 localhost master.puppet.com

 

Configure the puppet configuration file

The main configuration file of puppet is puppet. conf, which is located in/etc/puppet. We do not need to change it.

Several important configuration items:

N confdir: Master working directory of puppet, which contains the puppet configuration file, manifests, authentication certificate, module, and static content. The manifests and modules must be managed by SVN. Default Value:/etc/puppet.

N vardir: data placement address during puppet running hours, including cached data, reports, backup files, and dynamic content. Default Value:/var/lib/puppet.

N manifestdir: directory where manifests is stored. Default Value:/etc/puppet/manifests

N modulepath: Find the module search path when puppet is running. Similarly, the module needs to be managed by SVN. Default Value:/etc/puppet/modules.

Run the following command to view the puppet configurations:

Puppet Master-configprintconfdir

 

Create puppet users/groups

To start the puppet master, you need to create the puppet user group and the puppet user group.

Puppet Master -- mkusers

 

Start

Puppet Master

This is a background program

 

2. Configure the agent

Configure/etc/hosts

127.0.0.1 localhost agent1.puppet.com

10.6.222.87 [masterip] master.puppet.com

 

Configure the puppet configuration file

Server configurations are added compared with Master nodes.

Server = master.puppet.com

 

3. establish a connection between the master and the agent

Ø agent requests an SSL certificate from the master

Puppet agent -- Test

 

Ø master Authentication Agent Request

Puppet Cert list

Puppet Cert sign agent1.puppet.com

 

Enable the agent

Puppet agent

 

4. Run a test

Now we have set up the entire puppet runtime environment. It is time to test it. Do you still remember where to place our manifest? Yes, on the master machine, in manifestdir. We create the site. PP file and declare that we want to have a helloworld file.

# Site. PP

File {"/tmp/helloworld ":

Content => "Hello world !"

}

Wait, what will happen? Yes, on the Agent machine, we can see that the/tmp/helloworld file has been created, and the content is exactly what we expect "Hello World !". That's it! Very easy!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.