Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

allow passing extra_params to puppet agent #10

Closed
wants to merge 1 commit into from

4 participants

@frimik

Pass an array of configuration lines to add to the [agent] section of
puppet.conf:

$agent_params = ["splay = true"]

class {'::puppet':
agent_params => $agent_params,
}

@GregSutcliffe
Collaborator

I like this - we need to use it to remove some of the explicit params that people probably don't use much, and maybe implement it in other places too

@GregSutcliffe
Collaborator

So we had some debate on this on the mailing list. Looks like we were coming to the idea of a separate file, to keep the config in one place, but not puppet.conf, as foreman will treat it as an environment. Does that sound right? and if so, do you have time to update the PR?

@frimik
@skottler
Collaborator

Any update @frimik?

@frimik

just as a note to any readers; I think this comment thread is re: 2 pullreqs. One for the little improvement to allow extra_params in the puppet module and then the other one about extracting all the settings from the various foreman functions and report files into /etc/puppet/foreman.yml. I updated my parameters_and_yaml branch recently and will rebase this one too I guess.

@frimik frimik allow passing extra_params to puppet agent
Pass an array of configuration lines to add to the [agent] section of
puppet.conf:

$agent_params = ["splay = true"]

class {'::puppet':
  agent_params => $agent_params,
}
89bd0a1
@frimik

I rebased this particular pullreq (agent_params). This one is in case you think this method is acceptable/usable to get "custom" settings onto an agent without supplying an entire custom template. One could also do it by supplying a hash with $agent_config = { section => ["param = value", "param2 = bar"] }. Not sure that's motivated, when going that complex it would perhaps be acceptable to use a template instead.

@GregSutcliffe
Collaborator

I like this - I'll test it tomorrow. I think this would let us strip some of the less-used params from the module.

@GregSutcliffe GregSutcliffe commented on the diff
manifests/server.pp
@@ -21,7 +21,8 @@
$post_hook_content = $puppet::params::post_hook_content,
$post_hook_name = $puppet::params::post_hook_name,
$agent_template = $puppet::params::agent_template,
- $master_template = $puppet::params::master_template
+ $master_template = $puppet::params::master_template,
+ $agent_params = undef
@GregSutcliffe Collaborator

Why call it "agent_params" and only put it in server.pp? Do you not want it in init.pp too? If you don't, your example in the commit log doesn't work...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@GregSutcliffe GregSutcliffe commented on the diff
templates/puppet.conf.erb
@@ -29,3 +29,8 @@
environment = <%= environment %>
certname = <%= clientcert %>
server = <%= puppetmaster rescue fqdn %>
+<% if has_variable?("agent_params") and agent_params != :undef -%>
@GregSutcliffe Collaborator

This doesn't work - the variable is $puppet::agent_params (or $puppet::server::agent_params). You need to do something like:

$params = $puppet::agent_params

in config.pp and then use the local $params variable in the template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@vStone

I would be in favour of supporting a hash for key-pair values, but I would not go as far as supporting sections since this would probably indeed confuse either puppet or foreman.

@vStone
<%
    # Sanitize the variable. See if there is anything defined.
    if has_variable?('puppet::agent_params') and ! [:undef, ''].include?(scope.lookupvar('puppet::agent_params'))
      agent_params = scope.lookupvar('puppet::agent_params')
    else
      agent_params = []
    end
%>
<%  if agent_params.is_a?(String) -%>
   <%= agent_params %>
<%  elsif agent_params.is_a?(Array)
      agent_params.each do |param| -%>
    <%= param %>
<%    end -%>
<%  elsif agent_params.is_a?(Hash)
      agent_params.each do |key, value| -%>
    <%= key %> = <%= value %>
<%    end -%>
<%  end -%>

Untested and the <% %> blocks should probably be reviewed.

The major disadvantage of having a lot of options is always a more complex template :/

@frimik
@GregSutcliffe
Collaborator

Closing this for now, @frimik let us know if you update it ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 5, 2012
  1. @frimik

    allow passing extra_params to puppet agent

    frimik authored
    Pass an array of configuration lines to add to the [agent] section of
    puppet.conf:
    
    $agent_params = ["splay = true"]
    
    class {'::puppet':
      agent_params => $agent_params,
    }
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 1 deletion.
  1. +2 −1  manifests/server.pp
  2. +5 −0 templates/puppet.conf.erb
View
3  manifests/server.pp
@@ -21,7 +21,8 @@
$post_hook_content = $puppet::params::post_hook_content,
$post_hook_name = $puppet::params::post_hook_name,
$agent_template = $puppet::params::agent_template,
- $master_template = $puppet::params::master_template
+ $master_template = $puppet::params::master_template,
+ $agent_params = undef
@GregSutcliffe Collaborator

Why call it "agent_params" and only put it in server.pp? Do you not want it in init.pp too? If you don't, your example in the commit log doesn't work...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
) inherits puppet::params {
class { 'puppet::server::install': }~>
class { 'puppet::server::config': }
View
5 templates/puppet.conf.erb
@@ -29,3 +29,8 @@
environment = <%= environment %>
certname = <%= clientcert %>
server = <%= puppetmaster rescue fqdn %>
+<% if has_variable?("agent_params") and agent_params != :undef -%>
@GregSutcliffe Collaborator

This doesn't work - the variable is $puppet::agent_params (or $puppet::server::agent_params). You need to do something like:

$params = $puppet::agent_params

in config.pp and then use the local $params variable in the template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ <% agent_params.each do |param| -%>
+ <%= param %>
+ <% end -%>
+<% end -%>
Something went wrong with that request. Please try again.