chuck clark
2010-Jun-08 20:26 UTC
[Puppet Users] Can recipe variables be set at the command line?
I''d like to be able to override or set a variable from the command line. Is this possible? The only discussion I''ve been able to stumble upon is this feature/issue: http://projects.puppetlabs.com/issues/1411 My use case is the following: I have a specific version of an artifact installed in my PRD environment. The version number is set in the recipe. The artifact is a simple tgz which is downloaded from our continuous integration server, unpacked and symlinked. In my TST environment I''d like a continuous integration server to kick off a puppet run after a change is made and pass in the latest version of the artifact just built. This does highlight one aspect of our puppet installation which may be different than most -- we do not run puppet daemons on each server which wake up at regular intervals, query puppetmaster and apply changes but instead we trigger the updates when needed through a capistrano task. The pertinent recipe snippets look like: class logmaster { $download_dir = "/scratch" $prg = "logmaster" $prg_version = "2.0.16622.25" $prg_tarball = "$prg-$prg_version-install.tar.gz" $prg_dir = "$prg-$prg_version" $download_url = "> http://buildserver:8080/teamcity/httpAuth/repository/download/bt34/.lastPinned/$prg_tarball > "$install_dir = "/opt" $installed = "$install_dir/$prg_dir" $linked = "$install_dir/$prg" ... exec { "DownloadLogmaster": cwd => "$download_dir", command => "wget $download_url", creates => "$download_dir/$prg_tarball", } exec { "InstallLogmaster": cwd => "$download_dir", logoutput => true, command => "tar -zxvf $prg_tarball; mv $prg_dir $install_dir; chown> -R logmaster:logmaster $installed; ln -s $installed $linked",creates => "$install_dir/$prg_dir", require => Exec["DownloadLogmaster"], } ... } This install method feels a little hackish and I know it might be cleaner/easier to package as an RPM or deb file but we have a lot more developer knowledge than sysadmin knowledge in-house and we''re slowly taking that plunge and I''d welcome other suggestions on how people install simple tgz files. But it seems even with RPM I''d have the same problem that I''d specify a version in the ensure attribute of the package to ensue PRD has that version but when running against TST I''d want it to be overridden to be latest or the most recent version from the continuous integration server. Perhaps I need to have a recipe per environment and TST is always latest and PRD is hard versioned but that seems like a lot of recipe duplication for what is essentially a steady-state because I always want to be running a continuous integration server and encouraging our team to push changes. Essentially I''d like to be able to call: puppetd --no-daemonize --test --setvar logmaster::prg_version=2.1 --tags=logmaster This would then kick off an update for the logmaster recipe for version 2.1. Is it possible to easily override a recipe variable at the command line or is there a better approach others have taken if they''ve encountered this scenario? thanks, chuck -- 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.
Nigel Kersten
2010-Jun-08 20:37 UTC
Re: [Puppet Users] Can recipe variables be set at the command line?
On Tue, Jun 8, 2010 at 1:26 PM, chuck clark <cclark@ziclix.com> wrote:> I''d like to be able to override or set a variable from the command line. > Is this possible? The only discussion I''ve been able to stumble upon is > this feature/issue: http://projects.puppetlabs.com/issues/1411 > > My use case is the following: > > I have a specific version of an artifact installed in my PRD environment. > The version number is set in the recipe. The artifact is a simple tgz > which is downloaded from our continuous integration server, unpacked and > symlinked. > > In my TST environment I''d like a continuous integration server to kick off > a puppet run after a change is made and pass in the latest version of the > artifact just built. This does highlight one aspect of our puppet > installation which may be different than most -- we do not run puppet > daemons on each server which wake up at regular intervals, query > puppetmaster and apply changes but instead we trigger the updates when > needed through a capistrano task. > > The pertinent recipe snippets look like: > > class logmaster { > > $download_dir = "/scratch" > > $prg = "logmaster" > > $prg_version = "2.0.16622.25" > > $prg_tarball = "$prg-$prg_version-install.tar.gz" > > $prg_dir = "$prg-$prg_version" > > $download_url = " >> http://buildserver:8080/teamcity/httpAuth/repository/download/bt34/.lastPinned/$prg_tarball >> " > > $install_dir = "/opt" > > $installed = "$install_dir/$prg_dir" > > $linked = "$install_dir/$prg" > > ... > > > > exec { "DownloadLogmaster": > > cwd => "$download_dir", > > command => "wget $download_url", > > creates => "$download_dir/$prg_tarball", > > } > > > > exec { "InstallLogmaster": > > cwd => "$download_dir", > > logoutput => true, > > command => "tar -zxvf $prg_tarball; mv $prg_dir $install_dir; chown >> -R logmaster:logmaster $installed; ln -s $installed $linked", > > creates => "$install_dir/$prg_dir", > > require => Exec["DownloadLogmaster"], > > } > > ... > > } > > > > This install method feels a little hackish and I know it might be > cleaner/easier to package as an RPM or deb file but we have a lot more > developer knowledge than sysadmin knowledge in-house and we''re slowly taking > that plunge and I''d welcome other suggestions on how people install simple > tgz files. But it seems even with RPM I''d have the same problem that I''d > specify a version in the ensure attribute of the package to ensue PRD has > that version but when running against TST I''d want it to be overridden to be > latest or the most recent version from the continuous integration server. > Perhaps I need to have a recipe per environment and TST is always latest > and PRD is hard versioned but that seems like a lot of recipe duplication > for what is essentially a steady-state because I always want to be running a > continuous integration server and encouraging our team to push changes. > > Essentially I''d like to be able to call: > puppetd --no-daemonize --test --setvar logmaster::prg_version=2.1 > --tags=logmaster > > This would then kick off an update for the logmaster recipe for version > 2.1. > > Is it possible to easily override a recipe variable at the command line or > is there a better approach others have taken if they''ve encountered this > scenario? >FACTER_somevar=2.1 puppetd --test will expose $somevar=2.1 to your manifests> > thanks, > chuck > > -- > 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<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. >-- nigel -- 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.
chuck clark
2010-Jun-08 22:13 UTC
Re: [Puppet Users] Can recipe variables be set at the command line?
Thanks Nigel. On Tue, Jun 8, 2010 at 1:37 PM, Nigel Kersten <nigelk@google.com> wrote: Just to clarify and document for others who may arrive here from Google in search of an answer to a similar question...> > > FACTER_somevar=2.1 puppetd --test >> will expose $somevar=2.1 to your manifests > > This does indeed work. You''re setting an environment variable and usingthe functionality discussed in this thread: http://groups.google.com/group/puppet-dev/browse_thread/thread/ffae5ea1dcc3f2f8 thanks again, chuck -- 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.
Nigel Kersten
2010-Jun-08 22:37 UTC
Re: [Puppet Users] Can recipe variables be set at the command line?
On Tue, Jun 8, 2010 at 3:13 PM, chuck clark <cclark@ziclix.com> wrote:> Thanks Nigel. > > On Tue, Jun 8, 2010 at 1:37 PM, Nigel Kersten <nigelk@google.com> wrote: > > Just to clarify and document for others who may arrive here from Google in > search of an answer to a similar question... > > >> >> FACTER_somevar=2.1 puppetd --test >> > >> will expose $somevar=2.1 to your manifests >> >> This does indeed work. You''re setting an environment variable and using > the functionality discussed in this thread: > http://groups.google.com/group/puppet-dev/browse_thread/thread/ffae5ea1dcc3f2f8 > > thanks again, > \ >No worries. I use this a lot to test manifests standalone on the command line before integrating them into my puppetmaster configs, and we''ve used it in the past for people to be able to opt into upcoming changes, like when we rolled out full disk encryption on our Mac clients. -- 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.