wget apt.puppetlabs.com/puppetlabs-release-precise.deb
sudo dpkg -i puppetlabs-release-precise.deb
sudo apt-get update
sudo puppet resource package puppetdb ensure = latest
sudo puppet resource service puppetdb ensure = running enable = true
[master]
storeconfigs = true
storeconfigs_backend = puppetdb
[main]
server = puppet # dns name
port = 8081
class test {
file {"/ tmp / 1":
ensure => present,
content => "$ :: ipaddress",
}
}
class test {@@file
{"/ tmp / 1":
ensure => present,
content => "$ :: ipaddress",
}
}
@@file
resource is stored in puppetdb for later recall.class export_test {
File << | | >> {
}
}
node 'firstnode' {
include test
}
node 'secondnode' {
include exporttest
}
define host {
address 23.253.222.185
alias magnetodb-1
host_name magnetodb-1
use linux-server
hostgroups dev
}
define service {
service_description ssh
use local-service
check_command check_ssh
servicegroups GENERIC_GROUP
host_name magnetodb-1
}
define service {
service_description PING
use nagios-graph-service
check_command check_ping! 100.0.20%! 500.0.60%
servicegroups GENERIC_GROUP
host_name magnetodb-1
}
class nagios :: host :: generic {@@nagios_host
{"$ nagios_hostname":
ensure => present,
alias => $ nagios_hostname,
host_name => "$ nagios_hostname",
address => $ ipaddress,
hostgroups => $ env,
use => 'linux-server',
target => "$ nagios :: params :: nagios_base / hosts / $ {env} _ $ {nagios_hostname} .cfg", # the location of the resource at the node where it will be exported
tag => $ :: deployment_id,
notify => Service ["nagios"],
require => File [$ nagios :: params :: nagios_dirs],
}@@nagios_service
{"ssh $ ipaddress":
ensure => present,
check_command => 'check_ssh',
host_name => $ nagios_hostname,
servicegroups => 'GENERIC_GROUP',
service_description => 'ssh',
use => 'local-service',
target => "$ nagios :: params :: nagios_base / hosts / services / $ {env} _ $ {nagios_hostname} .cfg",
tag => $ :: deployment_id,
notify => Service ["nagios"],
require => File [$ nagios :: params :: nagios_dirs]
}@@nagios_service
{"ping $ ipaddress":
ensure => present,
check_command => 'check_ping! 100.0.20%! 500.0.60%',
host_name => $ nagios_hostname,
servicegroups => 'GENERIC_GROUP',
service_description => 'PING',
use => 'nagios-graph-service',
target => "$ nagios :: params :: nagios_base / hosts / services / $ {env} _ $ {nagios_hostname} .cfg",
tag => $ :: deployment_id,
notify => Service ["nagios"],
}
}
class nagios_server {
Nagios_host << | tag == $ :: deployment_id | >> {
}
Nagios_service << | tag == $ :: deployment_id | >> {
}
#tag == $ :: deployment_id means that we select all resources with a specific tag from the database, this is convenient when we have several nagios that must be checked by different hosts.
# variable $ deployment_id will need to be pre-declared in site.pp
}
$ deployment_id = "dev"
$ env = "dev"
node "nagios-1" {
$ nagios_hostname = "$ {hostname}"
class {'nagios :: server':
}
}
node "nagios-client-1" {
$ nagios_hostname = "$ hostname_ $ ipaddress"
class {'nagios :: hosts :: generic':}
}
puppet node clean "node_certname"
docs.puppetlabs.com/puppetdb/1/connect_puppet_master.html
projects.puppetlabs.com/projects/1/wiki/using_stored_configuration
docs.puppetlabs.com/guides/exported_resources.html
Source: https://habr.com/ru/post/219249/
All Articles