rundeck / rundeck

Enable Self-Service Operations: Give specific users access to your existing tools, services, and scripts
http://rundeck.org
Apache License 2.0
5.55k stars 921 forks source link

only one script from a script-plugin is executable #5568

Closed gtudan closed 3 years ago

gtudan commented 4 years ago

Describe the bug If a Plugin contains more than one script-providers than not all get the executable flag. Executing those scripts will fail at runtime.

My Rundeck detail

To Reproduce Steps to reproduce the behavior:

  1. Create a plugin with more than one script-provider. This is my plugin meta data:
    
    # yaml plugin metadata

name: rundeck-ldap-options-plugin version: 1.0 rundeckPluginVersion: 1.2 author: Gregor Tudan date: 2019-10-05 providers:

Expected behavior All scripts are executable. The actual result is that only one of the scripts will have the executable flag (which one seems to be random).

[gtudan@rundeck rundeck-ldap-options-plugin]$ ls -l .
total 8
-rwxrw-r--. 1 rundeck rundeck 260 Nov 27 22:47 get-groups.sh
-rw-rw-r--. 1 rundeck rundeck 258 Nov 27 22:47 get-users.sh
drwxrwxr-x. 2 rundeck rundeck   6 Nov 27 22:47 resources
MegaDrive68k commented 4 years ago

Hi @gtudan

You're right. I see the same behavior:

Screenshot_3

helloworld-plugin.zip

plugin.yaml:

name: helloworld
version: 1.0
rundeckPluginVersion: 1.2
author: Warhawk
date: 01-02-2018 (ISO8601)
providers:
  - name: helloworld
    service: RemoteScriptNodeStep
    title: HELLOWORLD
    description: test of custom plugin
    plugin-type: script
    script-interpreter: /bin/bash
    script-file: hello.config
    script-args:
  - name: bye
    service: RemoteScriptNodeStep
    title: BYE
    description: another test of custom plugin
    plugin-type: script
    script-interpreter: /bin/bash
    script-file: bye.config
    script-args:

hello.config:

#!/usr/bin/env bash
echo "Hello World"

bye.config:

#!/usr/bin/env bash
echo "Bye"

Job Definition:

<joblist>
  <job>
    <defaultTab>nodes</defaultTab>
    <description></description>
    <executionEnabled>true</executionEnabled>
    <id>bd899c76-3daa-4d46-aae9-c92945542e80</id>
    <loglevel>INFO</loglevel>
    <name>PluginTest</name>
    <nodeFilterEditable>false</nodeFilterEditable>
    <scheduleEnabled>true</scheduleEnabled>
    <sequence keepgoing='false' strategy='node-first'>
      <command>
        <node-step-plugin type='helloworld' />
      </command>
      <command>
        <node-step-plugin type='bye' />
      </command>
    </sequence>
    <uuid>bd899c76-3daa-4d46-aae9-c92945542e80</uuid>
  </job>
</joblist>

But doesn't affect the execution:

Screenshot_1

Thanks for yout feedback!

gtudan commented 4 years ago

Hi Reiner,

Thanks for looking into this. I can share the script, but first I need to remove some project specifics from it.

I‘m pretty sure your example works because you set a script interpreter. This changes the execution behavior: not the script is executed, but the interpreter (with the script as argument). This is a good workaround but I‘m not sure if it‘s a fix in for every situation. Could you check if both scripts are executable in the cache dir?

Am 06.12.2019 um 15:06 schrieb Reiner notifications@github.com:

 Hi @gtudan

Can you share the script content? I leave an example that works.

helloworld-plugin.zip

plugin.yaml:

name: helloworld version: 1.0 rundeckPluginVersion: 1.2 author: Warhawk date: 01-02-2018 (ISO8601) providers:

  • name: helloworld service: RemoteScriptNodeStep title: HELLOWORLD description: test of custom plugin plugin-type: script script-interpreter: /bin/bash script-file: hello.config script-args:
  • name: bye service: RemoteScriptNodeStep title: BYE description: another test of custom plugin plugin-type: script script-interpreter: /bin/bash script-file: bye.config script-args: hello.config:

!/usr/bin/env bash

echo "Hello World" bye.config:

!/usr/bin/env bash

echo "Bye" Job Definition:

nodes true bd899c76-3daa-4d46-aae9-c92945542e80 INFO PluginTest false true bd899c76-3daa-4d46-aae9-c92945542e80

Hope it helps!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

niall-munnelly commented 4 years ago

What’s the umask on the target server?

IIRC, you can set a umask to whatever suits you in Rundeck’s etc/profile, but if that doesn’t do it, then you may need to do so at the OS level.

Sent from a mobile device. Typos and probably bad ideas.

On Dec 7, 2019, at 10:26 AM, Gregor Tudan notifications@github.com wrote:

Hi Reiner,

Thanks for looking into this. I can share the script, but first I need to remove some project specifics from it.

I‘m pretty sure your example works because you set a script interpreter. This changes the execution behavior: not the script is executed, but the interpreter (with the script as argument). This is a good workaround but I‘m not sure if it‘s a fix in for every situation. Could you check if both scripts are executable in the cache dir?

Am 06.12.2019 um 15:06 schrieb Reiner notifications@github.com:

 Hi @gtudan

Can you share the script content? I leave an example that works.

helloworld-plugin.zip

plugin.yaml:

name: helloworld version: 1.0 rundeckPluginVersion: 1.2 author: Warhawk date: 01-02-2018 (ISO8601) providers:

  • name: helloworld service: RemoteScriptNodeStep title: HELLOWORLD description: test of custom plugin plugin-type: script script-interpreter: /bin/bash script-file: hello.config script-args:
  • name: bye service: RemoteScriptNodeStep title: BYE description: another test of custom plugin plugin-type: script script-interpreter: /bin/bash script-file: bye.config script-args: hello.config:

!/usr/bin/env bash

echo "Hello World" bye.config:

!/usr/bin/env bash

echo "Bye" Job Definition:

nodes true bd899c76-3daa-4d46-aae9-c92945542e80 INFO PluginTest false true bd899c76-3daa-4d46-aae9-c92945542e80

Hope it helps!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

MegaDrive68k commented 4 years ago

Hi @gtudan

I changed my post and I see the same behavior.

Take a look:

https://github.com/rundeck/rundeck/issues/5568#issuecomment-562584375

gtudan commented 4 years ago

@MegaDrive68k Good to hear that it's reproducible. Execution still works because you defined an interpreter. Try removing it and see what happens.

Having an interpreter is a perfectly legit workaround for scripts, but won't work for binaries.

stale[bot] commented 3 years ago

In an effort to focus on bugs and issues that impact currently supported versions of Rundeck, we have elected to notify GitHub issue creators if their issue is classified as stale and close the issue. An issue is identified as stale when there have been no new comments, responses or other activity within the last 12 months. If a closed issue is still present please feel free to open a new Issue against the current version and we will review it. If you are an enterprise customer, please contact your Rundeck Support to assist in your request. Thank you, The Rundeck Team

gaddman commented 3 years ago

Confirming this is still an issue in version 3.3.12, and the suggested workaround (setting script-interpreter) works.