Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Set up Puppet service

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Use virtualbox to install two virtual machines to build the test environment of Puppet server and client.

System version: CentOS 7.664-bit

Kernel version: 3.10.0-957

Puppetserver version: 5.3.10-1.el7

Puppet-agent version: 5.5.17-1.el7

Machine name / IP address:

Server: pp-master / 192.168.31.123

Client: pp-agent / 192.168.31.124

[ready]

Turn off the firewall and SELINUX

Add the IP and hostnames of the two hosts to / etc/hosts to ensure that they can ping each other's hostnames

[installation]

Download and install puppet repo on pp-master,pp-agent

Rpm-ivh https://yum.puppetlabs.com/puppet5/puppet5-release-el-7.noarch.rpm

Generate the file path / etc/yum.repos.d/puppet5.repo of puppet repo

Install puppetserver and puppet on pp-master

Yum install puppetserver puppet-y

Install puppet on pp-agent

Yum install puppet-y

[configuration]

Configuration file / etc/puppetlabs/puppet/puppet.conf for puppet

Server-side puppet.conf

The default configuration is as follows:

[master] vardir = / opt/puppetlabs/server/data/puppetserverlogdir = / var/log/puppetlabs/puppetserverrundir = / var/run/puppetlabs/puppetserverpidfile = / var/run/puppetlabs/puppetserver/puppetserver.pidcodedir = / etc/puppetlabs/code

Add the following main configuration to the server-side puppet.conf

[main] certname = pp-masterserver = pp-masterenvironment = productionruninterval = 10mstrict_variables = true

Both certname (certificate name) and server (server name) are set to pp-master

Environment defaults to production (production environment)

Runinterval (interval between runs) is set to 10 minutes

Strict_variables (mandatory variable) is set to true

Add the following main configuration to the client puppet.conf

[main] certname = pp-agentserver = pp-masterenvironment = productionruninterval = 10m

The certificate name is native hostname: pp-agent

The server side is pp-master

The environment defaults to production

The running interval is 10 minutes.

Edit hiera configuration / etc/puppetlabs/puppet/hiera.yaml

--: backends:-yaml:yaml:: datadir: "/ etc/puppetlabs/code/environments/% {environment} / hieradata": hierarchy:-"hosts/% {:: trusted.certname}"-common:yaml:# datadir is empty here, so hiera uses its defaults:#-/ etc/puppetlabs/code/environments/% {environment} / hieradata on * nix# -% CommonAppData%\ PuppetLabs\ environments\% {environment}\ hieradata on Windows# When specifying a datadir, make sure the directory exists. : datadir:

The client host configuration is stored in the path / etc/puppetlabs/code/environments/production/hieradata/hosts/pp-agent

Configuration content:

-classes:-helloworld

First define a module called helloworld for testing

Module catalog:

/ etc/puppetlabs/code/environments/production/modules/helloworld

There are 3 directories under the directory:

Helloworld/ ├── files │ └── hw.txt ├── manifests │ └── init.pp └── templates

Files and templates directory to store the template file, the template file is hw.txt

The init.pp file of manifests is used to define the resources and operations required by the module.

Init.pp

Class helloworld {file {'/ tmp/hw.txt': ensure = > 'file', source = >' puppet:///modules/helloworld/hw.txt', mode = > '0644', owner = > 'root', group = >' root',}}

The module defines a helloworld class, the resource is file, and its content is "Hello world!".

'/ tmp/hw.txt' the path and name of the file generated for the client

Ensure defines this type as a file, along with link and directory, or it can be defined as present and absent to indicate that the file exists or does not exist

Mode is file permission 644

The owner of owner file is root

Group filegroup is root

[service]

Start the server-side service

Systemctl start puppetserversystemctl start puppet

Start the client service

Systemctl start puppet

Client executes puppet agent-t user pull configuration

The server needs to sign the certificate

Puppet cert sign-all

[test]

After the client executes the puppet agent-t command, you can see that the file has been generated

Notice: / stage [main] / Helloworld/ File [/ tmp/hw.txt] / ensure: defined content as'{md5} 59ca0efa9f5633cb0371bbc0355478d8'Notice: Applied catalog in 0.60 seconds

At this point, a simple Puppet CS environment has been built.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 238

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report