0

I have a problem when I execute commands with some special characters like | on remote nodes. For instance, if I run ls /var/log/ | grep rundeck locally, the result is correct as shown in command_locally, whereas in a node the error that appears in command_remotely occurs (this node also has Rundeck installed and the folder 'rundeck' exists, so the command should work).

I face the same issue when I create a global log filter such as Key Value Data. I want to get the shell that is being used, so I create a job with a Key Value Data, then I add a first step which consists in running the command env, and a second one, echo 'SHELL is "${data.SHELL}"', to show the variable that I obtained from the log (example extracted from here). It works perfectly in localhost but it does not capture any data when a remote node is selected. This can be seen in Key_Value_Data_locally and Key_Value_Data_remotely respectively.

I would like to know if this is a bug or it is me that I am doing something wrong when it comes to executing something remotely. I use the Ansible plugin for Rundeck, could it be something related to that?

EDIT 1 WITH JOB DEFINITIONS:

Job with command. Locally works, remotely fails.

- defaultTab: output
  description: ''
  executionEnabled: true
  id: 4e10310c-b5e2-419e-a828-1ed7df4840e9
  loglevel: INFO
  name: Command_problem
  nodeFilterEditable: false
  scheduleEnabled: true
  sequence:
    commands:
    - exec: ls /etc | grep yum
    keepgoing: false
    strategy: node-first
  uuid: 4e10310c-b5e2-419e-a828-1ed7df4840e9

Job with Key Value Data. Locally works, remotely does not capture any data.

- defaultTab: output
  description: ''
  executionEnabled: true
  id: 1da43d9b-691d-437b-882e-8fbee2790c73
  loglevel: INFO
  name: Key_Value_Data_problem
  nodeFilterEditable: false
  scheduleEnabled: true
  sequence:
    commands:
    - exec: env
    - exec: ' echo ''SHELL is "${data.SHELL}"'''
    keepgoing: false
    pluginConfig:
      LogFilter:
      - config:
          logData: 'false'
          regex: ^(SHELL|USER|PWD)\s*=\s*(.+)$
        type: key-value-data
    strategy: node-first
  uuid: 1da43d9b-691d-437b-882e-8fbee2790c73

EDIT 2 WITH JOB OUTPUT ON DEBUG MODE:

I have changed the ip of the Rundeck machine and the node for 'localhost' and 'node ip' respectively, and the real username for 'user name'.

Command problem: output on debug mode

Key Value Data problem: output on debug mode

EDIT 3:

I have figured out what the problem was. It is the line force_color = 1 that I added to the ansible.cfg file to get colorful output in Rundeck. If I remove that part, the Key Value Data feature works perfectly on remotes nodes as well. I guess it is a bug.

Rendan
  • 11
  • 3

1 Answers1

0

About the first issue seems an Ansible plugin bug, I opened an Issue here to follow up:

https://github.com/Batix/rundeck-ansible-plugin/issues/255

About the second issue I did an example that works, take a look, just change the "dispatch to nodes" to your nodes:

    <joblist>
      <job>
        <defaultTab>nodes</defaultTab>
        <description></description>
        <dispatch>
          <excludePrecedence>true</excludePrecedence>
          <keepgoing>false</keepgoing>
          <rankOrder>ascending</rankOrder>
          <successOnEmptyNodeFilter>false</successOnEmptyNodeFilter>
          <threadcount>1</threadcount>
        </dispatch>
        <executionEnabled>true</executionEnabled>
        <id>29c0cb64-681c-4888-b2a8-f9eb02322155</id>
        <loglevel>INFO</loglevel>
        <name>HelloWorld</name>
        <nodeFilterEditable>false</nodeFilterEditable>
        <nodefilters>
          <filter>name: 192.168.33.2.*</filter>
        </nodefilters>
        <nodesSelectedByDefault>true</nodesSelectedByDefault>
        <scheduleEnabled>true</scheduleEnabled>
        <sequence keepgoing='false' strategy='node-first'>
          <command>
            <description>Second Issue.</description>
            <exec>env</exec>
            <plugins>
              <LogFilter type='key-value-data'>
                <config>
                  <logData>true</logData>
                  <regex>^(SHELL)\s*=\s*(.+)$</regex>
                </config>
              </LogFilter>
            </plugins>
          </command>
          <command>
            <node-step-plugin type='com.batix.rundeck.plugins.AnsiblePlaybookInlineWorkflowNodeStep'>
              <configuration>
                <entry key='ansible-base-dir-path' value='/playbooks' />
                <entry key='ansible-become' value='false' />
                <entry key='ansible-playbook-inline' value='# This playbook prints a simple debug message&#10;- name: Echo &#10;  hosts: farm&#10;&#10;  tasks:&#10;  - name: Print debug message &#10;    debug:&#10;      msg: Hello ${data.SHELL}!&#10;' />
              </configuration>
            </node-step-plugin>
          </command>
        </sequence>
        <uuid>29c0cb64-681c-4888-b2a8-f9eb02322155</uuid>
      </job>
    </joblist>

1) it take the data vaule.

2) pass to ansible.

MegaDrive68k
  • 3,768
  • 2
  • 9
  • 51
  • Thank you very much for your help. I'll follow the progress of the issue you opened regarding the first error. Relative to the second one, I tried with the job definition you shared and I have got the same problem I describe in the main comment, no data is captured. Evidence: 1) Command step:https://i.imgur.com/WfELyn3.png 2) Playbook step: https://i.imgur.com/AyYUZSP.png. I see that your ouput is black, whereas mine is green. The only time I obtain the output in black is when I execute the job locally (where Key Value Data does work). I don't know if that has something to do. – Rendan Nov 07 '19 at 11:56
  • I have edited my main post with the problem that causes Key Value Data to not work. It is the line force_color=1 in the ansible.cfg file. Thank you for your help. – Rendan Dec 17 '19 at 09:46