puppet

configuration was kept in the master only

1) puppet master

sudo apt-get install puppetmaster

/etc/puppet/puppet.conf

 

/etc/puppet/manifests/site.pp ( to install git on agent )

node "pong-VirtualBox" {
package { "git-core":
 ensure => "installed"
}
}

NOTE : site.pp is the main file to call all pp
by using
import “xx.pp”

or we can ensure=>present
see the different in https://ask.puppetlabs.com/question/4947/is-it-better-to-use-present-or-installed/

or we can add another : require => Package[“another-packagename”], require => File[“foldername”]

or just touch the file

node "pong-VirtualBox" {
file { "/root/helloworld.txt":
ensure => file,
owner => "root",
group => "root",
mode => 0644
}
}

or write the file using templates <% %>
https://docs.puppetlabs.com/puppet/latest/reference/lang_template_erb.html

node &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;pong-VirtualBox&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot; {
file { &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;/root/config.js&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;:
ensure =&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; file,
owner =&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;root&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;,
group =&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;root&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;,
mode =&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; 0644,
content =&amp;amp;amp;amp;amp;amp;amp;amp;gt; template(&amp;amp;amp;amp;amp;amp;amp;amp;quot;whatever/whatever.js.erb&amp;amp;amp;amp;amp;amp;amp;amp;quot;),
}
}

Service

service { &amp;amp;amp;amp;amp;amp;amp;amp;quot;servicename&amp;amp;amp;amp;amp;amp;amp;amp;quot;:
enable =&amp;amp;amp;amp;amp;amp;amp;amp;gt; true, ensure =&amp;amp;amp;amp;amp;amp;amp;amp;gt; running,
require =&amp;amp;amp;amp;amp;amp;amp;amp;gt; Package[&amp;amp;amp;amp;amp;amp;amp;amp;quot;packagename&amp;amp;amp;amp;amp;amp;amp;amp;quot;],
}

NOTE : pp can be imported, For example,

import nodes/*.pp
sudo service puppetmaster restart

ถ้าใครอยากดูพวกข้อความต่างๆ บน Master แบบ Real-Time ให้รันแบบนี้แทน

sudo puppet master --verbose --no-daemonize

list cert of agent

sudo puppet cert list

NOTE : –all sign cert

sudo puppet cert sign puppetClientInTheServerEtcHostsFile

use it efficiently try Puppetmasterd https://docs.puppetlabs.com/guides/passenger.html 2) puppet agent

sudo apt-get install puppet

/etc/puppet/puppet.conf

[agent]
server=whateverServerNameInTheClientEtcHostsFile
report=true

Default internal is 30 minutes polling, but we can change runinterval=10

sudo service puppet restart

enable agent to begin poll to master

sudo puppet agent --enable

This will store PID in the /var/run/puppet/agent.pid or in the process

puppet 1794 0.2 2.0 129260 41212 ? Ssl 09:18 0:03 /usr/bin/ruby1.8 /usr/bin/puppet master --masterport=8140
root 2833 0.0 2.0 132992 41224 ? Ss 09:34 0:00 /usr/bin/ruby1.8 /usr/bin/puppet agent

poll now

sudo puppet agent --test
info: Caching catalog for pong-virtualbox
info: Applying configuration version '1450775961'
info: Creating state file /var/lib/puppet/state/state.yaml
notice: /Stage[main]//Node[pong-virtualbox]/File[/root/helloworld.txt]/ensure: created
notice: Finished catalog run in 0.01 seconds

ref : http://www.kanouivirach.com/2014/11/puppet-master-and-agent-on-local/ http://manuel.kiessling.net/2014/03/26/building-manageable-server-infrastructures-with-puppet-part-1/   3) puppet module Download from : https://forge.puppetlabs.com/ puppet version 2.7.11 did not have the module subcommand, so /etc/puppet/puppet.conf

[master]
manifest=/path/to/main/file.pp

modulepath=/path/to/modules

ref : http://serverfault.com/questions/349046/could-not-find-class-and-yet-it-is-there

NOTE :

  • modulepath is a search path for modules.
  • puppet.conf references is here. -> https://docs.puppetlabs.com/references/4.3.latest/configuration.html

Example

java

tomcat

apache

logstash

NOTE : dependency for logstash is stdlib and fileconcat

elasticsearch

nginx

mongodb

ref : http://docs.puppetlabs.com/puppet/latest/reference/modules_installing.html

Create own module

modulename

|_manifests

|__ init.pp ( contains modulename class )

|_templates

|__whatever.js.whatever.erb

init.pp

class modulename($whatever_param=&amp;amp;amp;amp;amp;amp;amp;amp;quot;value&amp;amp;amp;amp;amp;amp;amp;amp;quot;){&amp;amp;amp;amp;amp;amp;amp;amp;lt;/pre&amp;amp;amp;amp;amp;amp;amp;amp;gt;
package{ ... }

file{ ... }

}

calling class

class { &amp;amp;amp;amp;amp;amp;quot;modulename&amp;amp;amp;amp;amp;amp;quot;: whatever_param=&amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;quot;vv&amp;amp;amp;amp;amp;amp;quot; }

ref : https://docs.puppetlabs.com/puppet/latest/reference/lang_conditional.html

NOTE: we can use in template <%= whatever_param %>

<% if @whatever_param == true %>

<% end %>

ref : https://docs.puppetlabs.com/pe/latest/quick_writing_nix.html

Problem when purging logstash

userdel: user logstash is currently logged in
mv /opt/logstash /opt/_logstash

Then we can purge logstash.
http://askubuntu.com/questions/458930/cannot-delete-user

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s