forked from ocf/puppet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate from puppetmaster to puppetserver
- Loading branch information
Showing
12 changed files
with
199 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
modulepath = modules:vendor:$basemodulepath | ||
parser = future |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ classes: | |
- ocf::utils | ||
|
||
staff_only: true | ||
|
||
puppet_agent: false | ||
|
||
# Mesos/Marathon configuration | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
classes: | ||
- ocf_puppet | ||
|
||
puppet_agent: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,91 @@ | ||
class ocf::puppet($stage = 'first') { | ||
package { ['facter', 'puppet']: } | ||
|
||
# configure puppet agent | ||
# set environment to match server and disable cached catalog on failure | ||
augeas { '/etc/puppet/puppet.conf': | ||
context => '/files/etc/puppet/puppet.conf', | ||
changes => [ | ||
# These changes can change the puppetmaster config, which is | ||
# defined separately in the ocf_puppet module, causing the | ||
# puppet agent on the puppetmaster to restart twice. Make sure | ||
# the changes made here are also made in that module. | ||
"set agent/environment ${::environment}", | ||
'set agent/usecacheonfailure false', | ||
'set main/pluginsync true', | ||
'set main/stringify_facts false', | ||
'set main/rundir /run/puppet', | ||
|
||
# future parser breaks too many 3rd-party modules | ||
'rm main/parser', | ||
|
||
# templatedir is deprecated in 3.8+ and we don't use it | ||
'rm main/templatedir', | ||
], | ||
require => Package['augeas-tools', 'libaugeas-ruby', 'puppet'], | ||
notify => Service['puppet'], | ||
} | ||
if hiera('puppet_agent') { | ||
package { 'puppet-agent':; } | ||
|
||
augeas { '/etc/puppetlabs/puppet/puppet.conf': | ||
context => '/files/etc/puppetlabs/puppet/puppet.conf', | ||
changes => [ | ||
# These changes can change the puppetmaster config, which is | ||
# defined separately in the ocf_puppet module, causing the | ||
# puppet agent on the puppetmaster to restart twice. Make sure | ||
# the changes made here are also made in that module. | ||
"set agent/environment ${::environment}", | ||
'set agent/usecacheonfailure false', | ||
|
||
# TODO: Remove this after the puppetmaster upgrade is complete | ||
'set main/server dev-puppet', | ||
|
||
# Remove a bunch of old settings that are no longer needed | ||
'rm main/logdir', | ||
'rm main/vardir', | ||
'rm main/ssldir', | ||
'rm main/rundir', | ||
'rm main/templatedir', | ||
'rm main/factpath', | ||
'rm main/pluginsync', | ||
'rm main/stringify_facts', | ||
'rm main/prerun_command', | ||
'rm main/postrun_command', | ||
'rm agent/certname', | ||
'rm master/ssl_client_header', | ||
'rm master/ssl_client_verify_header', | ||
], | ||
require => Package['puppet-agent'], | ||
} | ||
} else { | ||
package { ['facter', 'puppet']: } | ||
|
||
service { 'puppet': | ||
require => Package['puppet'], | ||
# configure puppet agent | ||
# set environment to match server and disable cached catalog on failure | ||
augeas { '/etc/puppet/puppet.conf': | ||
context => '/files/etc/puppet/puppet.conf', | ||
changes => [ | ||
# These changes can change the puppetmaster config, which is | ||
# defined separately in the ocf_puppet module, causing the | ||
# puppet agent on the puppetmaster to restart twice. Make sure | ||
# the changes made here are also made in that module. | ||
"set agent/environment ${::environment}", | ||
'set agent/usecacheonfailure false', | ||
'set main/pluginsync true', | ||
'set main/stringify_facts false', | ||
'set main/rundir /run/puppet', | ||
|
||
# future parser breaks too many 3rd-party modules | ||
'rm main/parser', | ||
|
||
# templatedir is deprecated in 3.8+ and we don't use it | ||
'rm main/templatedir', | ||
], | ||
require => Package['augeas-tools', 'libaugeas-ruby', 'puppet'], | ||
notify => Service['puppet'], | ||
} | ||
|
||
service { 'puppet': | ||
require => Package['puppet'], | ||
} | ||
} | ||
|
||
# create share directories | ||
file { | ||
'/opt/share': | ||
ensure => directory, | ||
; | ||
ensure => directory; | ||
|
||
'/opt/share/puppet': | ||
ensure => directory, | ||
recurse => true, | ||
purge => true, | ||
force => true, | ||
backup => false, | ||
; | ||
backup => false; | ||
} | ||
|
||
# install augeas | ||
package { [ 'augeas-tools', 'libaugeas-ruby', ]: } | ||
package { [ 'augeas-tools', 'libaugeas-ruby']:; } | ||
|
||
# install custom scripts | ||
file { | ||
# trigger a puppet run by the agent | ||
'/usr/local/sbin/puppet-trigger': | ||
mode => '0755', | ||
source => 'puppet:///modules/ocf/puppet-trigger', | ||
require => Package['puppet'], | ||
; | ||
source => 'puppet:///modules/ocf/puppet-trigger'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env python3 | ||
"""LDAP External Node Classifier for Puppet | ||
Since Puppet Server uses JRuby, we can't use the same ruby-ldap package that | ||
we have used with Puppet's LDAP node classifier in the past and instead must | ||
either patch jruby-ldap to work with Puppet (fragile for the future and tough | ||
if anything moves locations), or create an ENC for Puppet that will classify | ||
nodes like the built-in LDAP classifier. | ||
This is that classifier! It takes in node FQDNs, and looks them up in LDAP | ||
to get variables and classes to give to Puppet. | ||
""" | ||
|
||
import argparse | ||
import sys | ||
import yaml | ||
|
||
from ocflib.infra.hosts import hosts_by_filter | ||
from ocflib.infra.hosts import hostname_from_domain | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description=__doc__, | ||
formatter_class=argparse.RawDescriptionHelpFormatter | ||
) | ||
parser.add_argument('hostname', help='Hostname of LDAP node to classify.') | ||
args = parser.parse_args() | ||
|
||
hostname = hostname_from_domain(args.hostname) | ||
search = hosts_by_filter('(&(objectclass=puppetClient)(cn={}))'.format(hostname)) | ||
|
||
if len(search) == 1: | ||
host = search[0] | ||
else: | ||
# Could not find a unique node to classify, exit | ||
sys.exit(1) | ||
|
||
output = {'parameters': {}} | ||
|
||
for key, values in host.items(): | ||
# The environment is a special parameter that needs some conversion to | ||
# work correctly. | ||
if key == 'environment': | ||
output['environment'] = values[0] | ||
|
||
# Remove the value from its list only if it is a singular value | ||
if len(values) == 1: | ||
output['parameters'][key] = values[0] | ||
else: | ||
output['parameters'][key] = values | ||
|
||
print(yaml.dump(output, default_flow_style=False)) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[transport] | ||
reportfrom = puppet | ||
sendmail = /usr/sbin/sendmail | ||
|
||
[tagmap] | ||
warning, err, alert, emerg, crit: puppet | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,67 @@ | ||
class ocf_puppet::puppetmaster { | ||
package { | ||
['puppetmaster-passenger', 'puppet-lint']:; | ||
['puppetserver', 'puppet-lint']:; | ||
} | ||
|
||
class { '::apache': | ||
default_vhost => false; | ||
service { 'puppetserver': | ||
require => Package['puppetserver'], | ||
} | ||
|
||
apache::vhost { 'puppetmaster': | ||
docroot => '/usr/share/puppet/rack/puppetmasterd/public/', | ||
port => 8140, | ||
|
||
ssl => true, | ||
ssl_key => '/var/lib/puppet/ssl/private_keys/puppet.pem', | ||
ssl_cert => '/var/lib/puppet/ssl/certs/puppet.pem', | ||
ssl_chain => '/var/lib/puppet/ssl/certs/ca.pem', | ||
ssl_ca => '/var/lib/puppet/ssl/certs/ca.pem', | ||
ssl_crl => '/var/lib/puppet/ssl/ca/ca_crl.pem', | ||
ssl_verify_client => 'optional', | ||
ssl_verify_depth => 1, | ||
ssl_options => ['+StdEnvVars', '+ExportCertData'], | ||
|
||
rack_base_uris => ['/']; | ||
# Set correct memory limits on puppetserver so that it doesn't run out | ||
augeas { '/etc/default/puppetserver': | ||
context => '/files/etc/default/puppetserver', | ||
changes => [ | ||
"set JAVA_ARGS '\"-Xms512m -Xmx512m -XX:MaxPermSize=256m\"'", | ||
], | ||
require => Package['puppetserver'], | ||
notify => Service['puppetserver'], | ||
} | ||
|
||
$docker_private_hosts = union(keys(hiera('mesos_masters')), hiera('mesos_slaves')) | ||
|
||
file { | ||
'/etc/puppet/fileserver.conf': | ||
content => template('ocf_puppet/fileserver.conf.erb'); | ||
'/etc/puppetlabs/puppet/fileserver.conf': | ||
content => template('ocf_puppet/fileserver.conf.erb'), | ||
require => Package['puppetserver']; | ||
|
||
'/etc/puppet/puppet.conf': | ||
content => template('ocf_puppet/puppet.conf.erb'); | ||
'/etc/puppetlabs/puppet/tagmail.conf': | ||
source => 'puppet:///modules/ocf_puppet/tagmail.conf', | ||
require => Package['puppetserver']; | ||
|
||
'/etc/puppet/tagmail.conf': | ||
content => "warning, err, alert, emerg, crit: puppet\n"; | ||
'/opt/share/puppet/ldap-enc': | ||
mode => '0755', | ||
source => 'puppet:///modules/ocf_puppet/ldap-enc', | ||
require => File['/opt/share/puppet']; | ||
|
||
['/opt/puppet', '/opt/puppet/env', '/opt/puppet/scripts', '/opt/puppet/shares', '/opt/puppet/shares/contrib']: | ||
ensure => directory; | ||
'/etc/puppetlabs/puppet/puppet.conf': | ||
content => template('ocf_puppet/puppet.conf.erb'), | ||
require => Package['puppet-agent']; | ||
|
||
'/opt/puppet/shares/private': | ||
['/opt/puppetlabs/scripts', '/opt/puppetlabs/shares', '/opt/puppetlabs/shares/contrib']: | ||
ensure => directory, | ||
require => Package['puppetserver']; | ||
|
||
'/opt/puppetlabs/shares/private': | ||
mode => '0400', | ||
owner => puppet, | ||
group => puppet, | ||
recurse => true; | ||
recurse => true, | ||
require => File['/opt/puppetlabs/shares']; | ||
|
||
'/opt/puppet/scripts/update-prod': | ||
'/opt/puppetlabs/scripts/update-prod': | ||
source => 'puppet:///modules/ocf_puppet/update-prod', | ||
mode => '0755'; | ||
|
||
# TODO: Remove old puppet directories after the upgrade is fully done | ||
# (for now they are just links to the new locations) | ||
'/opt/puppet/env': | ||
ensure => symlink, | ||
target => '/etc/puppetlabs/code/environments', | ||
require => Package['puppetserver']; | ||
|
||
'/opt/puppet/shares': | ||
ensure => symlink, | ||
target => '/opt/puppetlabs/shares', | ||
require => Package['puppetserver']; | ||
} | ||
} |
Oops, something went wrong.