Ask Your Question
0

Error: Could not execute posix command: Exec format error

asked 2014-04-16 19:09:38 -0500

spuder gravatar image

updated 2014-04-18 10:28:33 -0500

I have the following manifest

class  ac_redis_6390 {

# Set the file name to download from foo.bar
  $redis_6390_version = $::osfamily ? {
    'RedHat' => 'redis-6390-2.8.8-1.x86_64.rpm',
    'Debian' => 'redis-6390_2.8.8_amd64.deb',
  }
  $server_location = 'http://foo.bar/redis'

# Download rpm/deb 
  exec { 'wget redis':
    command   => "/usr/bin/wget http://foo.bar/redis/${redis_6390_version} -O /tmp/${redis_6390_version}",
    creates   => "/tmp/${redis_6390_version}",
    before    => Package["${redis_6390_version}"],
  }

# Install redis 
  case $::osfamily {
    RedHat:{
          package {"${redis_6390_version}":
            ensure    => latest,
            source    => "/tmp/${redis_6390_version}",
            name      => 'redis-6390-2.8.8-1.x86_64',
            #name     => "${redis_6390_version}",
            provider  => 'rpm',
          }
    }
    Debian:{
          package {"${redis_6390_version}":
            ensure    => latest,
            source    => "/tmp/${redis_6390_version}",
            #name      => 'redis-6390-2.8.8-1.x86_64',
            #name     => "${redis_6390_version}",
            provider  => 'dpkg',
          }
    }
    default:{
        fail("${::osfamily} not supported yet")
    }
}


# Make sure redis is running
  service { 'redis_6390':
    name       => 'redis_6390',
    hasstatus  => false,
    hasrestart => false,
    ensure     => running,
    require    => [ Package["${redis_6390_version}"], Exec['wget redis'] ]
  }


}

On Redhat machines, redis installs and starts properly. On Ubuntu machines, it gives the following error:

Info: Applying configuration version '1397692981'
Debug: Prefetching dpkg resources for package
Debug: Executing '/usr/bin/dpkg-query -W --showformat '${Status} ${Package} ${Version}\n''
Debug: Executing '/usr/bin/dpkg-query -W --showformat '${Status} ${Package} ${Version}\n' redis-6390_2.8.8_amd64.deb'
Debug: Executing 'dpkg --set-selections'
Debug: Executing '/usr/bin/dpkg --force-confold -i /tmp/redis-6390_2.8.8_amd64.deb'
Notice: /Stage[main]/Ac_redis_6390/Package[redis-6390_2.8.8_amd64.deb]/ensure: ensure changed 'purged' to 'latest'
Debug: /Stage[main]/Ac_redis_6390/Package[redis-6390_2.8.8_amd64.deb]: The container Class[Ac_redis_6390] will propagate my refresh event
Debug: Service[redis_6390](provider=upstart): Could not find redis_6390.conf in /etc/init
Debug: Service[redis_6390](provider=upstart): Could not find redis_6390.conf in /etc/init.d
Debug: Service[redis_6390](provider=upstart): Could not find redis_6390 in /etc/init
Debug: Service[redis_6390](provider=upstart): Executing 'ps -ef'
Debug: Executing '/etc/init.d/redis_6390 start'
Error: Could not start Service[redis_6390]: Execution of '/etc/init.d/redis_6390 start' returned 1: Error: Could not execute posix command: Exec format error - /etc/init.d/redis_6390
Wrapped exception:
Execution of '/etc/init.d/redis_6390 start' returned 1: Error: Could not execute posix command: Exec format error - /etc/init.d/redis_6390
Error: /Stage[main]/Ac_redis_6390/Service[redis_6390]/ensure: change from stopped to running failed: Could not start Service[redis_6390]: Execution of '/etc/init.d/redis_6390 start' returned 1: Error: Could not execute posix command: Exec format error - /etc/init.d/redis_6390
Debug: Class[Ac_redis_6390]: The container Stage[main] will propagate my refresh event
Debug: Finishing transaction 70151343367120
Debug: Storing state
Debug: Stored state in 0.02 seconds
Notice: Finished catalog run in 1.94 seconds

When I manually execute /etc/init.d/redis_6390 redis starts properly with no error codes

root@foosball:~# /etc/init.d/redis_6390 start; echo $?
Starting Redis server...
0
root@foosball:/etc/redis# ps aux |grep redis
root     22959  0.1  0.3  40224  1988 ?        Ssl  16:08   0:00 /bin/redis-server *:6390
root     22965  0.0  0.1  11688   928 pts/0    S+   16:08   0:00 grep --color=auto redis

Why is puppet unable to start the service?

Error: Could not execute posix command: Exec format error

Update

I've tried this on 3 machines ... (more)

edit retag flag offensive close merge delete

Comments

1

try execute manually /etc/init.d/redis_6390 start and show us the output of the command echo $? , because that seems that the script is returning 1 instead 0 for some reason.

Renan Vicente gravatar imageRenan Vicente ( 2014-04-16 21:49:42 -0500 )edit

@Renan Vicente, I've updated the question showing the output of echo $?

spuder gravatar imagespuder ( 2014-04-17 11:09:48 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
1

answered 2014-05-13 21:13:50 -0500

spuder gravatar image

While I never did figure out exactly why this puppet module returned this error, I narrowed it down to a poorly written init script.

I've since scraped this rpm / deb and instead use augeas to manage the init scipt provided by epel / universe packages.

edit flag offensive delete link more
1

answered 2015-05-13 04:01:02 -0500

Philluminati gravatar image

I got this error in one of my scripts and the fix turned out to just be adding the shebang line

#!/bin/bash

to the top of the script file.

edit flag offensive delete link more

Comments

Saved my life man

amirb gravatar imageamirb ( 2016-01-18 05:12:51 -0500 )edit
1

answered 2014-04-18 03:29:13 -0500

doc75 gravatar image

Are you sure that your puppet agent is run as root user ?

It might explain why manually it works but not with puppet.

Hope this helps.

edit flag offensive delete link more

Comments

Good thought, I've updated the question with the results.

spuder gravatar imagespuder ( 2014-04-18 10:28:49 -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: 2014-04-16 19:09:38 -0500

Seen: 1,972 times

Last updated: May 13 '15