Suresh
2012-Apr-25 21:51 UTC
[Puppet Users] Host/Agent should not install if there are no changes in file
Can you guys please help me address this host configuration? 1) I have 5 different modules that need to be installed to each host/agent 1.1) from one of the modules, a large application tar file is downloaded by agent and performs untar to required folder structure. 1.2) before the "untar", required application services are stopped and after "untar'' is complete all the services are started What I have observed is, agent is downloading the application tar file every 30 minutes (agent is running in daemon mode) and performing the complete process (1, 1.1, 1.2) which it shouldn''t if the file is unchanged from its previous download. How can I configure agent, such that it should perform the installation, only if downloaded file is changed from previous download? Suresh -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/_YirDaiAVGwJ. 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.
Michael Baydoun
2012-Apr-26 00:21 UTC
Re: [Puppet Users] Host/Agent should not install if there are no changes in file
The file ensure for the tar file should only download when it changes The untar can have a require on the file resource, and so on Can you post your file resource and untar exec resource? On Wed, Apr 25, 2012 at 5:51 PM, Suresh <suresh.k.ugrp@gmail.com> wrote:> Can you guys please help me address this host configuration? > > 1) I have 5 different modules that need to be installed to each host/agent > 1.1) from one of the modules, a large application tar file is downloaded > by agent and performs untar to required folder structure. > 1.2) before the "untar", required application services are stopped and > after "untar'' is complete all the services are started > > What I have observed is, agent is downloading the application tar file > every 30 minutes (agent is running in daemon mode) > and performing the complete process (1, 1.1, 1.2) which it shouldn''t if > the file is unchanged from its previous download. > > > How can I configure agent, such that it should perform the installation, > only if downloaded file is changed from previous download? > > Suresh > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/puppet-users/-/_YirDaiAVGwJ. > 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. >-- 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.
Suresh
2012-Apr-26 03:02 UTC
Re: [Puppet Users] Host/Agent should not install if there are no changes in file
class filecheck { include myapp file { "puppet:///modules/myapp/MyApp_GA.tar.gz": owner => ''myapp'', group => ''myapp'', ensure => latest, path => "/opt/apps/myapp/artifacts/MyApp_GA.tar.gz", } } class myapp::decompress { exec { "myapp::decompress": owner => ''myapp'', group => ''myapp'', mode => 0755, command => "/bin/tar -xzf MyApp_GA.tar.gz -C /opt/apps/myapp/release" } in my puppet manifests/nodes.pp I have defined several stages e.g. nodes.pp =======stage { "stop_service": ; } node mynode.com { include filecheck, myapp } What I need is if filecheck fails, then execution should stop and should go no further. -Suresh On Wed, Apr 25, 2012 at 7:21 PM, Michael Baydoun <indymichaelb@gmail.com>wrote:> The file ensure for the tar file should only download when it changes > The untar can have a require on the file resource, and so on > > Can you post your file resource and untar exec resource? > > > On Wed, Apr 25, 2012 at 5:51 PM, Suresh <suresh.k.ugrp@gmail.com> wrote: > >> Can you guys please help me address this host configuration? >> >> 1) I have 5 different modules that need to be installed to each host/agent >> 1.1) from one of the modules, a large application tar file is downloaded >> by agent and performs untar to required folder structure. >> 1.2) before the "untar", required application services are stopped and >> after "untar'' is complete all the services are started >> >> What I have observed is, agent is downloading the application tar file >> every 30 minutes (agent is running in daemon mode) >> and performing the complete process (1, 1.1, 1.2) which it shouldn''t if >> the file is unchanged from its previous download. >> >> >> How can I configure agent, such that it should perform the installation, >> only if downloaded file is changed from previous download? >> >> Suresh >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Puppet Users" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/puppet-users/-/_YirDaiAVGwJ. >> 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. >> > > -- > 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. >-- 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.
jcbollinger
2012-Apr-26 12:57 UTC
[Puppet Users] Re: Host/Agent should not install if there are no changes in file
On Apr 25, 10:02 pm, Suresh <suresh.k.u...@gmail.com> wrote:> class filecheck { > include myapp > file { "puppet:///modules/myapp/MyApp_GA.tar.gz": > owner => ''myapp'', > group => ''myapp'', > ensure => latest, > path => "/opt/apps/myapp/artifacts/MyApp_GA.tar.gz", > } > > } > > class myapp::decompress { > exec { "myapp::decompress": > owner => ''myapp'', > group => ''myapp'', > mode => 0755, > command => "/bin/tar -xzf MyApp_GA.tar.gz -C /opt/apps/myapp/release" > > } > > in my puppet manifests/nodes.pp > I have defined several stages e.g. > > nodes.pp > =======> stage { > "stop_service": ; > } > > node mynode.com { > include filecheck, myapp > } > > What I need is if filecheck fails, then execution should stop and should go > no further.That should indeed happen if filecheck failed, but File[''puppet:/// modules/myapp/MyApp_GA.tar.gz''] (and thus Class[''filecheck'']) will not fail on account of the file already being present. It should not download the file again either in that case (are you sure it''s doing so?) unless the version on the server is different from the one on the client, but nothing I see in your manifests would prevent Puppet from proceeding to Exec[ ''myapp::decompress'' ]. You need to adjust your mental model. Your class names and your expectations suggest that you regard Puppet as some kind of scripting engine. It isn''t. Rather, it is a state management service. It takes your specifications for a target *state*, and does whatever is necessary (broadly speaking) to achieve that state. "Whatever it takes" can be nothing, and that''s just fine with Puppet -- by no means is it a failure. To address your problem, it would be far better build a package for "myapp" (RPM, DEB, or whatever is appropriate for your target system), put it in a local package repository, and use Puppet''s Package resource type to ensure it installed. Even stopping and restarting the service around an installation or update would be better done in the package''s scripts than directly under Puppet control. Don''t reinvent the wheel here. John -- 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.
Michael Baydoun
2012-Apr-26 13:24 UTC
Re: [Puppet Users] Host/Agent should not install if there are no changes in file
add something like notify => Exec["myapp::decompress"], to your file resource also, according to the documentation, for a file resource the ensure parameter possible values are *absent*, *present*, *file*, and *directory* I''m not sure what latest is going to do there, but you don''t need it, just say present ensure => latest is usually used for the package resource type, though I would suggest never doing that either, unless you really want your package management trying to update everytime puppet runs On Wed, Apr 25, 2012 at 11:02 PM, Suresh <suresh.k.ugrp@gmail.com> wrote:> class filecheck { > include myapp > file { "puppet:///modules/myapp/MyApp_GA.tar.gz": > owner => ''myapp'', > group => ''myapp'', > ensure => latest, > path => "/opt/apps/myapp/artifacts/MyApp_GA.tar.gz", > } > } > > > class myapp::decompress { > exec { "myapp::decompress": > owner => ''myapp'', > group => ''myapp'', > mode => 0755, > command => "/bin/tar -xzf MyApp_GA.tar.gz -C /opt/apps/myapp/release" > } > > > in my puppet manifests/nodes.pp > I have defined several stages e.g. > > nodes.pp > =======> stage { > "stop_service": ; > } > > node mynode.com { > include filecheck, myapp > } > > What I need is if filecheck fails, then execution should stop and should > go no further. > > -Suresh > > On Wed, Apr 25, 2012 at 7:21 PM, Michael Baydoun <indymichaelb@gmail.com>wrote: > >> The file ensure for the tar file should only download when it changes >> The untar can have a require on the file resource, and so on >> >> Can you post your file resource and untar exec resource? >> >> >> On Wed, Apr 25, 2012 at 5:51 PM, Suresh <suresh.k.ugrp@gmail.com> wrote: >> >>> Can you guys please help me address this host configuration? >>> >>> 1) I have 5 different modules that need to be installed to each >>> host/agent >>> 1.1) from one of the modules, a large application tar file is downloaded >>> by agent and performs untar to required folder structure. >>> 1.2) before the "untar", required application services are stopped and >>> after "untar'' is complete all the services are started >>> >>> What I have observed is, agent is downloading the application tar file >>> every 30 minutes (agent is running in daemon mode) >>> and performing the complete process (1, 1.1, 1.2) which it shouldn''t if >>> the file is unchanged from its previous download. >>> >>> >>> How can I configure agent, such that it should perform the installation, >>> only if downloaded file is changed from previous download? >>> >>> Suresh >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Puppet Users" group. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msg/puppet-users/-/_YirDaiAVGwJ. >>> 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. >>> >> >> -- >> 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. >> > > -- > 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. >-- 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.
jcbollinger
2012-Apr-26 14:33 UTC
[Puppet Users] Re: Host/Agent should not install if there are no changes in file
On Apr 25, 10:02 pm, Suresh <suresh.k.u...@gmail.com> wrote:> file { "puppet:///modules/myapp/MyApp_GA.tar.gz": > owner => ''myapp'', > group => ''myapp'', > ensure => latest, > path => "/opt/apps/myapp/artifacts/MyApp_GA.tar.gz", > }Furthermore, if you continue to use File and Exec resources instead of packaging it up, you should really write that File resource in one of these two forms: # using a logical name for the resource file { ''myapp::tarball'': ensure => ''file'', path => ''/opt/apps/myapp/artifacts/MyApp_GA.tar.gz'', owner => ''myapp'', group => ''myapp'', ensure => latest, # exactly one of ''source'', ''content'', or ''target'': source => ''puppet:///modules/myapp/MyApp_GA.tar.gz'', } # using the destination path as the resource name file { ''/opt/apps/myapp/artifacts/MyApp_GA.tar.gz'': ensure => ''file'', owner => ''myapp'', group => ''myapp'', ensure => latest, # exactly one of ''source'', ''content'', or ''target'': source => ''puppet:///modules/myapp/MyApp_GA.tar.gz'', } You should *not* name the resource by the server-side path / URL. Also, you absolutely should specify the file content via either ''content'' or ''source''. That it worked at all as you presented it (supposing that it did) is an undocumented implementation quirk on which you should not rely. Furthermore, you should specify an explicit ''ensure'' value at least for clarity, and maybe for correctness. John -- 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.