Hey there,
I am writing a small init puppet config to configure my servers without puppet master.
For creating user accounts I want iterate via an each loop over a array of user names
defined in a hiera file.
Without running the future parser my example each loop is not working and if i use it
my data in the yaml file cant be read.
I installed the the puppet-common pkt (vers: 3.8.7-1puppetlabs1) on Ubuntu 12.04. Should each not run
in this version without future parser?
The class iterating over the users:
#modules/manage_users/manifests/init.pp
class manage_users($users,){
group { 'test':
ensure => 'present'
}
['a','b','c'].each |Integer $index, String $value| { notice("${index} = ${value}") }
#each($users) |$user| {
#notify{"user: ${user}",}
# group {"${user}":
# ensure => 'present'
# }
# user { "${user}" :
# ensure => 'present',
# groups => [$user, test],
# home => "/home/${user}",
# shell => '/bin/bash',
# }
}
My hiera.yaml:
:backends:
- yaml
:yaml:
:datadir: /etc/puppet/hieradata
:hierarchy:
- lpkb
The yaml with the data:
#hieradata/lpkb.yaml
manage-users::users:
- user1
- user2
manage-users::test: test
puppet.conf:
[main]
logdir=/var/log/puppet
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
If I run without future parser:
puppet apply manifests/site.pp
Error:
Error: Syntax error at '['; expected ']' at /etc/puppet/modules/manage_users/manifests/init.pp:7 on node vps1234.localhost.local
Error: Syntax error at '['; expected ']' at /etc/puppet/modules/manage_users/manifests/init.pp:7 on node vps1234.localhost.local
With future parser:
puppet apply --parser=future manifests/site.pp
Error: Evaluation Error: Error while evaluating a Function Call, Must pass users to Class[Manage_users] at /etc/puppet/manifests/site.pp:3:5 on node vps1234.localhost.local
Error: Evaluation Error: Error while evaluating a Function Call, Must pass users to Class[Manage_users] at /etc/puppet/manifests/site.pp:3:5 on node vps1234.localhost.local
What am I doing wrong?
↧