How to merge puppet array variables
Given the following puppet manifest, how can I merge / concatenate the two arrays such that the command will execute with both a=b and b=c ?
Cron{
environment => ["a=b"]
}class a{
cron{'test':
command => "/usr/bin/true",
user => "francois",
environment => ["b=c"],
}
}include a
My crontab entry ends up like this:
# Puppet Name: test
b=c
* * * * * /usr/bin/true
As I recall you can’t do it directly. Something like this might work though:
$default_env = ["a=b"]Cron {
environment => $default_env
}class a {
$additional_env = split(inline_template("<%= (default_env).join(',') %>"),',') cron {"test":
command => "true",
user => "me",
environment => $additional_env
}
}include a
(the split/inline_template is based off of something from http://www.crobak.org/2011/02/two-puppet-tricks-combining-arrays-and-local-tests/ )
Check more discussion of this question.
Related posts:
- puppet variables
- Puppet: Checking sets of variables
- Accessing puppet configuration variables from manifests?
- How do you configure puppet to add a user to the sudoers group when it varies on different systems (or, how do variables work?)
- Differences between local ‘puppet apply’ and ‘puppet agent’ to a puppetmaster
Leave a comment
Recent Posts
- Is there a way for administrators to disable users from installing Firefox extensions?
- Is there research material on NTP accuracy available?
- How to create a limited “domain admin” that does not have access to domain controllers?
- Can Windows RDC admin users be immune from being kicked?
- Domain Administrators account policy (After PCI audit)
Tags
active-directory
amazon-ec2
apache
apache2
backup
bash
centos
cisco
command-line
debian
dns
email
exchange
firewall
iis
iis7
iptables
linux
macosx
monitoring
mysql
networking
nginx
performance
permissions
php
postfix
raid
security
sql-server
sql-server-2005
sql-server-2008
ssh
ssl
ubuntu
unix
virtualization
vpn
webserver
windows
windows-7
windows-server-2003
windows-server-2008
windows-server-2008-r2
windows-xp





