Puppet Class: puppet
- Defined in:
- manifests/init.pp
Overview
Class: puppet
The puppet class handles the maintenance of both puppet agents
and the master.
Parameters
- agent
-
Agent configuration block
- agent_opts
-
Options to pass along to the puppet agent when starting at boot The default is an empty string.
- agent_start
-
Specifies whether to start the puppet agent at boot The default is ‘false’
- clients
-
An array of IP addresses that the default site will provide puppet service to. The default is an empty array.
- listen
-
The IP address that passenger (Apache) should listen to. This option is only valid when mode is set to ‘passenger’. The default is ‘127.0.0.1’.
- log_level
-
The logging level for passenger (Apache). This option is only valid when mode is set to ‘passenger’. The default is ‘warn’.
- main
-
Main configuration block
- master
-
Master configuration block
- master_opts
-
Options to pass along to the puppetmaster when starting The default is an empty string.
- mode
-
The mode of operation the module is to run as. Possible values are ‘agent’, ‘master’, or ‘passenger’. Puppetmasters will use webbrick when mode is ‘master’ or passenger when mode is set to ‘passenger’. The default is ‘agent’
- modules
-
An array of modules that should be installed. The modules must exist in the PuppetLab’s Module Forge. The default is an empty array.
- remote_ca
-
An array of URLs for remote CA workers. This is used when configuring a front-end balancer to backend CA workers. Only the first two elements of the array are used.
- remote_workers
-
An array of URLs for remote workers. This is used when configuring a front-end balancer to multiple backend workers.
- site_privacy_warning
-
Toggle the display of the warning that detailes the lack of privacy between sites. The default is true
- sites
-
Hash-of-hashes that denotes the sites the puppetmaster will provide service for.
- sslverifyclient
-
Sets the SSLVerifyClient option in the Apache2 configuration. The possible values are ‘require’ and ‘optional’. Setting the value to ‘optional’ will mimic standalone puppetmaster behavior. The default is ‘require’
- tidy
-
Toggle the tidying of the clientbucket directory for agents and the buckket and reports directories for masters. The default is true
- tidy_age
-
The age to tidy the bucket, clientbucket, and reports directories to. The default is ‘52w’
- user
-
User configuration block
- workers
-
The number of passenger workers to create. This option only takes effect when mode is set to ‘passenger’. Default is 1
Variables
- confdir
-
The main Puppet configuration directory. The default for this setting is calculated based on the user. If the process is running as root or the user that Puppet is supposed to run as, it defaults to a system directory, but if it’s running as any other user, it defaults to being in the user’s home directory.
- client_packages
-
Array of packages that ‘agents’ need.
- dev_packages
-
Puppet developer packages to be installed.
- puppet_group
-
The puppet user’s group name.
- puppet_user
-
The user that puppet will operate as, typcially ‘puppet’.
- sys_group
-
The sytem user’s group name, typically root but can be different depending on the OS.
- sys_user
-
The sytem username, typically root but can be different depending on the OS.
- vardir
-
Where Puppet stores dynamic and growing data.
Examples
node myagent {
class { 'puppet':
mode => 'agent',
}
}
# accomplishes the same thing done for 'myagent' above
node myotheragent {
class { 'puppet': }
}
node smallagent {
class { 'puppet':
tidy_age => '4w',
}
}
node mymaster {
class { 'puppet':
mode => 'master',
clients => [ 'host1', 'host2', etc ],
modules => [
'foolean-ssh'
],
}
}
# A puppetmaster running passenger
node myothermaster {
class { 'puppet':
mode => 'passenger',
workers => 5,
clients => [ 'host1', 'host2', etc ],
modules => [
'foolean-ssh'
],
}
}
# A puppetmaster running passenger and multiple sites
node mysitemaster {
class { 'puppet':
mode => 'passenger',
workers => 5,
clients => [ 'host1', 'host2', etc ],
modules => [
'foolean-ssh'
],
sites => {
'site1' => {
'clients' => [ 'host1', 'host2', etc ],
},
'site2' => {
'clients' => [ 'host1', 'host2', etc ],
},
},
}
}
CAVEAT EMPTOR!
******************************************************
*** DO NOT USE MORE THAN ONE SITE PER PUPPETMASTER ***
*** IF YOU NEED TO MAINTAIN PRIVACY BETWEEN SITES! ***
******************************************************
Puppet allows for the execution of arbitrary ruby code on the puppetmaster.
This can be accomplished in manifest files by using the inline_template
function or in template files themselves. The arbitrary code will execute
in the context of the puppet daemon, typically uid:puppet, gid:puppet. While
it limits the scope of readable and writable files over the entire file
system it does also mean that any file puppet can read so can anyone with
the rights to upload manifests and templates. Because of this "feature"
there is no way to ensure privacy between sites.
See the README file for examples
File and Directory Permissions
This class attempts to remove all 'world' permissions and set ownership
to the puppet user and puppet group as there is really no reason for any
other users to access the puppet files. The premis is that only an
administrator (e.g. someone with root) should be running puppet on a
system. Likewise only an administrator or someone in the puppet group
should be looking at any of the puppet files.
Supported Operating Systems
* CentOS
* Debian
* Fedora
* OpenSUSE
* RedHat
* Ubuntu
Authors
Bennett Samowich <bennett@foolean.org>
Copyright
Copyright (c) 2013 Foolean.org
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 |
# File 'manifests/init.pp', line 238
class puppet (
$tidy = true,
$tidy_age = '52w',
$mode = 'agent',
$agent_start = false,
$agent_opts = '',
$master_opts = '',
$sites = false,
$agent = false,
$main = false,
$master = false,
$workers = 1,
$listen = '127.0.0.1',
$remote_ca = false,
$remote_workers = false,
$log_level = 'warn',
$modules = [],
$clients = [],
$developers = [],
$site_privacy_warning = true,
$recurse = false,
$sslverifyclient = 'require',
)
{
# We must have puppet version 2.7 or higher
if ( versioncmp( $::puppetversion, '2.7' ) < 0 ) {
fail( 'This module requires puppet version 2.7 or greater' )
}
# We must declare ourselves as either an agent or master
if ( $mode != 'agent' and $mode != 'master' and $mode != 'passenger' ) {
fail("invalid mode '${mode}', must be 'agent', 'master', or 'passenger'")
}
# sslverifyclient must be either 'require' or 'optional'
if ( $sslverifyclient != 'require' and $sslverifyclient != 'optional' ) {
fail("invalid sslverifyclient '${sslverifyclient}', must be 'require' or 'optional'")
}
# Select the client packages
$client_packages = $::operatingsystem ? {
'centos' => 'puppet',
'debian' => [ 'puppet', 'puppet-common' ],
'fedora' => 'puppet',
'opensuse' => 'puppet',
'redhat' => 'puppet',
'ubuntu' => [ 'puppet', 'puppet-common' ],
default => false,
}
# Fail if we aren't configured for this operating system
if ( ! $client_packages ) {
fail( "Unknown OS '${::operatingsystem}', unable to select packages" )
}
# sys_user
$sys_user = $::operatingsystem ? {
default => 'root',
}
# sys_group
$sys_group = $::operatingsystem ? {
default => 'root',
}
# puppet_user
$puppet_user = $::operatingsystem ? {
default => 'puppet',
}
# puppet_group
$puppet_group = $::operatingsystem ? {
default => 'puppet',
}
# The name of the puppetmaster service
$puppetmaster_service = $::operatingsystem ? {
'opensuse' => 'puppetmasterd',
default => 'puppetmaster',
}
# The command to start the puppetmaster service
$puppetmaster_status = $::operatingsystem ? {
'fedora' => "service ${puppetmaster_service} status",
'opensuse' => "systemctl status ${puppetmaster_service}",
default => "/etc/init.d/${puppetmaster_service} status",
}
# confdir
$confdir = $::operatingsystem ? {
default => '/etc/puppet',
}
# vardir
$vardir = $::operatingsystem ? {
default => '/var/lib/puppet',
}
# apache2 group
$apache2_group = $::operatingsystem ? {
'centos' => 'apache',
'fedora' => 'apache',
'opensuse' => 'www',
'redhat' => 'apache',
default => 'www-data'
}
# Path to apache's log directory
$apache2_logdir = $::operatingsystem ? {
'centos' => '/var/log/httpd',
'fedora' => '/var/log/httpd',
'redhat' => '/var/log/httpd',
default => '/var/log/apache2',
}
# Path to apache2's sites-available directory
$sites_available = $::operatingsystem ? {
'centos' => '/etc/httpd/conf.d',
'fedora' => '/etc/httpd/conf.d',
'opensuse' => '/etc/apache2/conf.d',
'redhat' => '/etc/httpd/conf.d',
default => '/etc/apache2/sites-available'
}
# Path to the puppet defaults files
$puppet_defaults = $::operatingsystem ? {
'debian' => '/etc/default/puppet',
'ubuntu' => '/etc/default/puppet',
default => false
}
# Path to the puppetmaster defaults files
$puppetmaster_defaults = $::operatingsystem ? {
'debian' => '/etc/default/puppetmaster',
'ubuntu' => '/etc/default/puppetmaster',
default => false
}
# Name of the Apache controler utility
$apache2ctl = $::operatingsystem ? {
'centos' => 'apachectl',
'fedora' => 'apachectl',
'redhat' => 'apachectl',
default => 'apache2ctl',
}
# Make sure the client packages are installed
package { $client_packages:
ensure => 'installed',
}
# Only the puppet master may override the defaults
include puppet::master::defaults
if ( $mode == 'master' or $mode == 'passenger' ) {
if ( $main ) {
$use_main = $main
} else {
$use_main = $puppet::master::defaults::main
}
if ( $agent ) {
$use_agent = $agent
} else {
$use_agent = $puppet::master::defaults::agent
}
if ( $master ) {
$use_master = $master
} else {
$use_master = $puppet::master::defaults::master
}
$use_sites = $sites
} else {
$use_main = $puppet::master::defaults::main
$use_agent = $puppet::master::defaults::agent
$use_master = false
$use_sites = false
}
# Create the configuration files
class { 'puppet::config':
agent => $use_agent,
main => $use_main,
master => $use_master,
sites => $use_sites,
}
# Copy in the rundir script
file { "${confdir}/rundir":
owner => $puppet::sys_user,
group => $puppet::puppet_group,
mode => '0750',
content => template( "${module_name}/etc/puppet/rundir" ),
require => [
File[$confdir],
],
}
# Create the pre-run.d directory
file { "${confdir}/pre-run.d":
ensure => 'directory',
owner => $puppet::sys_user,
group => $puppet::puppet_group,
mode => '0750',
require => [
File[$confdir],
],
}
# Create the post-run.d directory
file { "${confdir}/post-run.d":
ensure => 'directory',
owner => $puppet::sys_user,
group => $puppet::puppet_group,
mode => '0750',
require => [
File[$confdir],
],
}
# Copy in the 90_permissions script
file { "${confdir}/post-run.d/90_permissions":
owner => $puppet::sys_user,
group => $puppet::puppet_group,
mode => '0750',
content => template( "${module_name}/etc/puppet/post-run.d/90_permissions" ),
require => [
File[$confdir],
File["${confdir}/post-run.d"],
],
}
# Ensure that puppet $vardir is correct
file { $vardir:
ensure => 'directory',
owner => $sys_user,
group => $puppet_group,
mode => '2750',
require => Package[$client_packages],
}
# Ensure that $settings::clientbucketdir is correct
file { "${settings::clientbucketdir}":
ensure => 'directory',
owner => $sys_user,
group => $puppet_group,
mode => '2750',
require => File[$vardir],
}
# Keep $settings::clientbucketdir pruned to $age
if ( $tidy ) {
tidy { $settings::clientbucketdir:
age => $tidy_age,
backup => false,
recurse => true,
rmdirs => true,
type => 'ctime',
require => File[$settings::clientbucketdir],
}
}
# Ensure that $settings::client_datadir is correct
file { "${settings::client_datadir}":
ensure => 'directory',
owner => $sys_user,
group => $puppet_group,
mode => '2750',
require => File[$vardir],
}
# Ensure that $settings::clientyamldir is correct
file { "${settings::clientyamldir}":
ensure => 'directory',
owner => $sys_user,
group => $puppet_group,
mode => '2750',
require => File[$vardir],
}
# Ensure that $vardir/facts is correct
file { "${vardir}/facts":
ensure => 'directory',
owner => $sys_user,
group => $puppet_group,
mode => '2750',
force => true,
recurse => true,
require => File[$vardir],
}
# Ensure that $settings::libdir is correct
# NOTE:
# regardles of the value of manage_internal_file_permissions
# puppet will change this to $sys_user.$sys_group anyway
# so we might as well acquiesce even though being owned
# by puppet would seem to be better.
file { "${settings::libdir}":
ensure => 'directory',
owner => $sys_user,
group => $sys_group,
mode => '0770',
require => File[$vardir],
}
# Ensure that $settings::ssldir is correct
file { "${settings::ssldir}":
ensure => 'directory',
owner => $puppet_user,
group => $puppet_group,
mode => '2700',
require => File[$vardir],
}
# Ensure that $settings::statedir is correct
file { "${settings::statedir}":
ensure => 'directory',
owner => $sys_user,
group => $puppet_group,
mode => '2750',
require => File[$vardir],
}
# OS Specific configuration files
if ( $puppet_defaults ) {
# Copy in the /etc/default/puppet file
file { $puppet_defaults:
owner => $puppet::sys_user,
group => $puppet::sys_group,
mode => '0640',
content => template( "${module_name}${puppet_defaults}" ),
}
}
# Make sure the agent is started if we've askef for it to be
if ( $agent_start ) {
service { 'puppet':
ensure => 'running',
enable => true,
subscribe => File["${confdir}/puppet.conf"],
require => [
Package[$client_packages],
File[$vardir],
File["${vardir}/facts"],
File[$settings::clientbucketdir],
File[$settings::client_datadir],
File[$settings::clientyamldir],
File[$settings::libdir],
File[$settings::ssldir],
File[$settings::statedir],
],
}
} else {
service { 'puppet':
ensure => 'stopped',
enable => false,
}
}
# Puppet master specific configurations
if ( $mode == 'master' or $mode == 'passenger' ) {
# Make sure we understand this operating system
case $::operatingsystem {
'centos','fedora','opensuse','redhat': {
$puppetmaster_packages = [ 'puppet-server' ]
}
'debian','ubuntu': {
$puppetmaster_packages = [ 'puppetmaster', 'puppetmaster-common' ]
}
default: {
fail("${title} puppetmaster not configured for ${::operatingsystem}, exiting")
}
}
# Install the puppetmaster packages
package { $puppetmaster_packages:
ensure => 'installed',
}
# If we're running passenger then we have more to do
if ( $mode == 'passenger' ) {
# We're going to disable puppetmaster since we're running passenger
$master_start = false
# Packages required for running passenger
case $::operatingsystem {
'centos': {
$passenger_packages = [ 'mod_passenger' ]
# CentOS doesn't include mod_ssl when installing mod_passenger
exec { 'puppet_install_mod_ssl':
path => [ '/bin', '/usr/bin' ],
command => 'yum install -y mod_ssl',
unless => 'test `rpm -qa mod_ssl | grep -c "^mod_ssl"` -eq 1',
require => Package[$passenger_packages],
before => Exec['puppet-passenger-apache2ctl-graceful'],
}
}
'debian','ubuntu': {
$passenger_packages = [ 'puppetmaster-passenger' ]
}
'fedora': {
$passenger_packages = [ 'mod_passenger' ]
# Fedora doesn't include mod_ssl when installing mod_passenger
exec { 'puppet_install_mod_ssl':
path => [ '/bin', '/usr/bin' ],
command => 'yum install -y mod_ssl',
unless => 'test `rpm -qa mod_ssl | grep -c "^mod_ssl"` -eq 1',
require => Package[$passenger_packages],
before => Exec['puppet-passenger-apache2ctl-graceful'],
}
# Fedora doesn't include mod_proxy_html when installing mod_passenger
exec { 'puppet_install_mod_proxy_html':
path => [ '/bin', '/usr/bin' ],
command => 'yum install -y mod_proxy_html',
unless => 'test `rpm -qa mod_proxy_html | grep -c "^mod_proxy_html"` -eq 1',
require => Package[$passenger_packages],
before => Exec['puppet-passenger-apache2ctl-graceful'],
}
}
'opensuse': {
$passenger_packages = [ 'rubygem-passenger-apache2' ]
}
default: {
fail("${title} passenger not configured for ${::operatingsystem}, exiting")
}
}
# Debian Wheezy's puppetmaster_package attempts to start Apache2 and fails because
# webbrick is still running. When this happens, the rest of this class fails due
# to the dependency on the package. This results in webbrick being disabled and
# passenger not being properly configured. This exec is an attempt to trap the
# the error so rest of the class will run successfully and finish the configuration.
if ( $::operatingsystem == 'debian' ) {
if ( versioncmp( $::operatingsystemrelease, '7.0' ) >= 0 ) {
exec { 'install-passenger':
path => [ '/bin', '/usr/bin', '/sbin', '/usr/sbin' ],
command => '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install puppetmaster-passenger || echo "START=yes" >> /etc/default/puppetmaster; /etc/init.d/puppetmaster restart',
unless => 'test `dpkg --get-selections puppetmaster-passenger | grep -c "puppetmaster-passenger"` -ge 1',
before => Package[$passenger_packages],
}
}
}
# Make sure the passenger packages are installed
package { $passenger_packages:
ensure => 'installed'
}
# If we've specified remote workers then we
# don't need tocreate any local workers.
if ( $remote_workers != false ) {
$num_workers = 0
} else {
$num_workers = $workers
}
# Create the main balancer configuration
file { "${sites_available}/30_puppetmaster_balancer_8140.conf":
owner => $sys_user,
group => $sys_group,
mode => '0440',
content => template( "${module_name}/${sites_available}/30_puppetmaster_balancer.conf" ),
require => Package[$passenger_packages],
notify => Exec['puppet-passenger-apache2ctl-graceful'],
}
# Enable the balancer
puppet::master::passenger::a2ensite { "30_puppetmaster_balancer_8140.conf":
require => File["${puppet::sites_available}/30_puppetmaster_balancer_8140.conf"],
notify => Exec['puppet-passenger-apache2ctl-graceful'],
}
# Create the CA workers
puppet::master::passenger::worker { 'ca-worker':
workers => 2,
starting_port => 18138,
listen => $listen,
log_level => $log_level,
require => Package[$passenger_packages],
notify => Exec['puppet-passenger-apache2ctl-graceful'],
}
# Create the actual workers
puppet::master::passenger::worker { 'worker':
workers => $num_workers,
listen => $listen,
log_level => $log_level,
require => Package[$passenger_packages],
notify => Exec['puppet-passenger-apache2ctl-graceful'],
}
# Debian creates a default site named 'puppetmaster' that don't use
puppet::master::passenger::a2dissite { 'puppetmaster':
require => Package[$passenger_packages],
before => Exec['puppet-passenger-apache2ctl-graceful'],
}
# Make sure the required Apache modules are loaded
puppet::master::passenger::a2enmod { 'ssl':
require => Package[$passenger_packages],
before => Exec['puppet-passenger-apache2ctl-graceful'],
}
puppet::master::passenger::a2enmod { 'proxy':
require => Package[$passenger_packages],
before => Exec['puppet-passenger-apache2ctl-graceful'],
}
puppet::master::passenger::a2enmod { 'proxy_balancer':
require => Package[$passenger_packages],
before => Exec['puppet-passenger-apache2ctl-graceful'],
}
puppet::master::passenger::a2enmod { 'proxy_http':
require => Package[$passenger_packages],
before => Exec['puppet-passenger-apache2ctl-graceful'],
}
# This is really for Apache2 v2.4 or greater
# but I'm trying to keep this class autonomous.
if ( $::operatingsystem == 'ubuntu' ) {
puppet::master::passenger::a2enmod { 'lbmethod_byrequests':
require => Package[$passenger_packages],
before => Exec['puppet-passenger-apache2ctl-graceful'],
}
}
file { '/usr/share/puppet/rack':
ensure => 'directory',
owner => $puppet_user,
group => $apache2_group,
require => Package[$passenger_packages],
before => Exec['puppet-passenger-apache2ctl-graceful'],
mode => 0750,
}
file { '/usr/share/puppet/rack/puppetmasterd':
ensure => 'directory',
owner => $puppet_user,
group => $apache2_group,
require => Package[$passenger_packages],
before => Exec['puppet-passenger-apache2ctl-graceful'],
mode => 0750,
}
} else {
$master_start = true
}
# Packages useful for puppet development (e.g. writing manifests and such)
$dev_packages = $::operatingsystem ? {
'centos' => [ 'rubygem-puppet-lint', 'vim-puppet' ],
'debian' => [ 'puppet-lint', 'vim-puppet' ],
'fedora' => [ 'rubygem-puppet-lint' ],
'opensuse' => false,
'redhat' => [ 'rubygem-puppet-lint', 'vim-puppet' ],
'ubuntu' => [ 'puppet-lint', 'vim-puppet' ],
default => false,
}
# Ensure the development packages are installed and up to date.
if ( $dev_packages ) {
package { $dev_packages: ensure => 'latest' }
}
# Ensure that $settings::bucketdir is correct
file { "${settings::bucketdir}":
ensure => 'directory',
owner => $sys_user,
group => $puppet_group,
mode => '2750',
require => [
Package[$puppetmaster_packages],
File[$vardir],
],
}
# Keep $settings::bucketdir pruned to $age
if ( $tidy ) {
tidy { $settings::bucketdir:
age => $tidy_age,
backup => false,
recurse => true,
rmdirs => true,
type => 'ctime',
require => File[$settings::bucketdir],
}
}
# Ensure that $settings::module_working_dir is correct
file { "${settings::module_working_dir}":
ensure => 'directory',
owner => $sys_user,
group => $puppet_group,
mode => '2750',
require => [
Package[$puppetmaster_packages],
File[$vardir],
],
}
# Ensure that $settings::reportdir is correct
file { "${settings::reportdir}":
ensure => 'directory',
owner => $sys_user,
group => $puppet_group,
mode => '2750',
require => [
Package[$puppetmaster_packages],
File[$vardir],
],
}
# Keep $settings::reportdir pruned to $age
if ( $tidy ) {
tidy { $settings::reportdir:
age => $tidy_age,
backup => false,
recurse => true,
rmdirs => true,
type => 'ctime',
require => File[$settings::reportdir],
}
}
# Ensure that $settings::rrddir is correct
file { "${settings::rrddir}":
ensure => 'directory',
owner => $sys_user,
group => $puppet_group,
mode => '2750',
require => [
Package[$puppetmaster_packages],
File[$vardir],
],
}
# Ensure that $settings::server_datadir is correct
file { "${settings::server_datadir}":
ensure => 'directory',
owner => $sys_user,
group => $puppet_group,
mode => '2750',
require => [
Package[$puppetmaster_packages],
File[$vardir],
],
}
# Ensure that $settings::yamldir is correct
file { "${settings::yamldir}":
ensure => 'directory',
owner => $puppet_user,
group => $puppet_group,
mode => '0770',
require => [
Package[$puppetmaster_packages],
File[$vardir],
],
}
# Create the top-level directory for this site
file { "${vardir}/sites":
ensure => 'directory',
owner => $sys_user,
group => $puppet_group,
mode => '0660',
require => File[$vardir],
}
# Copy in the CA certificate if we have one
$cacert = file(
"${settings::vardir}/sites/default/${environment}/private/${::fqdn}/${settings::cacert}",
$settings::cacert,
'/dev/null'
)
if ( $cacert ) {
file { $settings::cacert:
mode => '0600',
owner => $puppet_user,
group => $puppet_group,
content => $cacert,
require => [
Package[$puppetmaster_packages],
File[$settings::ssldir],
],
}
}
# Copy in the CA key if we have one
$cakey = file(
"${settings::vardir}/sites/default/${environment}/private/${::fqdn}/${settings::cakey}",
$settings::cakey,
'/dev/null'
)
if ( $cakey ) {
file { $settings::cakey:
mode => '0600',
owner => $puppet_user,
group => $puppet_group,
content => $cakey,
require => [
Package[$puppetmaster_packages],
File[$settings::ssldir],
],
}
}
# Copy in the CA pass if we have one
$capass = file(
"${settings::vardir}/sites/default/${environment}/private/${::fqdn}/${settings::capass}",
$settings::capass,
'/dev/null'
)
if ( $capass ) {
file { $settings::capass:
mode => '0600',
owner => $puppet_user,
group => $puppet_group,
content => $capass,
require => [
Package[$puppetmaster_packages],
File[$settings::ssldir],
],
}
}
# Copy in the puppetmaster defaults file
if ( $puppetmaster_defaults ) {
file { $puppetmaster_defaults:
owner => $puppet::sys_user,
group => $puppet::sys_group,
mode => '0640',
content => template( "${module_name}${puppetmaster_defaults}" ),
}
}
# Create the site's directory structures
if ( $use_sites ) {
if ( $use_sites['default'] ) {
fail( "ERROR: 'default' can not be defined in the 'sites' parameter" )
} else {
if ( $site_privacy_warning ) {
notify { 'sites-warning':
message => "\nWARNING:\nWARNING: Puppet's ability to run arbitrary ruby code means there is no way to\nWARNING: ensure privacy between sites. The 'sites' feature may be removed in\nWARNING: the future. See the 'CAVEAT' in the README file for more details.\nWARNING: This message can be suppressed by setting 'site_privacy_warning' to\nWARNING: false in the class declaration\nWARNING:\n",
loglevel => 'warning',
}
}
}
create_resources( puppet::master::site, $use_sites )
}
puppet::master::site { 'default':
clients => $clients,
developers => $developers,
}
# Make sure the service is running if it's supposed to be
if ( $master_start ) {
service { $puppetmaster_service:
ensure => 'running',
enable => true,
subscribe => [
Package[$puppetmaster_packages],
File["${confdir}/auth.conf"],
File["${confdir}/fileserver.conf"],
File["${confdir}/puppet.conf"],
File[$puppetmaster_defaults],
],
}
} else {
service { $puppetmaster_service:
ensure => 'stopped',
enable => false,
hasstatus => true,
status => $puppetmaster_status,
require => [
Package[$puppetmaster_packages],
File[$settings::bucketdir],
File[$settings::cacert],
File[$settings::cakey],
File[$settings::capass],
File[$settings::clientbucketdir],
File[$settings::client_datadir],
File[$settings::clientyamldir],
File[$settings::libdir],
File[$settings::module_working_dir],
File[$settings::reportdir],
File[$settings::rrddir],
File[$settings::server_datadir],
File[$settings::ssldir],
File[$settings::statedir],
File[$settings::yamldir],
File[$vardir],
File["${vardir}/facts"],
File["${vardir}/sites"],
],
}
# On fedora, it was noticed that Apache was not started by default
# which causes the graceful reload to fail. This is a kludge to
# ensure that Apache is running so the graceful command, along with
# the rest of this class will succeed.
exec { 'puppet-passenger-apache2ctl-start':
path => [ '/bin', '/usr/bin', '/sbin', '/usr/sbin' ],
command => "${apache2ctl} start",
unless => "${apache2ctl} status",
before => Exec['puppet-passenger-apache2ctl-graceful'],
require => [
Service[$puppetmaster_service],
File["${confdir}/auth.conf"],
File["${confdir}/fileserver.conf"],
File["${confdir}/puppet.conf"],
],
}
# Exec to reload Apache if the puppet configuration changes
exec { 'puppet-passenger-apache2ctl-graceful':
path => [ '/bin', '/usr/bin', '/sbin', '/usr/sbin' ],
command => "${apache2ctl} graceful",
refreshonly => true,
require => [
Service[$puppetmaster_service],
],
subscribe => [
File["${confdir}/auth.conf"],
File["${confdir}/fileserver.conf"],
File["${confdir}/puppet.conf"],
],
}
}
}
# Install any modules that were requested. The extensive
# require list is just to ensure that $modulepath exists
# prior to actually trying to install the modules.
if ( $modules ) {
puppet::module { $modules:
require => [
Package[$puppetmaster_packages],
File[$settings::bucketdir],
File[$settings::cacert],
File[$settings::cakey],
File[$settings::capass],
File[$settings::clientbucketdir],
File[$settings::client_datadir],
File[$settings::clientyamldir],
File[$settings::libdir],
File[$settings::module_working_dir],
File[$settings::reportdir],
File[$settings::rrddir],
File[$settings::server_datadir],
File[$settings::ssldir],
File[$settings::statedir],
File[$settings::yamldir],
File[$vardir],
File["${vardir}/facts"],
File["${vardir}/sites"],
],
}
}
}
|