About | FAQ | Help
Ask Your Question

continuous struggle on exec commands

asked 2015-06-01 14:51:14 -0500

pup-master gravatar image

updated 2015-06-03 14:34:02 -0500

I've conquered Atlassian's Confluence and JIRA setup via puppet. Now I'm keep brain storming for fisheye/crucible.

[Update: new conditional exec statements]


    node 'agent.oracle' { class {'fishcruc':} }


class fishcruc (

  $version = '3.8.0',
  $extension = 'zip',
  $installdir = '/etc/ficr',
  $home = '/var/local/ficr',
  $user = 'oracle') {

  $srcdir = '/home/oracle/Downloads'
  include wget
  $dir = "${installdir}/fisheye-${version}"

    file { "/home/oracle/Downloads/jdk-8u45-linux-x64.rpm":
            owner => "oracle", 
            source => "puppet:///fs/jdk-8u45-linux-x64.rpm",

   exec { 'java': 
    command => 'yum -y install /home/oracle/Downloads/jdk-8u45-linux-x64.rpm',
    path => '/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin',
    cwd => $srcdir,
    logoutput => 'on_failure',
    unless => "yum -y install /home/oracle/Downloads/jdk-8u45-linux-x64.rpm ; echo $? -eq 0",
    } ->

   file { '/etc/environment':
    ensure  => file,
    content => "export JAVA_HOME=/usr/java/jdk1.8.0_45",
     } ~>

    file { "/etc/ficr":
        ensure => "directory",
        owner  => "oracle",
        mode   => 777,

    file { "/home/oracle/fisheye-3.8.0.zip":
            owner => "oracle", 
            source => "puppet:///fs/fisheye-3.8.0.zip",

  exec { 'ficr':
    command => 'tar zxvf /home/oracle/fisheye-3.8.0.zip && chown -R ${user} fisheye-3.8.0',
    creates => "${installdir}/fisheye-3.8.0",
    cwd     => $installdir,
    logoutput => "on_failure",
    path => '/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin',
    } ->

  exec { 'start':
    command => '/etc/ficr/fisheye-3.8.0/bin/start.sh',
    cwd => "$srcdir",
    path => '/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin',
    logoutput => "on_failure",

Can anyone think of any further improvement? to reflect the manual install.

[History of manual install]

  107  sudo rpm -Uvh jdk-8u45-linux-x64.rpm 
  108  sudo vim /etc/environment 
  109  cd fecru
  110  cd fecru-3.8.0/
  111  cd ..
  112  sudo chmod a+rwx fecru-3.8.0/
  113  cd fecru
  114  cd fecru-3.8.0/
  115  ls
  116  ls -la
  117  sudo chmod -R a+rwx fecru-3.8.0/
  118  sudo chmod -R a+rwx /fecru-3.8.0/
  119  cd ..
  120  sudo chmod -R a+rwx /fecru-3.8.0/
  121  sudo chmod -R a+rwx fecru-3.8.0/
  122  sudo gedit /etc/environment 
  123  pwd
  124  sudo ./start.sh 
  125  start.sh
  126  sudo chmod a+rwx start.sh 
  127  sudo ./start.sh 
  128  sudo vim /etc/sysconfig/iptables

[agent ~]$ sudo tail -50 /var/log/messages]

Jun  3 12:28:16 agent puppet-agent[7621]: (/Stage[main]/Fishcruc/Exec[ficr]/returns) gzip: stdin has more than one entry--rest ignored
Jun  3 12:28:16 agent puppet-agent[7621]: (/Stage[main]/Fishcruc/Exec[ficr]/returns) tar: Child returned status 2
Jun  3 12:28:16 agent puppet-agent[7621]: (/Stage[main]/Fishcruc/Exec[ficr]/returns) tar: Error is not recoverable: exiting now
Jun  3 12:28:16 agent puppet-agent[7621]: tar zxvf /home/oracle/fisheye-3.8.0.zip && chown -R ${user} fisheye-3.8.0 returned 2 instead of one of [0]
Jun  3 12:28:16 agent puppet-agent[7621]: (/Stage[main]/Fishcruc/Exec[ficr]/returns) change from notrun to 0 failed: tar zxvf /home/oracle/fisheye-3.8.0.zip && chown -R ${user} fisheye-3.8.0 returned 2 instead of one of [0]
Jun  3 12:28:16 agent puppet-agent[7621]: (/Stage[main]/Fishcruc/Exec[start]) Dependency Exec ...
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-06-01 19:12:01 -0500

ramindk gravatar image

updated 2015-06-02 12:16:34 -0500

Could not find command 'yum'

Full path for each command or set path in each Exec. I set it globally in site.pp

# global defaults
Exec {
  logoutput =>  on_failure,
  path      => '/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin',

However I would setup an internal Yum server which would take 2-3 hours tops. Then add the Java package to it. I'd also build RPM of Fisheye/Cruciable and whatever else which shouldn't take more than 2-3 to get a build server, mock, rpmbuild, etc up and running. Less time if you just use FPM to make the RPMs since they're just a set of files rather than needing to build a binary.

Again if you read the errors your problem become apparent.

Jun 1 21:46:04 agent puppet-agent[6453]: (/Stage[main]/Fishcruc/Exec[java]/returns) Examining jdk-8u45-linux-x64.rpm: 2000:jdk1.8.045-1.8.045-fcs.x86_64 Jun 1 21:46:04 agent puppet-agent[6453]: (/Stage[main]/Fishcruc/Exec[java]/returns) jdk-8u45-linux-x64.rpm: does not update installed package. Jun 1 21:46:04 agent puppet-agent[6453]: (/Stage[main]/Fishcruc/Exec[java]/returns) Error: Nothing to do Jun 1 21:46:04 agent puppet-agent[6453]: /usr/bin/yum -y install jdk-8u45-linux-x64.rpm returned 1 instead of one of [0]

You can test the above yourself by running the same command.

yum -y install jdk-8u45-linux-x64.rpm ; echo $?

If the RPM is already installed you'll get an exit code of 1 just like your error says. You'll need to use unless => or only => statement to make sure that Exec only runs when it needs to.

edit flag offensive delete link more


(1) so you set this in site.pp along with the node definition? or in fishcru.pp? (2) Can i just get away with it using "rpm -Uvh" instead of "yum?"

pup-master gravatar imagepup-master ( 2015-06-01 22:39:51 -0500 )edit

Thanks for your time. Updated the post. But still similar errors. hmmm What am I doing wrong?

pup-master gravatar imagepup-master ( 2015-06-01 22:53:03 -0500 )edit

you have use the full path to the command you're calling. /usr/bin/yum or whatever unless you set path =>

ramindk gravatar imageramindk ( 2015-06-01 23:20:52 -0500 )edit

also post the actual errors and logs. Your updates are useless if you tell us about the errors instead of pasting them.

ramindk gravatar imageramindk ( 2015-06-01 23:21:57 -0500 )edit

"sudo cat /var/log/messages?"

pup-master gravatar imagepup-master ( 2015-06-01 23:49:29 -0500 )edit

answered 2015-06-02 08:01:03 -0500

slk gravatar image

You should, ideally, put that rpm into a private 'in-house' repo. If that is not available switch to using 'yum' instead of 'rpm'.

edit flag offensive delete link more


my rpm is puppet-master's fileserver that is mounted. How can I use either rpm or yum correctly without having to setup my own repo? Thanks.

pup-master gravatar imagepup-master ( 2015-06-02 10:00:47 -0500 )edit

for your SELinux issue : just do what the error says `` run sealert -l 68241e37-0b5e-4498-b540-d4b0fd126f01 `` or just disable the cursed thing. as for yum install. looking at your updated code. you're doing it right. but i would really recommend setting up a private repo !

slk gravatar imageslk ( 2015-06-02 10:19:12 -0500 )edit

Thanks! Also, did I find and post the relevant error logs that "ramindk" pointed out?

pup-master gravatar imagepup-master ( 2015-06-02 12:00:08 -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


Asked: 2015-06-01 14:51:14 -0500

Seen: 1,190 times

Last updated: Jun 03 '15