exec resource applied on every run

44 views
Skip to first unread message

Tim Dunphy

unread,
Mar 6, 2015, 6:30:42 PM3/6/15
to puppet...@googlegroups.com
Hey all,

 I've created a very basic puppet module to install bacula and ensure that it's running. However one exec statement in my manifest gets applied every time.

Here's the manifest:

class bacula::install {

   if $hostname == "ops" {

      file { "/var/bacula":
      ensure => directory,
      }

      file {"/backup/tapes":
        ensure => directory,
      }

      package { ["bacula-client", "bacula-common", "bacula-storage", "bacula-libs", "bacula-libs-sql", "bacula-director", "bacula-console"] :
      ensure => present,
      require => [ File["/var/bacula"], File["/backup/tapes"]]
      }

     exec { "update_mysql_alternatives":
     command => "alternatives --set libbaccats.so /usr/lib64/libbaccats-mysql.so",
     path    => "/usr/local/bin/:/bin/:/usr/sbin"
     }

  } else {
      package { ["bacula-client", "bacula-common"] :
      ensure => present,
      require => [ File["/var/bacula"], File["/backup/tapes"]]
      }
  }
}


Seems pretty straight forward. But how can I get the exec command to run only once if it hasn't been run previously? 

Thanks!
Tim

Thanks

--
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

Brian Mathis

unread,
Mar 7, 2015, 12:41:22 AM3/7/15
to puppet-users
Hi Tim,

The exec type has some attributes that can control this, such as "onlyif", "unless", and "creates".

Please review the documentation here:
    https://docs.puppetlabs.com/references/latest/type.html#exec


❧ Brian Mathis
@orev


--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAOZy0enBbzZCq5U%2B81fGGXPcNcuGDXcsHqtizDUcavheCaOJVQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Tim Dunphy

unread,
Mar 7, 2015, 8:07:34 AM3/7/15
to puppet...@googlegroups.com
Hi Brian,

Ok, excellent. Thank you for your reply. I'll check out the link you sent!

Thanks,
Tim

Sent from my iPhone
Reply all
Reply to author
Forward
0 new messages