Ask Your Question

How to use parameters / array

asked 2015-08-14 03:42:43 -0600

pgh2011 gravatar image

updated 2015-08-14 20:09:37 -0600

GregLarkin gravatar image


I new to puppet and I have a question.

What I have is:

  - yaml
  :datadir: /etc/puppet/hieradata

  - "nodes/%{::fqdn}"
  - "usergroups/%{usergroups}"

  - colorprompt
  - ntp
  - motd
  - ssh
  - sudodba
  - sudoroot

colorprompt::server_color: 'blue'
    - 'root'
    - 'admiam'
    - 'oracle'

This works:

hiera -c /etc/puppet/hiera.yaml -d ssh::keys usergroups=oracle
hiera -c /etc/puppet/hiera.yaml -d ssh::keys usergroups=root


But it won't put all the usergroups on this server. The last parameter overwrites the first two.

edit retag flag offensive close merge delete


You'll need to a post a link to your code somewhere so someone here can tell what the problem is.

GregLarkin gravatar imageGregLarkin ( 2015-08-14 22:01:41 -0600 )edit

I'm not really sure what you're trying to do. What do you mean with "this works", what's the output of those commands?

Woefdram gravatar imageWoefdram ( 2015-08-15 13:27:34 -0600 )edit

What I am trying to do is: From hieradata/usergroups (there are ssh keys) select the group (files) root, admiam and oracle users. the output of: hiera -c /etc/puppet/hiera.yaml -d ssh::keys usergroups=oracle "oracle"=> {"ensure"=>"present", "user"=>"oracle", "type"=>"rsa", "kdddd" etc

pgh2011 gravatar imagepgh2011 ( 2015-08-21 07:48:12 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-08-17 15:34:50 -0600

cbarbour gravatar image

You cannot do what you're trying to do. Only strings may be used as interpolation tokens for dynamic data sources.

Instead, I recommend one of these approaches:

Option 1:

Declare all of your usergroups as virtual resources and realize them using the group name.

Option 2:

Declare your usergroups as a big array and use the puppetlabs-stdlib intersection function to select only the elements of the hash that exist in the node's 'usergroups' array.

edit flag offensive delete link more


??? "I'm new to puppet and I have a question." :-)

pgh2011 gravatar imagepgh2011 ( 2015-08-25 10:12:12 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-08-14 03:42:43 -0600

Seen: 798 times

Last updated: Aug 17 '15