FAQ
Here's one for you!

We're rolling out some zip files to our servers using Puppet, there's an
exec that unzips them, the zip file is then deleted. I need to remove the
old versions of the unzipped directory using Puppet when we rol out a newer
version.

So, on my client/node machine I have the below directories.

/opt/1234
/opt/12345
/opt/123456

What I need to do, is rm the the above directories when we roll out
1234567.zip. When the newest directory (1234567) is unzipped, the Puppet
exec sym links it to /opt/java. So could I remove the older directores that
are not sym linked?

Maybe using:

tidy { tidy_opt:
path => "/opt/",
age => "1d",
backup => false,
matches => [ "some nice ruby here that finds the non sym linked directories??" ],
}


Hope this makes sense?

Thanks,


--
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/-/nq3bxtqSYNwJ.
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.

Search Discussions

  • Jcbollinger at Oct 8, 2012 at 3:36 pm

    On Thursday, October 4, 2012 11:05:08 AM UTC-5, timo wrote:
    Here's one for you!

    We're rolling out some zip files to our servers using Puppet, there's an
    exec that unzips them, the zip file is then deleted. I need to remove the
    old versions of the unzipped directory using Puppet when we rol out a newer
    version.

    So, on my client/node machine I have the below directories.

    /opt/1234
    /opt/12345
    /opt/123456

    What I need to do, is rm the the above directories when we roll out
    1234567.zip. When the newest directory (1234567) is unzipped, the Puppet
    exec sym links it to /opt/java. So could I remove the older directores that
    are not sym linked?

    Maybe using:

    tidy { tidy_opt:
    path => "/opt/",
    age => "1d",
    backup => false,
    matches => [ "some nice ruby here that finds the non sym linked directories??" ],
    }

    There are several ways you could approach this, and which would be best
    depends on several factors. It would be ideal if the directories you want
    to manage this way were located in a parent directory that you could be
    sure would hold only files for this general purpose. I would not feel
    comfortable assuming that /opt satisfies that criterion, but you could set
    up a subdirectory such as /opt/java_version for the purpose.

    Next you should consider whether you need the test for which directory is
    currently symlinked. You're managing the deployment of those directories
    and (I hope) the symlink itself via Puppet, so you don't really need to
    test. Instead, you can just rely on Puppet to get it done, or else to fail
    before any damage is done. For example, you can do something like this:

    $java_base_directory = '/opt/java_version'
    $current_java_version = '123456'

    # Put the current version in place, update the
    # symlink, etc.; perhaps you have a defined
    # type that handles it?
    deploy_java_version { "${current_java_version}":
    base_directory => "${java_base_directory}"
    }

    # Clean up other versions
    file { "${java_base_directory}":
    ensure => directory,
    recurse => remote,
    purge => true,
    ignore => "${java_base_directory}/${current_java_version}",
    require => Deploy_java_version["${current_java_version}"]
    }

    You may need also a "source" parameter, but it can (and should) point to an
    empty directory on the master's file server.

    There are other approaches you could consider, but other than an Exec, all
    of them either require you to maintain a list of the directories you want
    to ensure have been removed, or else to create and deploy a custom fact.
    Neither of those is hard, but they would be bigger and a bit messier than
    the above approach.


    John

    --
    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/-/U0u4ReIpnS0J.
    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.
  • Stephen Gran at Oct 8, 2012 at 3:55 pm
    Hi,
    On Thu, 2012-10-04 at 09:05 -0700, timo wrote:
    Here's one for you!


    We're rolling out some zip files to our servers using Puppet, there's
    an exec that unzips them, the zip file is then deleted. I need to
    remove the old versions of the unzipped directory using Puppet when we
    rol out a newer version.


    So, on my client/node machine I have the below directories.


    /opt/1234
    /opt/12345
    /opt/123456


    What I need to do, is rm the the above directories when we roll out
    1234567.zip. When the newest directory (1234567) is unzipped, the
    Puppet exec sym links it to /opt/java. So could I remove the older
    directores that are not sym linked?


    Maybe using:


    tidy { tidy_opt:
    path => "/opt/",
    age => "1d",
    backup => false,
    matches => [ "some nice ruby here that finds the non sym linked directories??" ],
    }
    So, there are a number of approaches that might make sense here,
    including making a named subdirectory (say, /opt/java_version or
    something) and managing that directory with recurse and force and so on.

    But, here's a nickel. Buy yourself a package management system.

    Cheers,
    --
    Stephen Gran
    Senior Systems Integrator - guardian.co.uk

    Please consider the environment before printing this email.
    ------------------------------------------------------------------
    Visit guardian.co.uk - newspaper of the year

    www.guardian.co.uk www.observer.co.uk www.guardiannews.com

    On your mobile, visit m.guardian.co.uk or download the Guardian
    iPhone app www.guardian.co.uk/iphone and iPad edition www.guardian.co.uk/iPad

    Save up to 37% by subscribing to the Guardian and Observer - choose the papers you want and get full digital access.
    Visit guardian.co.uk/subscribe

    ---------------------------------------------------------------------
    This e-mail and all attachments are confidential and may also
    be privileged. If you are not the named recipient, please notify
    the sender and delete the e-mail and all attachments immediately.
    Do not disclose the contents to another person. You may not use
    the information for any purpose, or store, or copy, it in any way.

    Guardian News & Media Limited is not liable for any computer
    viruses or other material transmitted with or as part of this
    e-mail. You should employ virus checking software.

    Guardian News & Media Limited

    A member of Guardian Media Group plc
    Registered Office
    PO Box 68164
    Kings Place
    90 York Way
    London
    N1P 2AP

    Registered in England Number 908396

    --
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedOct 5, '12 at 12:33p
activeOct 8, '12 at 3:55p
posts3
users3
websitepuppetlabs.com

3 users in discussion

Stephen Gran: 1 post Jcbollinger: 1 post Timo: 1 post

People

Translate

site design / logo © 2022 Grokbase