-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi, I''m trying to set up a system to deploy a set of different python
services that each will be run as a separate user with different
packages installed.
The basic code is:
define easy_install($app, $user , $log = True) {
exec { "su - $user -c ''easy_install $app''":
}
}
define twisted_instance($app, $appConfig,$port = 8000, $python_deps
["twisted"], $packages = [] ) {
easy_install { $python_deps : user=> $user , log => false}
}
There is a lot more to the template than this, but I''m trying to keep
this message short.
Then I define servers like this:
twisted_instance{"name":
app => http://svn....",
appConfig => "path/to/template",
port => 7001,
python_deps => ["twisted",
"pysqlite", "uuid",
"ConfigObj", "storm"],
packages => [
"fonts-bengali"
]}
This works well for one instance, but when I define two instances I get:
err: Could not retrieve catalog: Puppet::Parser::AST::Resource failed
with error ArgumentError: Duplicate definition: Easy_install[twisted] is
already defined in file /etc/puppet/modules/twisted/manifests/init.pp at
line 57; cannot redefine at
/etc/puppet/modules/twisted/manifests/init.pp:57 on node skryme.scanmine.com
The problem here is that it is the user that varies.
Now, this isn''t a big problem if I new how to do an iteration. Then I
could change :
easy_install { $python_deps : user=> $user , log => false}
to:
easy_install { "something" : python_deps => $python_deps, user=>
$user ,
log => false}
and the define to something like:
define easy_install($apps, $user , $log = True) {
for $app in $apps:
exec { "su - $user -c ''easy_install $app''":
}
}
So how can I do this? Any suggestions?
Kind regards,
Tarjei
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFIbKM0YVRKCnSvzfIRAnCYAJ9idPsA1aEmA5l+0H4Z/posrWTgEwCfeIr8
p4m90v2PeocG2RMKBx+i5bo=uUrJ
-----END PGP SIGNATURE-----
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to
puppet-users-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---
tarjei wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi, I''m trying to set up a system to deploy a set of different python > services that each will be run as a separate user with different > packages installed. > > The basic code is: > > define easy_install($app, $user , $log = True) { > exec { "su - $user -c ''easy_install $app''": } > } > > define twisted_instance($app, $appConfig,$port = 8000, $python_deps > ["twisted"], $packages = [] ) { > > easy_install { $python_deps : user=> $user , log => false} > > } > > There is a lot more to the template than this, but I''m trying to keep > this message short. > > Then I define servers like this: > > twisted_instance{"name": > app => http://svn....", > appConfig => "path/to/template", > port => 7001, > python_deps => ["twisted", "pysqlite", "uuid", > "ConfigObj", "storm"], > packages => [ > "fonts-bengali" > ]} > > > This works well for one instance, but when I define two instances I get: > > err: Could not retrieve catalog: Puppet::Parser::AST::Resource failed > with error ArgumentError: Duplicate definition: Easy_install[twisted] is > already defined in file /etc/puppet/modules/twisted/manifests/init.pp at > line 57; cannot redefine at > /etc/puppet/modules/twisted/manifests/init.pp:57 on node skryme.scanmine.com > > The problem here is that it is the user that varies. > > Now, this isn''t a big problem if I new how to do an iteration. Then I > could change : > easy_install { $python_deps : user=> $user , log => false} > > to: > > easy_install { "something" : python_deps => $python_deps, user=> $user , > log => false} > > and the define to something like: > define easy_install($apps, $user , $log = True) { > for $app in $apps: > exec { "su - $user -c ''easy_install $app''": } > } > > So how can I do this? Any suggestions? >Pass in the app as a parameter, and mangle the name define twisted_instance($app, $appConfig,$port = 8000, $python_deps ["twisted"], $packages = [] ) { easy_install { "install_depdencies_$name": app => $python_deps : user=> $user , log => false} } You are overloading app as the namevar. -- bk --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi,>> So how can I do this? Any suggestions? >> > > Pass in the app as a parameter, and mangle the name > > define twisted_instance($app, $appConfig,$port = 8000, $python_deps > ["twisted"], $packages = [] ) { > > easy_install { "install_depdencies_$name": app => $python_deps : > user=> $user , log => false} > > }I''ve tried this, but how do I iterate over the packages? If I just pass app => ["storm", "pylons"] then I end up executing su -c ''easy_install stormpylons'' instead of running it as multiple commands. Kind regards, Tarjei> > You are overloading app as the namevar. > > -- bk > > > >-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIbLYaYVRKCnSvzfIRAt6oAJ9/nktHpYWCPbUHGtiSMupRXmsOywCgiC8D 84Ad3X1NRzO4p0Im4xkhm6k=ftY4 -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
tarjei wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi, >>> So how can I do this? Any suggestions? >>> >> Pass in the app as a parameter, and mangle the name >> >> define twisted_instance($app, $appConfig,$port = 8000, $python_deps >> ["twisted"], $packages = [] ) { >> >> easy_install { "install_depdencies_$name": app => $python_deps : >> user=> $user , log => false} >> >> } > > I''ve tried this, but how do I iterate over the packages? If I just pass > app => ["storm", "pylons"] then I end up executing > su -c ''easy_install stormpylons'' > > instead of running it as multiple commands.I beleieve that if you have to use an Array, and iterate, then you have to create a custom type. -- bk --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Bryan Kearney schrieb:> > I beleieve that if you have to use an Array, and iterate, then you have > to create a custom type. >Not really. What actually works is something like that: Exec { "foo": command => template(''foo.erb''), } Then you only have to iterate the array in the template and generate the required commands. Not very nice, but works :) Regards, Andreas -- Solvention Egermannstr. 6-8 53359 Rheinbach Tel: +49 2226 158179-0 Fax: +49 2226 158179-9 http://www.solvention.de mailto:info@solvention.de
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Bryan Kearney wrote:> tarjei wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> Hi, >>>> So how can I do this? Any suggestions? >>>> >>> Pass in the app as a parameter, and mangle the name >>> >>> define twisted_instance($app, $appConfig,$port = 8000, $python_deps >>> ["twisted"], $packages = [] ) { >>> >>> easy_install { "install_depdencies_$name": app => $python_deps : >>> user=> $user , log => false} >>> >>> } >> I''ve tried this, but how do I iterate over the packages? If I just pass >> app => ["storm", "pylons"] then I end up executing >> su -c ''easy_install stormpylons'' >> >> instead of running it as multiple commands. > > I beleieve that if you have to use an Array, and iterate, then you have > to create a custom type.Ok. Do you have a pointer to a custom type example? I tried to find info about this in the documentation, but I couldn''t find it for some reason. Kind regards, Tarjei> > -- bk > > > >-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIbLnYYVRKCnSvzfIRAuNRAKC8Eo65ortNd9uMUAs6GiRNPr7QVQCcCaJT rfI4RZJykRiV9E8rsM4n468=jJEr -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
tarjei wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Bryan Kearney wrote: >> tarjei wrote: >>> -----BEGIN PGP SIGNED MESSAGE----- >>> Hash: SHA1 >>> >>> Hi, >>>>> So how can I do this? Any suggestions? >>>>> >>>> Pass in the app as a parameter, and mangle the name >>>> >>>> define twisted_instance($app, $appConfig,$port = 8000, $python_deps >>>> ["twisted"], $packages = [] ) { >>>> >>>> easy_install { "install_depdencies_$name": app => $python_deps : >>>> user=> $user , log => false} >>>> >>>> } >>> I''ve tried this, but how do I iterate over the packages? If I just pass >>> app => ["storm", "pylons"] then I end up executing >>> su -c ''easy_install stormpylons'' >>> >>> instead of running it as multiple commands. >> I beleieve that if you have to use an Array, and iterate, then you have >> to create a custom type. > > Ok. Do you have a pointer to a custom type example? I tried to find info > about this in the documentation, but I couldn''t find it for some reason. > > Kind regards, > Tarjei >Best to start here: http://www.reductivelabs.com/trac/puppet/wiki/PracticalTypes Then here: http://www.reductivelabs.com/trac/puppet/wiki/CreatingCustomTypes --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
> Hi, I''m trying to set up a system to deploy a set of different python > services that each will be run as a separate user with different > packages installed. > > The basic code is: > > define easy_install($app, $user , $log = True) { > exec { "su - $user -c ''easy_install $app''": } > } > > define twisted_instance($app, $appConfig,$port = 8000, $python_deps > ["twisted"], $packages = [] ) { > > easy_install { $python_deps : user=> $user , log => false} > > } > > There is a lot more to the template than this, but I''m trying to keep > this message short. > > Then I define servers like this: > > twisted_instance{"name": > app => http://svn....", > appConfig => "path/to/template", > port => 7001, > python_deps => ["twisted", "pysqlite", "uuid", > "ConfigObj", "storm"], > packages => [ > "fonts-bengali" > ]}Okay I don''t think iteration is going to solve your problem here. You can only ever have one occurrence of the namespace easy_install{twisted: } and you have set to try and happen several times. this happening becuase you are calling the twisted every time you use the twisted_instances. Defines have to be setup in such a way that they can be used multiple times. Instead of just reinstalling twisted everytime you run the twisted_instance( which is what you are doing), change python_deps from the be handled as a require => instead of just reinstalling so you get something more like this: define twisted_instance($app, $appConfig,$port = 8000, $python_deps ["twisted"], $packages = [] ) { easy_install { $app: require => $python_deps, user=> $user , log => false } } $base-twisted=["twisted", "pysqlite", "uuid", "ConfigObj", "storm"] easy_install{$base-twisted; } twisted_instance{"name": app => "http://svn....", appConfig => "path/to/template", port => 7001, python_deps => ["Easy_install[twisted]", "Easy_install[pysqlite]", "Easy_install[uuid]", "Easy_install[ConfigObj]", "Easy_install[storm]"], # You can''t just pass an array to Easy_install [$array] yet. This in the tracker to get fixed packages => "fonts-bengali", }> This works well for one instance, but when I define two instances I get: > > err: Could not retrieve catalog: Puppet::Parser::AST::Resource failed > with error ArgumentError: Duplicate definition: Easy_install[twisted] is > already defined in file /etc/puppet/modules/twisted/manifests/init.pp at > line 57; cannot redefine at > /etc/puppet/modules/twisted/manifests/init.pp:57 on node skryme.scanmine.com > The problem here is that it is the user that varies.This caused by the namespace collision of trying to name 2 instances of easy_install the same.> > Now, this isn''t a big problem if I new how to do an iteration. Then I > could change : > easy_install { $python_deps : user=> $user , log => false} > > to: > > easy_install { "something" : python_deps => $python_deps, user=> $user , > log => false} > > and the define to something like: > define easy_install($apps, $user , $log = True) { > for $app in $apps: > exec { "su - $user -c ''easy_install $app''": } > } > > So how can I do this? Any suggestions?Puppet does not do this kind of looping. This type of looping is mostly not supported because it tends to make you think at a less abstract level, as I understand it, and abstraction is the key to a good puppet manifest. That is probably not the perfect solution to your problem but based on the available manifest I think can give you a good idea of how to solve it. Evan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---