Ask Your Question
0

how to get a binary file to stop the install if exist

asked 2017-04-13 14:54:38 -0500

michaelzay gravatar image

updated 2017-04-13 14:55:26 -0500

I have a binary file to install called install.sh on the master under /data/binary, I need to fix my code to only install it if the file exist and want to have it only copy the file if the agent is not installed.

I am not sure how my onlyif should look like, as if now, if only check the file if exist but puppet the ensure already doing that.

1  class profile: epo {
  2
  3   file { '/tmp/install.sh':
  4     ensure => 'file',
  5     source => 'puppet:///binaries/install.sh',
  6     notify => Exec['somthing'],
  7  }
  8    exec { 'something':
  9     command     => '/tmp/install.sh',
 10     onlyif      => '/usr/bin/test -e /tmp/install.sh',,
11  }



  12 }
edit retag flag offensive close merge delete

Comments

What do you mean, are you saying you only want the exec statement to run once? Instead of onlyif use the creates parameter and point it at a log file or something of that sort that your script creates. That will make sure it only runs once.

UBPClaw gravatar imageUBPClaw ( 2017-04-13 18:44:04 -0500 )edit

I want it to check it as well not only install it once, so I might just add--> replace => 'no' and then with only if check the install package if exist

michaelzay gravatar imagemichaelzay ( 2017-04-14 09:08:55 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2017-04-14 09:11:42 -0500

michaelzay gravatar image
 1 class profile::epo {
  2
  3   file { '/tmp/install.sh':
  4     ensure  => 'present',
  5     replace => 'no',
  6     source  => 'puppet:///binaries/install.sh',
  7     notify  => Exec['abc'],
  8
  9 }
 10
 11    exec { 'abc':
 12      command     => '/tmp/install.sh',
 13      onlyif      => '/usr/bin/test -e /etc/see/if/package/installed',
 14  }

    enter code here
edit flag offensive delete link more
1

answered 2017-04-14 06:26:30 -0500

puser gravatar image

updated 2017-04-14 06:28:27 -0500

As UBPClaw suggested, use Creates: https://docs.puppet.com/puppet/latest...

This will only fire if the file that is in creates exists. For example

exec { '/usr/bin/touch /tmp/myfile':
 creates => '/tmp/myfile',
}

This creates the file /tmp/myfile and the creates variable looks for /tmp/myfile. If it exists it does not fire.

edit flag offensive delete link more

Comments

I want it to check it as well not only install it once, so I might just add--> replace => 'no' and then with only if check the install package if exist

michaelzay gravatar imagemichaelzay ( 2017-04-14 09:09:04 -0500 )edit

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: 2017-04-13 14:54:38 -0500

Seen: 34 times

Last updated: Apr 14