diff --git a/cdist/exec/local.py b/cdist/exec/local.py index e078dbd2..d30bc146 100644 --- a/cdist/exec/local.py +++ b/cdist/exec/local.py @@ -237,8 +237,14 @@ class Local(object): Return the output as a string. """ - command = [os.environ.get('CDIST_LOCAL_SHELL', "/bin/sh"), "-e"] - command.append(script) + if os.access(script, os.X_OK): + self.log.debug('%s is executable, running it', script) + command=[script] + else: + command = [os.environ.get('CDIST_LOCAL_SHELL', "/bin/sh"), "-e"] + self.log.debug('%s is NOT executable, running it with %s', + script, " ".join(command)) + command.append(script) return self.run(command=command, env=env, return_output=return_output, message_prefix=message_prefix, save_output=save_output) diff --git a/docs/src/cdist-type.rst b/docs/src/cdist-type.rst index 2c5f9f6a..59423332 100644 --- a/docs/src/cdist-type.rst +++ b/docs/src/cdist-type.rst @@ -79,6 +79,12 @@ two underscores (__) to prevent collisions with other executables in $PATH. To implement a new type, create the directory **cdist/conf/type/__NAME**. +Type manifest and gencode can be written in any language. They just need to be +executable and have a proper shebang. If they are not executable then cdist assumes +they are written in shell so they are executed using '/bin/sh -e' or 'CDIST_LOCAL_SHELL'. + +For executable shell code it is suggested that shebang is '#!/bin/sh -e'. + Defining parameters -------------------