Aprenda neste vídeo a provisionar um ambiente de demonstração com Puppet.
Demo repository to demonstrate how to use puppet 7.
To simplify to installation process 3 Vagrant Boxes will be used, as defined in the nodes.json
file, change the ip address or memory settings.
{
"nodes": {
"master": {
":ip": "192.168.32.5",
":memory": 2048,
":bootstrap": "scripts/bootstrap-master.sh"
},
"node01": {
":ip": "192.168.32.10",
":memory": 512,
":bootstrap": "scripts/bootstrap-node.sh"
},
"node02": {
":ip": "192.168.32.20",
":memory": 512,
":bootstrap": "scripts/lbootstrap-node.sh"
}
}
}
Download and install Vagrant from https://www.vagrantup.com/downloads
git clone https://github.com/devopshouse/puppet-in-vagrant-examples.git
cd puppet-in-vagrant-examples/provision
vagrant up
The Puppet Server initial installation and configuration process was done by the bootstrap scripts bootstrap-master.sh. The Puppet agent nodes were configured using the bootstrap-node.sh bootstrap script. During the agent initialization new certificates request were generated.
To verify agent certificates executed the following commands:
vagrant ssh master
sudo -i
puppetserver ca list
Output:
Requested Certificates:
node01.station (SHA256) C1:A7:53:D0:45:7C:F1:A5:78:9F:EE:1F:08:D1:31:39:53:67:69:CE:4C:A4:EF:E4:E2:9C:5C:AA:78:5B:FE:61
node02.station (SHA256) F6:82:45:43:B3:39:A8:7B:ED:22:FD:C4:D9:11:2C:E5:C3:55:B9:CB:64:AF:C9:69:27:F0:02:21:7A:CC:C9:A1
The command output shows the the agent certificate request.
puppetserver ca sign --certname=node01.station
puppetserver ca sign --certname=node02.station
Sign all agent certificates.
puppetserver ca sign --all
vagrant ssh node01
sudo -i
puppet agent --test
vagrant ssh master
sudo -i
cd /etc/puppetlabs/code/environments/production
4 . Create the web server module folder structure
mkdir -p modules/webserver/{files,manifests}
/etc/puppetlabs/code/environments/production/modules/webserver/manifests/init.pp
with the following content:class webserver {
package {
'apache2':
ensure => installed
}
file { "/var/www/html/index.html":
ensure => file,
mode => '755',
owner => root,
group => root,
source => "puppet:///modules/webserver/index.html",
require => Package['apache2']
}
service {
'apache2':
ensure => true,
enable => true,
require => Package['apache2']
}
}
/etc/puppetlabs/code/environments/production/modules/webserver/files/index.html
with the following content:<html>
<head>
<title>Congratulations</title>
<head>
<body>
<h1>Congratulations</h1>
<p>Apache index.html installed by Puppet.</p>
</body>
</html>
/etc/puppetlabs/code/environments/production/manifests/site.pp
with the following content:node default {
include webserver
}
runinterval
in the puppet agent node configuration file /etc/puppetlabs/puppet/puppet.conf
or login in the node and manually trigger the update:vagrant ssh node01
Become root into node
sudo -i
Force the configuration update
puppet agent --test
Check for the web server installation:
curl 127.0.0.1
<html>
<head>
<title>Congratulations</title>
<head>
<body>
<h1>Congratulations</h1>
<p>Apache index.html installed by Puppet.</p>
</body>
</html>