An introduction to Puppet's Learning and Mastery

Source: Internet
Author: User
Tags ssh ssl connection
puppet Getting StartedSkip to end of metadata 1puppet

Puppet is an open source software automation configuration and Deployment tool, and many large IT companies are using puppet to manage and deploy software in a cluster. 2. The Design architecture Puppet is based on the C/S architecture. The server side holds all the configuration code for the client server, which is called manifest in puppet. After the client downloads manifest, the server can be configured according to manifest, such as package management, user management, file management, and so on.

As shown in the figure above, the puppet workflow is as follows:

(1) The client puppetd calls Facter,facter to detect Some variables of the host, such as host name, memory size, IP address, etc. pupppetd send this information to the server via SSL connection;

(2) server-side puppetmaster detect the host name of the client, and then find the manifest inside the corresponding node configuration, and the content of the resolution , Facter sent over the information can be treated as a variable,

The code that the node is involved in is parsed, and other code that is not involved is not parsed. Parsing is divided into several stages, grammar checking, and error if grammatical errors. If the syntax is correct, continue to parse, the result of the resolution generates an intermediate "pseudo-code", and then send the pseudo-code to the client;

(3) The client receives "pseudo-code" and executes, the client sends the execution result to the server;

(4) The server side writes the execution result of the client to the log.

Puppet two points worth noting in the course of the work: in order to ensure security, between the client and master is based on SSL and certificate, only the master certificate-certified client can communicate with master; Puppet will keep the system in a state that you expect to persist, such as detecting a file and ensuring it persists, ensuring that the SSH service is always on, if the file is deleted, or if the SSH service is turned off,
Puppet the next execution (30 minutes by default), the file is recreated or the SSH service is started. 3 puppet Syntax 1 Resources

1. The main resources are as follows:

File: Document management more detailed information

Package: More detailed information on software packages management

Service: System service Management more detailed information

Cron: Configuring a recurring task more detailed information

EXEC: Run shell command more details

2. Resource Common Properties 1 resource public properties

Before is used to control the execution order relationship of different objects (resources), which means that an object (resource) Occurs after another object (require, in contrast, represents a previous occurrence).

Subscribe detects a resource, and when it changes, the resource reloads.

  2 File resource owner          settings file's main group           Specify the user group for that file, the value Can be GID or group name mode           mode to set permissions for files content         The contents of a file can be included Fixed content, source          You can use the source command to copy the contents of a file from another URL. Template       using templates, you can generate file content through the Erb template, and the Erb template can use variables. You can also calculate and manipulate variables. 3 Package Resources ensure          set the status of the packages.                        installed says to install the software, you can also write present;                      absent for the anti-installation of the software;         & nbsp            pureged means clean removal of the software,                 &NBSP ;    latest represents the latest version of the installation package. 4 Service Resource

Whether the Enable service starts at boot time, the value that can be set is true and false, requires provider support enableable

Ensure whether the service is running, running indicates that the service is running, stopped means stop service

Restart specify a restart script, or stop the service before starting the service

Start specifies the command to start the service, which is usually supported by the INIT mode management script and does not need to be specified manually

status Specifies the status command and, if not specified, queries the service from the list of processes

STOP specifies the script to stop the service. 2 classes and Functions Class 1

A class can define multiple related resources together to form a class that can inherit a class. class

C L A s SSH {f i l e {"/E t c/ssh/sshd_config": Source = "Puppet://$ F i l e s e R v E r/s Sh/sshd_config. CFG ";} Package {"SSH": ensure = i n s t a l l e D;} S e R v I c e {"ssh": ensure = running;}} Here, the content of the file/etc/ssh/sshd_config is downloaded from the puppet server, the contents of the file resource can be obtained from other URLs, can also be generated by the Erb template, the Erb template is a very powerful tool, this will be said later. Package resources to install SSH software, service resources to ensure that the SSH service in the running state. The inheritance of the class is not spoken here, because it is a starter manual, and not much else.
2 Functions

Functions (called "Defination" in puppet) can wrap multiple resources into a single resource, or package a resource into a model for ease of use. function

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.