Puppet Learning Documents

Source: Internet
Author: User

192.168.6.226 as the service side

192.168.6.223 for clients

1,puppet Installation

Service side

Turn off selinux iptables

Add Hosts

Vim/etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4localhost4.localdomain4 web10

:: 1 localhost localhost.localdomainlocalhost6 localhost6.localdomain6 web10

127.0.0.1 www.test1.com www.aaa.com www.test.com

192.168.6.223 web9.aming.com

192.168.6.226 web10.aming.com

Vim/etc/sysconfig/network

Hostname web10.aming.com

Yum Install Puppetmaster–y

Start puppetmaster

Prompt Error need to include host name in hosts

Starting Puppetmaster:dnsdomainname:Unknown Host

Dnsdomainname:unknown Host

PS Aux|grep Puppet

Puppet 31418 3.9 8.4 142812 42328? SSL 17:07 0:01/usr/bin/ruby/usr/sbin/puppetmasterd

Port number 8140

Client

Vim/etc/hosts

192.168.6.226 web10.aming.com

192.168.6.223 web9.aming.com

Vim/etc/sysconfig/network

Hostname web9.aming.com

Press-Fit puppet

Yum Install Puppet–y

/etc/init.d/puppet start

in the add configuration on client

Vim/etc/puppet/puppet.conf

Listen = True

Server = web9.aming.com

Runinterval = 30

Puppet Applications

registering a CA

Puppet agent–test–server web10.aming.com ( registration command )

Info:csr_attributes File Loading From/etc/puppet/csr_attributes.yaml

Info:creating a new SSL certificaterequest for web10.aming.com

Info:certificate Request fingerprint (SHA256):D d:17:9f:11:4b:01:77:32:8f:38:22:9c:48:51:35:57:8d:eb:f3:94:1b : 52:8f:ca:ca:53:53:fe:a6:ec:b9:4c

Exiting; No certificate found Andwaitforcert is disabled

Prompt registration of the above content is successful

Puppet cert list–all View CA

+ "web10.aming.com" (SHA256) 6a:2e:1d:77:8f:64:ba:39:63:b9:5a:1f:b0:60:66:8e:27:68:60:52:d5:53:fe:d2:9f:68:41:05: A7:64:16:16

+ "web9.aming.com" (SHA256) bd:8f:d1:6e:52:ed:d2:08:dc:4d:de:a2:d1:23:21:08:1a:69:fa:15:39:4f:8a:37:10:65:5d:ed:0 0:B5:59:C6 (alt names: "Dns:puppet", "DNS:puppet.aming.com", "DNS:web9.aming.com")

See a list of CAs that have been added to the server with the + sign

If the + sign does not appear , use

Puppet cert--sign web10.aming.com

Test

Create a new file on the server site.pp

Vim/etc/puppet/manifests/site.pp

Node Default {

File {

"/tmp/123.txt": Content = "Test,test";

}

}

After saving

On the client input

Puppet–test–server web9.aming.com

123.txt after / tmp

Info:caching Certificate forweb10.aming.com

Info:caching certificate_revocation_listfor CA

Info:caching Certificate forweb10.aming.com

Notice:ignoring--listen on Onetime run

Warning:unable to fetch my nodedefinition, but the agent run would continue:

Warning:undefined method ' include? ' Fornil:nilclass

Info:retrieving pluginfacts

Info:retrieving Plugin

Info:loading Facts

info:caching Catalog for Web10.aming.com

Info:applying configuration version ' 1456399416 '

notice:/stage[main]/main/node[default]/file[/tmp/123.txt]/ensure:defined content as ' {MD5} C175A2C7AEFDBA02F99B8A5B019B18CB '

Info:creating State File/var/lib/puppet/state/state.yaml

Automatic authentication

Client

/etc/init.d/puppet stop

