FAQ
I would like to place a file with puppet only if a certain package is
installed on the system -- but assuming this package is not puppet-managed.
Checking for the presence of a non-puppet-managed file is also ok. Is this
possible? using require => Package['mypkg'] doesn't work if it's not
puppet-managed. 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/-/l4_dq40ii4UJ.
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

  • Axel Bock at Sep 24, 2012 at 1:03 pm
    if the package is in under the management of the system's package manager
    it should not matter whether it is puppet-"managed". puppet checks for the
    presence of the package in the system,and then fails if it's not there and
    can't install it.

    and you can always go with an exec{} resource, which has an "unless" /
    "onlyif" parameter with a "test -f" for example.


    HTH,
    Axel.


    Am Samstag, 22. September 2012 02:40:52 UTC+2 schrieb Justin Ryan:
    I would like to place a file with puppet only if a certain package is
    installed on the system -- but assuming this package is not puppet-managed.
    Checking for the presence of a non-puppet-managed file is also ok. Is this
    possible? using require => Package['mypkg'] doesn't work if it's not
    puppet-managed. 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/-/HfISq1qMDO0J.
    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 Sep 24, 2012 at 2:26 pm

    On Friday, September 21, 2012 7:40:52 PM UTC-5, Justin Ryan wrote:
    I would like to place a file with puppet only if a certain package is
    installed on the system -- but assuming this package is not puppet-managed.
    Checking for the presence of a non-puppet-managed file is also ok. Is this
    possible? using require => Package['mypkg'] doesn't work if it's not
    puppet-managed. thanks.


    For those details where you want Puppet to adapt to the client node instead
    of managing it to a known state, your first recourse should be node facts.
    Puppet and Facter don't provide built-in facts describing whether
    particular packages are installed, but it's pretty easy to write custom
    facts and distribute them via Puppet's 'pluginsync' mechanism. See, for
    example, http://docs.puppetlabs.com/guides/custom_facts.html.

    Supposing that you create a custom fact 'mypkg_installed', you could then
    use something like this in your manifest:

    if $::mypkg_installed == 'yes' {
    file { '/etc/mypkg/special-file':
    # ...
    }
    }

    (Note that that does not force the file absent if the package is not
    installed; that's certainly possible, but I leave it as an exercise.)


    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/-/qqjyuCuV94AJ.
    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.
  • Justin Ryan at Sep 24, 2012 at 7:20 pm
    Thanks John, that's exactly what I'm looking for, but am having trouble
    getting it to work. I read the Custom Facts<http://docs.puppetlabs.com/guides/custom_facts.html>and Plugins
    in Modules <http://docs.puppetlabs.com/guides/plugins_in_modules.html> docs,
    and:

    added pluginsync = true to puppet.conf on the puppetmaster and restarted
    the service:

    [root@puppet01 facter]# puppet config print all |grep pluginsync
    pluginsync = true

    added my custom fact to {module}/lib/facter/pgsql_pkg.rb:

    Facter.add("pgsql_pkg") do
    setcode do
    Facter::Util::Resolution.exec("echo itworks")
    end
    end

    but then after doing a puppet run on the client, it does not appear in the
    output of facter [-p]. I do see the script has synced to
    /var/lib/puppet/facts on the client.

    any ideas? thanks.


    On Monday, September 24, 2012 7:21:04 AM UTC-7, jcbollinger wrote:


    On Friday, September 21, 2012 7:40:52 PM UTC-5, Justin Ryan wrote:

    I would like to place a file with puppet only if a certain package is
    installed on the system -- but assuming this package is not puppet-managed.
    Checking for the presence of a non-puppet-managed file is also ok. Is this
    possible? using require => Package['mypkg'] doesn't work if it's not
    puppet-managed. thanks.


    For those details where you want Puppet to adapt to the client node
    instead of managing it to a known state, your first recourse should be node
    facts. Puppet and Facter don't provide built-in facts describing whether
    particular packages are installed, but it's pretty easy to write custom
    facts and distribute them via Puppet's 'pluginsync' mechanism. See, for
    example, http://docs.puppetlabs.com/guides/custom_facts.html.

    Supposing that you create a custom fact 'mypkg_installed', you could then
    use something like this in your manifest:

    if $::mypkg_installed == 'yes' {
    file { '/etc/mypkg/special-file':
    # ...
    }
    }

    (Note that that does not force the file absent if the package is not
    installed; that's certainly possible, but I leave it as an exercise.)


    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/-/zqt-maq6PNIJ.
    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.
  • Justin Ryan at Sep 24, 2012 at 7:43 pm
    also, as suggested in the *Pro Puppet* book, I:


    - copied the ruby file to ~/lib/ruby/facter/
    - export RUBYLIB=~/lib/ruby
    - facter pgsql_pkg
    - it printed "itworks" as expected.


    I'm running puppet 2.7.18 on the master and 2.7.19 on the client, all are
    CentOS 6.
    On Monday, September 24, 2012 12:20:07 PM UTC-7, Justin Ryan wrote:

    Thanks John, that's exactly what I'm looking for, but am having trouble
    getting it to work. I read the Custom Facts<http://docs.puppetlabs.com/guides/custom_facts.html>and Plugins
    in Modules <http://docs.puppetlabs.com/guides/plugins_in_modules.html> docs,
    and:

    added pluginsync = true to puppet.conf on the puppetmaster and restarted
    the service:

    [root@puppet01 facter]# puppet config print all |grep pluginsync
    pluginsync = true

    added my custom fact to {module}/lib/facter/pgsql_pkg.rb:

    Facter.add("pgsql_pkg") do
    setcode do
    Facter::Util::Resolution.exec("echo itworks")
    end
    end

    but then after doing a puppet run on the client, it does not appear in the
    output of facter [-p]. I do see the script has synced to
    /var/lib/puppet/facts on the client.

    any ideas? thanks.


    On Monday, September 24, 2012 7:21:04 AM UTC-7, jcbollinger wrote:


    On Friday, September 21, 2012 7:40:52 PM UTC-5, Justin Ryan wrote:

    I would like to place a file with puppet only if a certain package is
    installed on the system -- but assuming this package is not puppet-managed.
    Checking for the presence of a non-puppet-managed file is also ok. Is this
    possible? using require => Package['mypkg'] doesn't work if it's not
    puppet-managed. thanks.


    For those details where you want Puppet to adapt to the client node
    instead of managing it to a known state, your first recourse should be node
    facts. Puppet and Facter don't provide built-in facts describing whether
    particular packages are installed, but it's pretty easy to write custom
    facts and distribute them via Puppet's 'pluginsync' mechanism. See, for
    example, http://docs.puppetlabs.com/guides/custom_facts.html.

    Supposing that you create a custom fact 'mypkg_installed', you could then
    use something like this in your manifest:

    if $::mypkg_installed == 'yes' {
    file { '/etc/mypkg/special-file':
    # ...
    }
    }

    (Note that that does not force the file absent if the package is not
    installed; that's certainly possible, but I leave it as an exercise.)


    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/-/8tNtLRR_67AJ.
    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.
  • Justin Ryan at Sep 24, 2012 at 8:13 pm
    and interestingly, I see this when running puppet on the client:

    info: Loading facts in /var/lib/puppet/facts/pgsql_pkg.rb

    but it still doesn't appear in the output of `facter` or `facter -p`
    On Monday, September 24, 2012 12:35:39 PM UTC-7, Justin Ryan wrote:

    also, as suggested in the *Pro Puppet* book, I:


    - copied the ruby file to ~/lib/ruby/facter/
    - export RUBYLIB=~/lib/ruby
    - facter pgsql_pkg
    - it printed "itworks" as expected.


    I'm running puppet 2.7.18 on the master and 2.7.19 on the client, all are
    CentOS 6.
    On Monday, September 24, 2012 12:20:07 PM UTC-7, Justin Ryan wrote:

    Thanks John, that's exactly what I'm looking for, but am having trouble
    getting it to work. I read the Custom Facts<http://docs.puppetlabs.com/guides/custom_facts.html>and Plugins
    in Modules <http://docs.puppetlabs.com/guides/plugins_in_modules.html> docs,
    and:

    added pluginsync = true to puppet.conf on the puppetmaster and restarted
    the service:

    [root@puppet01 facter]# puppet config print all |grep pluginsync
    pluginsync = true

    added my custom fact to {module}/lib/facter/pgsql_pkg.rb:

    Facter.add("pgsql_pkg") do
    setcode do
    Facter::Util::Resolution.exec("echo itworks")
    end
    end

    but then after doing a puppet run on the client, it does not appear in
    the output of facter [-p]. I do see the script has synced to
    /var/lib/puppet/facts on the client.

    any ideas? thanks.


    On Monday, September 24, 2012 7:21:04 AM UTC-7, jcbollinger wrote:


    On Friday, September 21, 2012 7:40:52 PM UTC-5, Justin Ryan wrote:

    I would like to place a file with puppet only if a certain package is
    installed on the system -- but assuming this package is not puppet-managed.
    Checking for the presence of a non-puppet-managed file is also ok. Is this
    possible? using require => Package['mypkg'] doesn't work if it's not
    puppet-managed. thanks.


    For those details where you want Puppet to adapt to the client node
    instead of managing it to a known state, your first recourse should be node
    facts. Puppet and Facter don't provide built-in facts describing whether
    particular packages are installed, but it's pretty easy to write custom
    facts and distribute them via Puppet's 'pluginsync' mechanism. See, for
    example, http://docs.puppetlabs.com/guides/custom_facts.html.

    Supposing that you create a custom fact 'mypkg_installed', you could
    then use something like this in your manifest:

    if $::mypkg_installed == 'yes' {
    file { '/etc/mypkg/special-file':
    # ...
    }
    }

    (Note that that does not force the file absent if the package is not
    installed; that's certainly possible, but I leave it as an exercise.)


    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/-/J-t-9XqfxoAJ.
    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.
  • Justin Ryan at Sep 25, 2012 at 12:33 am
    I figured it out, pluginsync = true needs to be added to puppet.conf [main]
    on both master and client. Also good to note, if the output of the custom
    fact script is empty, the fact will not appear at all.
    On Monday, September 24, 2012 12:35:39 PM UTC-7, Justin Ryan wrote:

    also, as suggested in the *Pro Puppet* book, I:


    - copied the ruby file to ~/lib/ruby/facter/
    - export RUBYLIB=~/lib/ruby
    - facter pgsql_pkg
    - it printed "itworks" as expected.


    I'm running puppet 2.7.18 on the master and 2.7.19 on the client, all are
    CentOS 6.
    On Monday, September 24, 2012 12:20:07 PM UTC-7, Justin Ryan wrote:

    Thanks John, that's exactly what I'm looking for, but am having trouble
    getting it to work. I read the Custom Facts<http://docs.puppetlabs.com/guides/custom_facts.html>and Plugins
    in Modules <http://docs.puppetlabs.com/guides/plugins_in_modules.html> docs,
    and:

    added pluginsync = true to puppet.conf on the puppetmaster and restarted
    the service:

    [root@puppet01 facter]# puppet config print all |grep pluginsync
    pluginsync = true

    added my custom fact to {module}/lib/facter/pgsql_pkg.rb:

    Facter.add("pgsql_pkg") do
    setcode do
    Facter::Util::Resolution.exec("echo itworks")
    end
    end

    but then after doing a puppet run on the client, it does not appear in
    the output of facter [-p]. I do see the script has synced to
    /var/lib/puppet/facts on the client.

    any ideas? thanks.


    On Monday, September 24, 2012 7:21:04 AM UTC-7, jcbollinger wrote:


    On Friday, September 21, 2012 7:40:52 PM UTC-5, Justin Ryan wrote:

    I would like to place a file with puppet only if a certain package is
    installed on the system -- but assuming this package is not puppet-managed.
    Checking for the presence of a non-puppet-managed file is also ok. Is this
    possible? using require => Package['mypkg'] doesn't work if it's not
    puppet-managed. thanks.


    For those details where you want Puppet to adapt to the client node
    instead of managing it to a known state, your first recourse should be node
    facts. Puppet and Facter don't provide built-in facts describing whether
    particular packages are installed, but it's pretty easy to write custom
    facts and distribute them via Puppet's 'pluginsync' mechanism. See, for
    example, http://docs.puppetlabs.com/guides/custom_facts.html.

    Supposing that you create a custom fact 'mypkg_installed', you could
    then use something like this in your manifest:

    if $::mypkg_installed == 'yes' {
    file { '/etc/mypkg/special-file':
    # ...
    }
    }

    (Note that that does not force the file absent if the package is not
    installed; that's certainly possible, but I leave it as an exercise.)


    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/-/i6pUMLvbodEJ.
    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.
  • Stefan Schulte at Sep 27, 2012 at 1:18 am

    On Fri, Sep 21, 2012 at 05:40:52PM -0700, Justin Ryan wrote:
    I would like to place a file with puppet only if a certain package is
    installed on the system -- but assuming this package is not puppet-managed.
    Checking for the presence of a non-puppet-managed file is also ok. Is this
    possible? using require => Package['mypkg'] doesn't work if it's not
    puppet-managed. thanks.
    I haven't tried it but

    package { 'mypkg':
    audit => all,
    }

    should work. This way you are declaring the resource so you should be
    able to refer to it later as Package['mypkg'] while on the other hand
    only auditing the state and not actually changing it through puppet.

    -Stefan

    --
    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 Sep 27, 2012 at 12:58 pm

    On Wednesday, September 26, 2012 8:18:51 PM UTC-5, Stefan Schulte wrote:
    On Fri, Sep 21, 2012 at 05:40:52PM -0700, Justin Ryan wrote:
    I would like to place a file with puppet only if a certain package is
    installed on the system -- but assuming this package is not
    puppet-managed.
    Checking for the presence of a non-puppet-managed file is also ok. Is this
    possible? using require => Package['mypkg'] doesn't work if it's not
    puppet-managed. thanks.
    I haven't tried it but

    package { 'mypkg':
    audit => all,
    }

    should work. This way you are declaring the resource so you should be
    able to refer to it later as Package['mypkg'] while on the other hand
    only auditing the state and not actually changing it through puppet.
    That's actually kinda cool, but I think either you've missed the OP's
    point, or I'm missing yours. Declaring the package for only auditing
    should indeed support any Puppet relationships with that resource without
    forcing the package to be installed, but how does it achieve the main
    objective of conditionally managing a file depending on whether the package
    is installed? As far as I can tell, relationships in general cannot
    address this problem. Am I missing something?


    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/-/Ol-CLuQnkj8J.
    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.
  • Stefan Schulte at Sep 28, 2012 at 5:32 am

    On Thu, Sep 27, 2012 at 05:58:34AM -0700, jcbollinger wrote:
    That's actually kinda cool, but I think either you've missed the OP's
    point, or I'm missing yours. Declaring the package for only auditing
    should indeed support any Puppet relationships with that resource without
    forcing the package to be installed, but how does it achieve the main
    objective of conditionally managing a file depending on whether the package
    is installed? As far as I can tell, relationships in general cannot
    address this problem. Am I missing something?


    John
    Nope, I did not read the question carefully enough. So as you already
    mentioned a custom fact should do the trick.

    But it general determining the desired state (that's what puppet tries
    to enforce) by looking at the current state (is the package installed?)
    may not be the best design here. So why not finding out when the package
    needs to be installed (e.g. because application X needs mysql) and then
    enforce that rule by puppet?

    -Stefan

    --
    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 Sep 28, 2012 at 1:19 pm

    On Friday, September 28, 2012 12:05:03 AM UTC-5, Stefan Schulte wrote:
    But it general determining the desired state (that's what puppet tries
    to enforce) by looking at the current state (is the package installed?)
    may not be the best design here. So why not finding out when the package
    needs to be installed (e.g. because application X needs mysql) and then
    enforce that rule by puppet?
    I agree. Where it can do so, it is usually better for Puppet to command
    than to inquire.

    A situation such as the OP's, where Puppet has the power to command but you
    don't want to use it, often signals disorganized or conflicting
    administration of the affected system. That is, if the person writing the
    Puppet manifests knows whether the package is supposed to be installed,
    then it is better all-around to just manage it. If he does *not* know,
    then that's either because someone else is responsible (and doesn't / won't
    share -- an administration conflict), or because the information is just
    not recorded (i.e. disorganized administration).

    In fairness, both situations are fairly common, and the second, especially,
    is a hallmark of sites that do not (yet) use an automated configuration
    management system.


    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/-/dGJ5_cFPu8YJ.
    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
postedSep 23, '12 at 11:11p
activeSep 28, '12 at 1:19p
posts11
users4
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase