<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Launching tower-cli playbook from Splunk alert in Alerting</title>
    <link>https://community.splunk.com/t5/Alerting/Launching-tower-cli-playbook-from-Splunk-alert/m-p/400438#M11342</link>
    <description>&lt;P&gt;I do have the full path on my Splunk server to run the tower-cli script. I can run the actual tower-cli command that is in the alerts scripts from any path on the CLI.... "/opt/rh/python27/root/usr/bin/tower-cli user list  &amp;gt;&amp;gt;  "/home/splunk/bin/scripts/nac_interfaces.log"&lt;BR /&gt;
Just can't execute it from the alerts scripts in Splunk&lt;/P&gt;

&lt;P&gt;Not sure what path it can't find. The tower-cli is attempting to login to another server to run the playbook. &lt;/P&gt;

&lt;H2&gt;Here is the content of the tower-cli file:&lt;/H2&gt;

&lt;P&gt;[root@splunk bin]# cat tower-cli&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#!/opt/rh/python27/root/usr/bin/python2

# -*- coding: utf-8 -*-
import re
import sys

from tower_cli.cli.run import cli

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(cli())
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is the tower-cli config. foobar would be the host that has the playbook to run&lt;/P&gt;

&lt;P&gt;[root@splunk bin]# tower-cli config&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;# User options (set with `tower-cli config`; stored in ~/.tower_cli.cfg).
host: foobar.com
username: splunk.service
password: xxxxxxxxx
verify_ssl: False

# Defaults.
use_token: False
verbose: False
certificate: 
format: human
color: True
description_on: False
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Could it be a permissions error? When I attempt to run the script at the CLI as a non-root user I get this error: "/opt/rh/python27/root/usr/bin/python2: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory"&lt;/P&gt;</description>
    <pubDate>Mon, 25 Jun 2018 14:22:08 GMT</pubDate>
    <dc:creator>ndavis4</dc:creator>
    <dc:date>2018-06-25T14:22:08Z</dc:date>
    <item>
      <title>Launching tower-cli playbook from Splunk alert</title>
      <link>https://community.splunk.com/t5/Alerting/Launching-tower-cli-playbook-from-Splunk-alert/m-p/400436#M11340</link>
      <description>&lt;P&gt;I have setup an alert to run a tower-cli script that kicks off a playbook. I installed tower-cli in /opt/rh on my Splunk server. In order to troubleshoot, I have stripped the script down to just list some users and pipe it to a file. I can run the script at the cli but it will not run from the alert in Splunk. I know the script is kicking off as I also just have a echo command in the script the dumps the timestamp to the same file. Here is my shell script I am calling from my Splunk alert:&lt;/P&gt;

&lt;P&gt;Location of script file is:  /home/splunk/bin/scripts&lt;BR /&gt;
nac_interfaces.sh&lt;/P&gt;

&lt;H1&gt;!/bin/bash&lt;/H1&gt;

&lt;P&gt;echo "&lt;CODE&gt;date '+%m-%e-%G %H:%M:%S'&lt;/CODE&gt;" &amp;gt;&amp;gt;  "/home/splunk/bin/scripts/nac_interfaces.log"&lt;BR /&gt;
source /opt/rh/python27/enable &lt;BR /&gt;
/opt/rh/python27/root/usr/bin/tower-cli user list  &amp;gt;&amp;gt;  "/home/splunk/bin/scripts/nac_interfaces.log"&lt;/P&gt;

&lt;P&gt;This is an error I am getting when the above script tries to execute the nac_interfaces.sh via the alerts script in Splunk&lt;BR /&gt;
ERROR script - sid:rt_scheduler_&lt;EM&gt;admin&lt;/EM&gt;&lt;EM&gt;search&lt;/EM&gt;_EUCImaging_at_1529626004_20372.268 command="runshellscript", Script: /opt/splunk/bin/scripts/nac_interfaces.sh exited with status code: 127&lt;/P&gt;