rm–rf/var/lib/puppet/ssl/*

Service side

Puppet cert Clean–all

Vim/etc/puppet/puppet.conf

Add a

Autosign = True

Vim/etc/puppet/autosign.conf

*.aming.com

Start puppetmaster

/etc/init.d/puppetmaster start

start The puppet client

/etc/init.d/puppet start

module example

First edit Create a custom module in/etc/puppet/modules/testm

when you create a CD testm

MKDIR-PV {files,manifests,templates}

CD files

Echo Sdfasfaasfaming.com>aming.txt

Vim manifests/init.pp

Class testm{

file {"/tmp/aming.txt":

Owner = "Root",

Group = "Root",

mode = 0400,

Source = "puppet://$puppetserver/modules/testm/aming.txt"

} }

Vim manifests/site.pp

$puppet = ' web9.aming.com '

Node ' WEB10 ' {

Include Testm

}

WEB10 by looking at the files in puppet cert List–all

Tail–f/var/log/message

Feb 02:03:06 localhostpuppet-agent[59793]: (/stage[main]/testm/file[/tmp/aming.txt]/ensure) definedcontent as ' { Md5}a3a6d94ec56c9a449377625873340f10 '

Feb 02:03:06 localhostpuppet-agent[59793]: Finished catalog run in 0.37 seconds

Prompt for above content success

Do directory Resources

CD Testm/files

Vim manifests/init.pp

Class testm{

file {"/tmp/aming.txt":

Owner = "Root",

Group = "Root",

mode = 0400,

Source = "puppet://$puppetserver/modules/testm/aming.txt"

} }

Class Nginx {

file {"/usr/local/nginx":

Owner = "Root",

Group = "Root",

Source = "puppet://$puppetserver/modules/testm/nginx",

Recurse = True,

Purge = true # supports delete operations

}

}

~ VIMMANIFESTS/SITE.PP

$puppet = ' web9.aming.com '

Node ' WEB10 ' {

Include Testm

Include Nginx

}

View Logs

Tail–f/var/log/message

Feb 02:29:31 localhostpuppet-agent[23849]:(/stage[main]/nginx/file[/usr/local/nginx/sbin/nginx.old]/ensure) Definedcontent as ' {md5}347341e105e668ea6220cbaa09dd6e7d '

Feb 02:29:31 localhostpuppet-agent[23849]: (/stage[main]/nginx/file[/usr/local/nginx/conf/win-utf]/ensure) Defined content as ' {md5}3749ffe19bedd842eb87e83d544e5ce6 '

Feb 02:29:31 localhostpuppet-agent[23849]:(/stage[main]/nginx/file[/usr/local/nginx/conf/mime.types.default]/ ensure) defined content as ' {md5}bd837e7b34f5c9b8d89957d0527f0d44 '

Feb 02:29:31 localhostpuppet-agent[23849]:(/stage[main]/nginx/file[/usr/local/nginx/conf/uwsgi_params]/ensure) Definedcontent as ' {MD5}2AAAF1E3535752E74D2942DB8B3632CB '

Feb 02:29:31 localhostpuppet-agent[23849]: (/stage[main]/nginx/file[/usr/local/nginx/conf/fastcgi.conf]/ensure) Defined content as ' {md5}c53b8ddf4250e742594d24c55e73c0df '

Feb 02:29:31 localhostpuppet-agent[23849]:(/stage[main]/nginx/file[/usr/local/nginx/conf/nginx.conf]/ensure) Definedcontent as ' {md5}a79bb7bb340a80057bce4772935548f0 '

Feb 02:29:31 localhostpuppet-agent[23849]:(/stage[main]/nginx/file[/usr/local/nginx/conf/scgi_params]/ensure) Definedcontent as ' {md5}e9fd19c7d1f0cecbd46b3cb041ae19c7 '

Feb 02:29:31 localhostpuppet-agent[23849]:(/stage[main]/nginx/file[/usr/local/nginx/html/50x.html]/ensure) Definedcontent as ' {md5}d74f9cdd604653c22c6752c46fffd587 '

Feb 02:29:31 localhostpuppet-agent[23849]: (/stage[main]/nginx/file[/usr/local/nginx/uwsgi_temp]/ensure) created

Feb 02:29:32 localhostpuppet-agent[23849]:(/stage[main]/nginx/file[/usr/local/nginx/logs/access.log]/ensure) Definedcontent as ' {md5}68a546f08e828ad73f7a37860fe977fd '

Prompt for above content success

Remote execution commands

CD Testm/files

Vim manifests/init.pp

Class Nginx {

file {"/usr/local/nginx":

Owner = "Root",

Group = "Root",

Source = "puppet://$puppetserver/modules/testm/nginx",

Recurse = True,

Purge = True

}

exec {"123":

unless = "Test-f/tmp/aminglinux.txt",

Path = ["/bin", "/sbin", "/usr/bin", "/usr/sbin"],

Command = "Touch/tmp/aminglinux.txt"

}

}

unless = "Test-f/tmp/aminglinux.txt" can be created when a file does not exist

Onlyif = "Test-f/tmp/aminglinux.txt" when asked to exist is to create

Cron Module

CD Testm/files

Vim manifests/init.pp

Class Nginx {

file{"/usr/local/nginx":

Owner = "Root",

Group = "Root",

Source = "puppet://$puppetserver/modules/testm/nginx",

Recurse = True,

Purge = True

}

exec {"123":

unless = "Test-f/tmp/aminglinux.txt",

Path =>["/bin", "/sbin", "/usr/bin", "/usr/sbin"],

Command = "Touch/tmp/aminglinux.txt"

}

cron{"Aming1":

Command = "/sbin/ntpdate time.windows.com",

user = "Root",

minute = "*/10",

#ensure = "Absent" whether to clear the command

}

}

Description: The time of day and month respectively corresponding Puppet inside the minute,hour,monthday,month,weekday,ensure is set to absent to delete the task, if you do not set a row to establish


This article is from the "Learn Linux" blog, so be sure to keep this source http://10265013.blog.51cto.com/10255013/1745380

Puppet Learning Documents

Related Article

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.