Ask Your Question
0

How can I use file created dynamically due to an exec as a file resource to trigger a service notify?

asked 2015-03-03 16:48:35 -0500

cjcox gravatar image

updated 2015-04-05 06:40:21 -0500

If I have an exec resource that "creates" a file... how can I then use that file to do a notify to a service but only when the content of the file has changed?

edit retag flag offensive close merge delete

Comments

Can you post a link to a pastebin of your code somewhere for review? There may be a better way to achieve your goal without using an exec resource.

GregLarkin gravatar imageGregLarkin ( 2015-03-04 19:26:00 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-04-03 17:37:01 -0500

updated 2015-04-05 06:41:06 -0500

You're looking for the audit-meta-attribute.

A service doesn't have a refreshonly-attribute. So you have to work around.

  exec { 'randomfile':
    command => '/bin/bash -c '/bin/echo $((${RANDOM}%5)) > /home/lu/r'
  }

  Exec['randomfile'] -> File['/home/lu/r']

  file { '/home/lu/r':
    audit => 'content',
  }

  File['/home/lu/r'] ~> Exec['tea_service']

  exec { 'tea_service':
    command     => '/etc/init.d/tea_service start',
    unless      => '/etc/init.d/tea_service status | /bin/grep -q '^ \* tea_service is running$',
    refreshonly => true,
  }

(not tested)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-03-03 16:48:35 -0500

Seen: 509 times

Last updated: Apr 05 '15