Ubuntu 22.04
Sponsored Link

Puppet : How to use [exec Resource]2023/10/12


This is the examples for [exec] resource.

It is possible to execute any commands by using [exec] resource, however it is not recommended because it is critical. So use this resource for specific case like when it receives events by using the refreshonly parameter.

[1] It executes [echo "copy test2.txt" | tee /home/copy-test2.txt] only when [/home/test2.txt] is updated.
vi /etc/puppetlabs/code/environments/production/manifests/cmd01.pp
file { '/home/test2.txt':
  ensure => file,
  owner  => 'root',
  group  => 'root',
  mode   => '0644',
    source => 'puppet://dlp.srv.world/extra_files/test2.txt'

exec { 'echo "copy test2.txt" | tee /home/copy-test2.txt':
  path        => ['/usr/bin', '/usr/sbin'],
  subscribe   => File['/home/test2.txt'],
  refreshonly => true
Matched Content