This repository was archived by the owner on Mar 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Puppetserver support (third try) #200
Open
danieldreier
wants to merge
5
commits into
puppetlabs-operations:master
Choose a base branch
from
danieldreier:puppetserver_round3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9da1994
Add basic rspec-puppet tests for puppetserver
9a648fe
Add beaker tests for puppetserver functionality
b02a285
add puppetserver-specific items to params.pp
b37e827
Add basic puppetserver support
3ba358c
Set puppetserver_maxpermsize conditionally
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,180 @@ | ||
| # puppet::server::puppetserver configures the master using the new JVM puppet server | ||
| # Puppet Server is pre-release and not recommended for production use yet | ||
| # See https://github.com/puppetlabs/puppet-server/blob/master/documentation/install_from_packages.markdown for basic | ||
| # manual install documentation | ||
|
|
||
| # This class should not normally be used directly. | ||
|
|
||
| # TODO: Add support for external SSL termination | ||
| # https://github.com/puppetlabs/puppet-server/blob/master/documentation/external_ssl_termination.markdown | ||
|
|
||
| # TODO: Add ability to configure stuff from: | ||
| # https://github.com/puppetlabs/puppet-server/blob/master/documentation/configuration.markdown | ||
| # - where JRuby will look for gems | ||
| # - path to puppet conf dir | ||
| # - path to puppet var dir | ||
| # - maximum number of JRuby instances to allow; defaults to <num-cpus>+2 | ||
| # - enable/disable the CA service via trapperkeeper settings | ||
| # - configure logging via logback | ||
|
|
||
| # Note that OpenBSD support is blocking on https://tickets.puppetlabs.com/browse/SERVER-14 | ||
|
|
||
| # parameters | ||
| # descriptions largely copied from official docs at | ||
| # https://github.com/puppetlabs/puppet-server/blob/master/documentation/configuration.markdown | ||
| # [*memory*] - (optional) set JVM memory use; 2gb recommended by default | ||
| # format is "2gb", "512m", etc. | ||
| # [*max_active_instances*] - (optional) maximum number of JRuby instances to allow | ||
| # [*logging_config*] - (optional) Path to logback logging configuration file | ||
| # http://logback.qos.ch/manual/configuration.html | ||
| # [*gem_home*] - (optional) determines where JRuby will look for gems. Also | ||
| # used by the `puppetserver gem` command line tool. | ||
| # [*master_conf_dir*] - (optional) path to puppet conf dir | ||
| # [*master_var_dir*] - (optional) path to puppet var dir | ||
| # [*enable_profiler*] - (optional) enable or disable profiling for the Ruby code | ||
| # (true|false) | ||
| # [*allow_header_cert_info - (optional) Allows the "ssl_client_header" and | ||
| # (true|false) "ssl_client_verify_header" options set in | ||
| # puppet.conf to work. These headers will be | ||
| # ignored unless "allow-header-cert-info" is true | ||
|
|
||
| # puppetserver.conf is in HOCON format, which is a superset of JSON: | ||
| # - https://github.com/puppetlabs/puppet-server/blob/master/documentation/configuration.markdown | ||
| # - https://github.com/typesafehub/config#using-hocon-the-json-superset | ||
| # puppet-puppet will use https://github.com/puppetlabs/puppetlabs-hocon to | ||
| # manage hocon settings because that appears to be the approach the puppetserver | ||
| # developers have chosen to support | ||
|
|
||
| class puppet::server::puppetserver ( | ||
| # aside from memory (defaults to 2g), these are the puppetserver defaults | ||
| # Setting them here makes it easier to anticipate behavior | ||
| $enabled = true, | ||
| $memory_pct = 70, | ||
| $memory = undef, | ||
| $max_active_instances = $::processorcount + 2, | ||
| $logging_config = $puppet::params::puppetserver_logback_conf, | ||
| $gem_home = $puppet::params::puppetserver_gem_home, | ||
| $master_conf_dir = $puppet::params::puppet_confdir, | ||
| $master_var_dir = $puppet::params::puppet_vardir, | ||
| $enable_profiler = false, | ||
| $allow_header_cert_info = false, | ||
| $bootstrap_cfg = $puppet::params::puppetserver_bootstrap_conf, | ||
| ) { | ||
|
|
||
| include puppet | ||
| include puppet::server | ||
|
|
||
| # Calculate JVM memory based on percentage if specified | ||
| # Should JVM settings be their own class? | ||
| if ($memory_pct != undef) and ($memory != undef) { | ||
| fail('memory and memory_pct cannot both be set at the same time') | ||
| } | ||
| if ($memory_pct != undef) and ($memory == undef) { | ||
| $rounded_mem = floor($::memorysize_mb * $memory_pct * 0.01) | ||
| $jvm_memory = "${rounded_mem}m" | ||
| } | ||
| if ($memory_pct == undef) and ($memory != undef) { | ||
| $jvm_memory = $memory | ||
| } | ||
|
|
||
| $service_ensure = $enabled? { | ||
| true => 'running', | ||
| default => 'stopped', | ||
| } | ||
|
|
||
| Ini_subsetting { | ||
| ensure => present, | ||
| section => '', | ||
| key_val_separator => '=', | ||
| quote_char => '"', | ||
| path => $puppet::params::server_service_conf, | ||
| setting => 'JAVA_ARGS', | ||
| notify => Service[$puppet::params::server_service], | ||
| } | ||
|
|
||
| ini_subsetting {'puppetserver_xmx_memory': | ||
| subsetting => '-Xmx', | ||
| value => $jvm_memory, | ||
| } | ||
| ini_subsetting {'puppetserver_xms_memory': | ||
| subsetting => '-Xms', | ||
| value => $jvm_memory, | ||
| } | ||
| ini_subsetting {'puppetserver_maxpermsize': | ||
| subsetting => '-XX:MaxPermSize=', | ||
| value => '256m', | ||
| } | ||
| # JAVA_ARGS="-Xms2776m -Xmx2776m -XX:MaxPermSize=256m" | ||
| Ini_setting { | ||
| ensure => present, | ||
| path => $puppet::params::server_service_conf, | ||
| key_val_separator => '=', | ||
| section => '', | ||
| } | ||
| ini_setting { "JAVA_BIN": | ||
| setting => 'JAVA_BIN', | ||
| value => "\"${puppet::params::puppetserver_java}\"", | ||
| } | ||
| ini_setting { "USER": | ||
| setting => 'USER', | ||
| value => "\"${puppet::params::puppet_user}\"", | ||
| } | ||
| ini_setting { "INSTALL_DIR": | ||
| setting => 'INSTALL_DIR', | ||
| value => "\"${puppet::params::puppetserver_install_dir}\"", | ||
| } | ||
| ini_setting { "CONFIG": | ||
| setting => 'CONFIG', | ||
| value => "\"${puppet::params::puppetserver_config_dir}\"", | ||
| } | ||
| ini_setting { "BOOTSTRAP_CONFIG": | ||
| setting => 'BOOTSTRAP_CONFIG', | ||
| value => "\"${puppet::params::puppetserver_bootstrap_conf}\"", | ||
| } | ||
| ini_setting { "SERVICE_STOP_RETRIES": | ||
| setting => 'SERVICE_STOP_RETRIES', | ||
| value => '60', | ||
| } | ||
|
|
||
| # disable the trapperkeeper-based CA service entirely if this isn't a CA node | ||
| $ca_disable_ensure = $puppet::params::ca? { | ||
| false => 'present', | ||
| default => 'absent', | ||
| } | ||
| $ca_enable_ensure = $puppet::params::ca? { | ||
| false => 'absent', | ||
| default => 'present', | ||
| } | ||
| file_line { 'disable_puppetserver_ca': | ||
| ensure => $ca_disable_ensure, | ||
| path => $puppet::params::puppetserver_bootstrap_conf, | ||
| line => 'puppetlabs.services.ca.certificate-authority-disabled-service/certificate-authority-disabled-service', | ||
| require => Package[$puppet::params::server_package], | ||
| } | ||
| file_line { 'enable_puppetserver_ca': | ||
| ensure => $ca_enable_ensure, | ||
| path => $puppet::params::puppetserver_bootstrap_conf, | ||
| line => 'puppetlabs.services.ca.certificate-authority-service/certificate-authority-service', | ||
| require => Package[$puppet::params::server_package], | ||
| } | ||
|
|
||
| service { $puppet::params::server_service: | ||
| ensure => $service_ensure, | ||
| enable => $enabled, | ||
| hasstatus => false, | ||
| pattern => 'puppet-server-release.jar', # yeah, this is embarassing | ||
| require => [Class['puppet::server::config'], | ||
| Class['puppet::server::standalone'], | ||
| Package[$puppet::params::server_package]], | ||
| } | ||
|
|
||
| # stop regular puppet master to avoid conflicting binds on port 8140 | ||
| if $enabled == true { | ||
| package { $puppet::params::server_package: | ||
| ensure => $puppet::server::ensure; | ||
| } | ||
| class { 'puppet::server::standalone': | ||
| enabled => false | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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,22 @@ | ||
| require 'spec_helper_acceptance' | ||
|
|
||
| describe 'server', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do | ||
| context 'running on puppetserver', :servertype => 'puppetserver', :webserver => 'puppetserver' do | ||
| it 'should run with no errors' do | ||
| pp = <<-EOS | ||
| class { 'puppet::server': | ||
| servertype => 'puppetserver', | ||
| ca => true, | ||
| } | ||
| EOS | ||
|
|
||
| # Run it twice and test for idempotency | ||
| apply_manifest(pp, :catch_failures => true) | ||
| expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero | ||
| end | ||
|
|
||
| it_behaves_like "basic working puppetmaster" | ||
| it_behaves_like "puppetserver-based master" | ||
|
|
||
| end | ||
| end |
This file contains hidden or 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 hidden or 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 hidden or 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,4 @@ | ||
| class { 'puppet::server': | ||
| servertype => 'puppetserver', | ||
| ca => true, | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will not work in java8
well, it'll work, but it'll be ignored with a warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty ignorant of java version differences; what would we need to do for java 8? I'm simply re-implementing the stock puppetserver configuration here. I'd be glad to switch based on java version, or to parameterize it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the equivalent in java 8 is:
-XX:MaxMetaspaceSize=256mThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can use
$::java_major_versionto distinguish this.i hope this also works if someone's not using puppetlabs-java, while using puppet 4 ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion - added it.
Actually - our travis-ci tests do a required test iteration with future parser enabled. Puppet 3.7.3 future parser and puppet 4 syntax should be virtually identical. The agent install will be a bit different - facter, puppet, etc all bundled together in one package and paths will be different. The recent abstraction work we've done on this module should help, too.
I'm also not sure I want to add a dependency on puppetlabs-java. I've wrapped the whole thing in a conditional; if we end up needing to manage java further we can circle back.