Previous articles introduced the initial installation configuration of Poppet:
Portal:
Today I will introduce the specific practical functions of Poppet. In fact, my understanding is how to be lazy.
1. Fill in the file content:
(Server ):
Modify the server configuration file:
# Vi/etc/puppet/manifests/site. pp
-----------------
Node default {
File {"/tmp/test ":
Content => "this is a test file ";
}
}
-----------------
Restart puppetmaster to update the configuration file.
# Service puppetmaster restart
(Client ):
Restart puppet (no need to restart)
# Service puppet restart
Synchronize files:
# Puppetd -- server server.example.com -- test
------------------
Warning: peer certificate won't be verified in this SSL session
Info: Caching certificate for client.example.com
Info: Caching certificate_revocation_list for ca
Info: Caching catalog for client.example.com
Info: Applying configuration version '20140901'
Notice:/Stage [main] // Node [default]/File [/tmp/test]/ensure: defined content as '{md5} 100b144907af2a4786003758a0a6a563'
Info: Creating state file/var/lib/puppet/state. yaml
Notice: Finished catalog run in 0.02 seconds
------------------
View the/tmp/test file and file content
# Cat/tmp/test
-----------
This is a test file
-----------
2. File distribution:
Puppet allows you to push files to the managed machine by using the source attribute of the file type.
1: Modify/etc/puppet/fileserver. conf
2: Modify/etc/puppet/manifests/site. pp
Instance: Transfer puppet-2.6.13.tar.gz under/rootdirectory on the server to the/tmp directory of the client server. The file name remains unchanged.
# Vi/etc/puppet/fileserver. conf
----------------
[Files]
Path/root
Allow 192.168.7.0/24
----------------
# Vi/etc/puppet/manifests/site. pp
Add to node default:
---------------
File {"/tmp/puppet-2.6.13.tar.gz ":
Source = & gt; "puppet: // $ puppetserver/files/puppet-2.6.13.tar.gz ",
}
---------------
Restart the poppetmaster Service
# Service poppetmaster restart
(Client ):
Execute the update command
# Puppetd -- test -- server server.example.com
Here, "$ puppetserver" is the name of the puppet Server, that is, the hostname of the local machine. The online tutorials are all specified in hosts. We recommend that you use internal DNS for resolution in the production environment.