&lt;P&gt;Does it matter that splunk is installed in /home with a symlink to /opt?&lt;BR /&gt;
[root@splunk opt]# pwd&lt;BR /&gt;
/opt&lt;BR /&gt;
[root@splunk opt]# ls -ll&lt;BR /&gt;
lrwxrwxrwx. 1 splunk splunk        12 Nov 19  2013 splunk -&amp;gt; /home/splunk&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:07:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Launching-tower-cli-playbook-from-Splunk-alert/m-p/400436#M11340</guid>
      <dc:creator>ndavis4</dc:creator>
      <dc:date>2020-09-29T20:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Launching tower-cli playbook from Splunk alert</title>
      <link>https://community.splunk.com/t5/Alerting/Launching-tower-cli-playbook-from-Splunk-alert/m-p/400437#M11341</link>
      <description>&lt;P&gt;Hi  @ndavis4,&lt;/P&gt;

&lt;P&gt;BASH throws the error code 127 when it's not able to find the executable in PATH system variable and it is not a built-in shell command. In other words, the system doesn't understand your command, because it doesn't know where to find the binary you're trying to call.&lt;BR /&gt;
Try giving absolute path for all the executable and make sure that they have +x permissions and splunk user has permissions to execute them&lt;/P&gt;</description>
      <pubDate>Sat, 23 Jun 2018 09:58:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Launching-tower-cli-playbook-from-Splunk-alert/m-p/400437#M11341</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-06-23T09:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: Launching tower-cli playbook from Splunk alert</title>
      <link>https://community.splunk.com/t5/Alerting/Launching-tower-cli-playbook-from-Splunk-alert/m-p/400438#M11342</link>
      <description>&lt;P&gt;I do have the full path on my Splunk server to run the tower-cli script. I can run the actual tower-cli command that is in the alerts scripts from any path on the CLI.... "/opt/rh/python27/root/usr/bin/tower-cli user list  &amp;gt;&amp;gt;  "/home/splunk/bin/scripts/nac_interfaces.log"&lt;BR /&gt;
Just can't execute it from the alerts scripts in Splunk&lt;/P&gt;

&lt;P&gt;Not sure what path it can't find. The tower-cli is attempting to login to another server to run the playbook. &lt;/P&gt;

&lt;H2&gt;Here is the content of the tower-cli file:&lt;/H2&gt;

&lt;P&gt;[root@splunk bin]# cat tower-cli&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#!/opt/rh/python27/root/usr/bin/python2

# -*- coding: utf-8 -*-
import re
import sys

from tower_cli.cli.run import cli

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(cli())
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is the tower-cli config. foobar would be the host that has the playbook to run&lt;/P&gt;

&lt;P&gt;[root@splunk bin]# tower-cli config&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;# User options (set with `tower-cli config`; stored in ~/.tower_cli.cfg).
host: foobar.com
username: splunk.service
password: xxxxxxxxx
verify_ssl: False

# Defaults.
use_token: False
verbose: False
certificate: 
format: human
color: True
description_on: False
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Could it be a permissions error? When I attempt to run the script at the CLI as a non-root user I get this error: "/opt/rh/python27/root/usr/bin/python2: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory"&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 14:22:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Launching-tower-cli-playbook-from-Splunk-alert/m-p/400438#M11342</guid>
      <dc:creator>ndavis4</dc:creator>
      <dc:date>2018-06-25T14:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: Launching tower-cli playbook from Splunk alert</title>
      <link>https://community.splunk.com/t5/Alerting/Launching-tower-cli-playbook-from-Splunk-alert/m-p/400439#M11343</link>
      <description>&lt;P&gt;Yes it could be a permission issue as well as mentioned earlier. sudo as splunk user and try to execute the script&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 02:12:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Launching-tower-cli-playbook-from-Splunk-alert/m-p/400439#M11343</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-06-26T02:12:36Z</dc:date>
    </item>
  </channel>
</rss>

