Hi all,
I recently came across the thread titled "A simple function to load
external class attributes". The idea sounds good.
I'm bumping into a similar but I think different problem.
I need to install (via custom scripts) a software package using various
parameters such as install location, software version, and environment.
The initial setup required the following tasks to be executed.
1. Create local directory to download install script.
2. Download install script from puppet master.
3. Run install script providing various parameters unless software is installed.
This worked fine.
It's now necessary to multiple instances of this software package at
once using different parameters.
My initial idea was to create a defintion and provide the appropriate parameters
for each install.
This doesn't work as the install script which is part of the definition and
needs
to be downloaded is common within differently defined instances. Thus puppet
complains about a duplicate class definition.
The current code (sanitised for this list) looks as follows:
define software_installation (
$software_install_dir = '/path/to/software/installation',
$software_version = 'X.Y.Z',
$software_env = 'prod'
) {
case $software_env {
'prod': {}
'dev': {}
default: { fail( "software_env not defined. Should be 'dev' or
'prod'" ) }
}
$download_dir = '/root/tmp'
$install_script = 'install_script_name'
file { "$download_dir":
owner => root,
group => root,
mode => 700,
ensure => directory,
}
file { "$download_dir/$install_script":
backup => false,
owner => root,
group => root,
mode => 700,
source => "puppet:///source_location/$install_script",
require => File["$download_dir"]
}
exec { "$install_script/$software_env":
command => "$download_dir/$install_script ... appropriate
parameters ...",
onlyif => "... test if software not installed ...",
require => File["$download_dir/$install_script"]
}
}
and is called as follows:
software_installation { '/path/to/install/prod':
software_install_dir => '/path/to/install/prod',
software_version => '1.2.3',
software_env => 'prod'
}
software_installation { '/path/to/install/dev':
software_install_dir => '/path/to/install/dev',
software_version => '1.3.1',
software_env => 'dev'
}
The error I get is
err: Could not retrieve catalog: Puppet::Parser::AST::Resource failed with
error ArgumentError: Duplicate definition: File[/root/tmp] is already defined
in file //etc/puppet/services/xxxx/manifests/init.pp at line 83; cannot
redefine at //etc/puppet/services/xxxx/manifests/init.pp:83 on node
dev01.example.com
I'd rather NOT download the install script unless I want to install
the software and of course the install script is designed to install
multiple versions (if necessary) at once. Additionally removing the
2 file definitions outside of the defintion will also have issues with
variable scoping, thus making the solution less clean.
So how should I best approach this in puppet?
Thanks for any thoughts.
Simon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---