CentOS 7
Ads

Puppet : How to use [exec Resource]
2015/07/22
 
This is the exmaples for exec resource.
It is possible to execute any commands by using exec resource, but 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 "newaliases" when "/etc/aliases" is updated.
[root@dlp ~]#
vi /etc/puppet/manifests/site.pp
file { '/etc/aliases':
    ensure => file,
    owner  => 'root',
    group  => 'root',
    mode   => 644,
    source => 'puppet://dlp.srv.world/extra_files/aliases'
}

exec { 'newaliases':
    path        => ['/usr/bin', '/usr/sbin'],
    subscribe   => File['/etc/aliases'],
    refreshonly => true
}
 
Tweet