DevOps@RajeshKumar.XYZ
MP owerShell Script written in version 2
may not natively work in versions 3+
Don’t support non Windows operating systems |
Requiresan Active Directory infrastructure |
Extensible... using scripts |
---|
Puppet overcome the shortcomings of other
configuration management approaches
“What”instead of “how” |
Less complex |
Easy to create,understand,and share |
---|
Puppet manages your infrastructure. You describe configurations in an easy-to-read declarative language, and Puppet will bring your systems into the desired state and keep them there.
At the end of this course you will be able to:
Server is called the Puppet Master |
Client are called nodes |
---|
Individual configuration items are called resource declarations
Package |
File |
Service |
---|
node 'apserver'{
Package {'ntp':
ensure => installed,
}
...
Ensures the ntp package is installed on appserverOl
...
service { 'ntpd':
ensure => 'running',
enable => true,
}
}
Ensures the ntpd service is enabled and running
Answers the question,”What state do we want this resource in?” |
=> | Attribute/value pairs are separated by a “fat comma” |
---|
yum (RedHat) |
apt(Ubuntu) |
Windows(Windows) |
---|
Stored in /etc/pu ppet/environ ments/prod uction/manifests
Puppet automatically loads all .pp files in the manifests directory
$ sudo nano
/etc/puppet/environments/production/manifests/nodes . pp
node 'wiki'{
}
node 'wikitest'{
}
Create a simple text file on each
Puppet node that says/’Created by
Puppet”followed bya timestamp
Create a simple text file on each
Puppet node that says/’Created by
Puppet”followed bya timestamp
file{'/info.txt':
ensure => 'present',
content => inline_template(created by puppet at <%= Time.now %>\n"),
}
node 'wiki'{
file { '/info.txt':
ensure => 'present',
content => inline_template(created by puppet at <%= Time.now %>\n"),
}|
}
node 'wikitest'{
}
What about the puppet override the file and for
some reason we need to recover the version>
package{ 'ntp':
ensure => 'installed',
}
node 'wiki'{
file { '/info.txt':
ensure => 'present',
content => inline_template(created by puppet at <%= Time.now %>\n"),
}
package{ 'ntp':
ensure => 'installed',
}
}
node 'wikitest'{
package{ 'ntp':
ensure => 'installed',
}
}
service { 'ntpd':
ensure => 'running',
enable => true,
}
service { 'ntp':
ensure => 'running',
enable => true,
}
$ntpservice = $osfamily ? {
'redhat' => 'ntpd',
'debian' => 'ntp',
default => 'ntp',
}
Replace:
service { 'ntpd':
ensure => 'running',
enable => true,
}
With:
service { $ntpservice:
ensure => 'running',
enable => true,
}
DRY = Don’t Repeat Yourself!
Puppet class # object-oriented class
A named collection of resource declarations,
variables, selectors, or any other Puppet code
class linux {
package {'ntp':
ensure => 'installed',
}
}
node 'wiki' {
{ class 'linux': }
}
class linux {
$admintoo1s = ['git' 'nano', 'screen']
package { $admintoo1s:
ensure => 'installed',
}
}