FAQ
Hi

I have wriiten a class to deploy a tra file and extract on a remote puppet
client. The tar file gets copied across fine and it seems to puppet the
thet tar extraction suceeds, but when I check the client I dont see the
extracted files

exec { "Deploy Code":
command => "/bin/tar -xvf /var/tmp/deploy.tar",
onlyif => [
"/usr/bin/test -d /var/tmp/test/" #just
testing this
]
}

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

  • Peter Bukowinski at Aug 8, 2012 at 4:29 pm

    On Aug 8, 2012, at 5:40 AM, duckegg01 wrote:

    Hi

    I have wriiten a class to deploy a tra file and extract on a remote puppet client. The tar file gets copied across fine and it seems to puppet the thet tar extraction suceeds, but when I check the client I dont see the extracted files

    exec { "Deploy Code":
    command => "/bin/tar -xvf /var/tmp/deploy.tar",
    onlyif => [
    "/usr/bin/test -d /var/tmp/test/" #just testing this
    ]
    }
    I see two possible issues. First, you either need to give the exec resource a working directory via the 'cwd' parameter, or you need to use tar's -C option to specify where to extract the files. Without either of these, files will extract into the home of whichever user is running puppet. So either add this parameter:

    cwd => '/var/tmp/,

    or use this as your tar command ( -- # note that I skipped the verbose switch since it's not interactive):

    /bin/tar -xf /var/tmp/deploy.tar -C /var/tmp

    Another possible issue: If you want /var/tmp/deploy.tar to extract to /var/tmp/test, then you need to leave off the 'onlyif' parameter. Currently, the exec will only run if /var/tmp/test already exists.

    One last thing. If you haven't done so already, set up a dependency between the file resource that copies the tar file to the node and the exec resource that extracts it -- either via a notify parameter in the file resource or a require parameter in the exec resource.

    --
    Peter Bukowinski

    --
    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.
  • Duckegg01 at Aug 9, 2012 at 8:51 am
    Hi Peter

    I managed to get this working by have the cwd in place, but im interested
    in your point with regards to setting up the dependency any chance you can
    provide an example of this based on what I have at present.
    On Wednesday, August 8, 2012 5:29:06 PM UTC+1, pmbuko wrote:
    On Aug 8, 2012, at 5:40 AM, duckegg01 wrote:

    Hi

    I have wriiten a class to deploy a tra file and extract on a remote
    puppet client. The tar file gets copied across fine and it seems to puppet
    the thet tar extraction suceeds, but when I check the client I dont see the
    extracted files
    exec { "Deploy Code":
    command => "/bin/tar -xvf /var/tmp/deploy.tar",
    onlyif => [
    "/usr/bin/test -d /var/tmp/test/"
    #just testing this
    ]
    }
    I see two possible issues. First, you either need to give the exec
    resource a working directory via the 'cwd' parameter, or you need to use
    tar's -C option to specify where to extract the files. Without either of
    these, files will extract into the home of whichever user is running
    puppet. So either add this parameter:

    cwd => '/var/tmp/,

    or use this as your tar command ( -- # note that I skipped the verbose
    switch since it's not interactive):

    /bin/tar -xf /var/tmp/deploy.tar -C /var/tmp

    Another possible issue: If you want /var/tmp/deploy.tar to extract to
    /var/tmp/test, then you need to leave off the 'onlyif' parameter.
    Currently, the exec will only run if /var/tmp/test already exists.

    One last thing. If you haven't done so already, set up a dependency
    between the file resource that copies the tar file to the node and the exec
    resource that extracts it -- either via a notify parameter in the file
    resource or a require parameter in the exec resource.

    --
    Peter Bukowinski
    --
    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/-/gOIxni7fKGIJ.
    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.
  • Peter Bukowinski at Aug 9, 2012 at 12:24 pm
    Adding this parameter to your file resource,

    notify => Exec['Deploy Code'],

    and these parameters to your exec resource,

    require => File['/var/tmp/deploy.tar'],
    refreshonly => true,

    will create the appropriate dependency. Basically, it makes sure the file resource must run before the exec. Puppet manifests do not run in a top down manner, do it's important to specify the order of resouces when necessary.

    --
    Peter
    On Aug 9, 2012, at 4:51 AM, duckegg01 wrote:

    Hi Peter

    I managed to get this working by have the cwd in place, but im interested in your point with regards to setting up the dependency any chance you can provide an example of this based on what I have at present.

    On Wednesday, August 8, 2012 5:29:06 PM UTC+1, pmbuko wrote:
    On Aug 8, 2012, at 5:40 AM, duckegg01 wrote:

    Hi

    I have wriiten a class to deploy a tra file and extract on a remote puppet client. The tar file gets copied across fine and it seems to puppet the thet tar extraction suceeds, but when I check the client I dont see the extracted files

    exec { "Deploy Code":
    command => "/bin/tar -xvf /var/tmp/deploy.tar",
    onlyif => [
    "/usr/bin/test -d /var/tmp/test/" #just testing this
    ]
    }
    I see two possible issues. First, you either need to give the exec resource a working directory via the 'cwd' parameter, or you need to use tar's -C option to specify where to extract the files. Without either of these, files will extract into the home of whichever user is running puppet. So either add this parameter:

    cwd => '/var/tmp/,

    or use this as your tar command ( -- # note that I skipped the verbose switch since it's not interactive):

    /bin/tar -xf /var/tmp/deploy.tar -C /var/tmp

    Another possible issue: If you want /var/tmp/deploy.tar to extract to /var/tmp/test, then you need to leave off the 'onlyif' parameter. Currently, the exec will only run if /var/tmp/test already exists.

    One last thing. If you haven't done so already, set up a dependency between the file resource that copies the tar file to the node and the exec resource that extracts it -- either via a notify parameter in the file resource or a require parameter in the exec resource.

    --
    Peter Bukowinski

    --
    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/-/gOIxni7fKGIJ.
    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 at Aug 10, 2012 at 1:04 pm

    On Thursday, August 9, 2012 7:24:23 AM UTC-5, pmbuko wrote:
    Adding this parameter to your file resource,

    notify => Exec['Deploy Code'],

    and these parameters to your exec resource,

    require => File['/var/tmp/deploy.tar'],
    refreshonly => true,

    will create the appropriate dependency. Basically, it makes sure the file
    resource must run before the exec. Puppet manifests do not run in a top
    down manner, do it's important to specify the order of resouces when
    necessary.
    Technically, either the 'notify' on one side or the 'require' on the other
    is sufficient to create a relationship, and 'refreshonly' is a tangential
    issue. I prefer to avoid specifying relationships redundantly, as it
    complicates maintenance. The Exec's relationship to the File is a true
    dependency, so I would express the relationship on that side.

    Inasmuch as it makes sense to deploy the code only when the tarball
    changes, 'refreshonly' is a good choice. In that case, I would use:

    In the File:
    # nothing special

    In the Exec:
    refreshonly => true,
    listen => File['/var/tmp/deploy.tar']

    Note also that if you're going to use this means to deploy code then you
    should probably put the tarball in a permanent location and plan on leaving
    it there. If you delete it after the deployment then Puppet will copy it
    back down (and trigger a new deployment) on its next run.


    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/-/opxR_-wVLWMJ.
    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.
  • Peter Bukowinski at Aug 10, 2012 at 3:23 pm

    On Aug 10, 2012, at 9:04 AM, jcbollinger wrote:



    On Thursday, August 9, 2012 7:24:23 AM UTC-5, pmbuko wrote:
    Adding this parameter to your file resource,

    notify => Exec['Deploy Code'],

    and these parameters to your exec resource,

    require => File['/var/tmp/deploy.tar'],
    refreshonly => true,

    will create the appropriate dependency. Basically, it makes sure the file resource must run before the exec. Puppet manifests do not run in a top down manner, do it's important to specify the order of resouces when necessary.

    Technically, either the 'notify' on one side or the 'require' on the other is sufficient to create a relationship, and 'refreshonly' is a tangential issue. I prefer to avoid specifying relationships redundantly, as it complicates maintenance. The Exec's relationship to the File is a true dependency, so I would express the relationship on that side.

    Inasmuch as it makes sense to deploy the code only when the tarball changes, 'refreshonly' is a good choice. In that case, I would use:

    In the File:
    # nothing special

    In the Exec:
    refreshonly => true,
    listen => File['/var/tmp/deploy.tar']

    Note also that if you're going to use this means to deploy code then you should probably put the tarball in a permanent location and plan on leaving it there. If you delete it after the deployment then Puppet will copy it back down (and trigger a new deployment) on its next run.


    John
    The listen parameter is new to me. Good to know!

    --
    Peter

    --
    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 at Aug 10, 2012 at 8:13 pm

    On Friday, August 10, 2012 10:23:16 AM UTC-5, pmbuko wrote:
    On Aug 10, 2012, at 9:04 AM, jcbollinger wrote:


    On Thursday, August 9, 2012 7:24:23 AM UTC-5, pmbuko wrote:

    Adding this parameter to your file resource,

    notify => Exec['Deploy Code'],

    and these parameters to your exec resource,

    require => File['/var/tmp/deploy.tar'],
    refreshonly => true,

    will create the appropriate dependency. Basically, it makes sure the
    file resource must run before the exec. Puppet manifests do not run in a
    top down manner, do it's important to specify the order of resouces when
    necessary.
    Technically, either the 'notify' on one side or the 'require' on the other
    is sufficient to create a relationship, and 'refreshonly' is a tangential
    issue. I prefer to avoid specifying relationships redundantly, as it
    complicates maintenance. The Exec's relationship to the File is a true
    dependency, so I would express the relationship on that side.

    Inasmuch as it makes sense to deploy the code only when the tarball
    changes, 'refreshonly' is a good choice. In that case, I would use:

    In the File:
    # nothing special

    In the Exec:
    refreshonly => true,
    listen => File['/var/tmp/deploy.tar']

    Note also that if you're going to use this means to deploy code then you
    should probably put the tarball in a permanent location and plan on leaving
    it there. If you delete it after the deployment then Puppet will copy it
    back down (and trigger a new deployment) on its next run.


    John


    The listen parameter is new to me. Good to know!

    It's new to me, too: I meant to say "subscribe". Sorry about that.


    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/-/yYnhIE7HA5AJ.
    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
postedAug 8, '12 at 3:59p
activeAug 10, '12 at 8:13p
posts7
users3
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase