<?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: Using Run-Script with Ansible in Ansible</title>
    <link>https://community.checkpoint.com/t5/Ansible/Using-Run-Script-with-Ansible/m-p/113368#M464</link>
    <description>&lt;P&gt;Try specifying the full path to the script.&lt;BR /&gt;If not, I recommend checking the task status in SmartConsole to see what it says.&lt;/P&gt;</description>
    <pubDate>Sat, 13 Mar 2021 04:07:59 GMT</pubDate>
    <dc:creator>PhoneBoy</dc:creator>
    <dc:date>2021-03-13T04:07:59Z</dc:date>
    <item>
      <title>Using Run-Script with Ansible</title>
      <link>https://community.checkpoint.com/t5/Ansible/Using-Run-Script-with-Ansible/m-p/113361#M462</link>
      <description>&lt;P&gt;Hi, I am trying to use Run-Script module. Below is my code&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;---
- hosts: check_point
  connection: httpapi
  gather_facts: False
  vars_files:
    - 'credentials/ansible_login_information.yml'
  tasks:
  - name: run-script
    check_point.mgmt.cp_mgmt_run_script:
      script: ./stat.sh
      script_name: 'Check stat'
      targets:
      - Some_Server
      wait_for_task_timeout: 30&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;shell script&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#!/bin/bash
cpstat os -f all&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;TASK [run-script] ******************************************************************************************************************************************&lt;BR /&gt;fatal: [check_point]: FAILED! =&amp;gt; {"changed": false, "msg": "Task Some_Server - Check stat with task id af3660dc-9e23-4a90-a398-6d54357a failed. Look at the logs for more details"}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I&amp;nbsp; noticed this playbook is not running my script. What can I do to fix this erroor&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 21:35:59 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Using-Run-Script-with-Ansible/m-p/113361#M462</guid>
      <dc:creator>ukohae</dc:creator>
      <dc:date>2021-03-12T21:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using Run-Script with Ansible</title>
      <link>https://community.checkpoint.com/t5/Ansible/Using-Run-Script-with-Ansible/m-p/113368#M464</link>
      <description>&lt;P&gt;Try specifying the full path to the script.&lt;BR /&gt;If not, I recommend checking the task status in SmartConsole to see what it says.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Mar 2021 04:07:59 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Using-Run-Script-with-Ansible/m-p/113368#M464</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2021-03-13T04:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using Run-Script with Ansible</title>
      <link>https://community.checkpoint.com/t5/Ansible/Using-Run-Script-with-Ansible/m-p/113555#M470</link>
      <description>&lt;P&gt;The shell script is in the same directory as the playbook.&lt;BR /&gt;&lt;BR /&gt;Error message on SmartConsole&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Run One Time Script

Results ..............................................................
Task Results Connection failed for 192.1.1.1
             Make sure that the machine is up and running, and that  
             SIC has been established

Details ..............................................................
Script  ./stat.sh&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Connection failed for IP Address&lt;/P&gt;&lt;P&gt;Makes sure that the machine is up and running, and that SIC has been established&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 14:42:07 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Using-Run-Script-with-Ansible/m-p/113555#M470</guid>
      <dc:creator>ukohae</dc:creator>
      <dc:date>2021-03-15T14:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using Run-Script with Ansible</title>
      <link>https://community.checkpoint.com/t5/Ansible/Using-Run-Script-with-Ansible/m-p/113565#M471</link>
      <description>&lt;P&gt;My only guess regarding the SIC error is that the target definition isn't reachable or hasn't been fully configured yet.&lt;/P&gt;
&lt;P&gt;The run-script will not copy a script from the local directory and deploy it to a remote deployment for use. You need to insert the body of the script into the "script" command before running it from the management API.&lt;/P&gt;
&lt;P&gt;From &lt;A href="https://github.com/CheckPointSW/CheckPointAnsibleMgmtCollection/blob/master/plugins/modules/checkpoint_run_script.py" target="_blank" rel="noopener"&gt;https://github.com/CheckPointSW/CheckPointAnsibleMgmtCollection/blob/master/plugins/modules/checkpoint_run_script.py&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;  script:
    description:
    - Script body contents.
    type: str
    required: true&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This mirrors the run-script API documentation.&lt;/P&gt;
&lt;P&gt;- &lt;A href="https://sc1.checkpoint.com/documents/latest/APIs/index.html#cli/run-script~v1.7%20" target="_blank" rel="noopener"&gt;https://sc1.checkpoint.com/documents/latest/APIs/index.html#cli/run-script~v1.7%20&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I haven't run this in my lab, so this might not provide the results. However, I would expect it to look similar to below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;---
- hosts: check_point
  connection: httpapi
  gather_facts: False
  vars_files:
    - 'credentials/ansible_login_information.yml'
  tasks:
  - name: run-script
    check_point.mgmt.cp_mgmt_run_script:
      script: "cpstat os -f all"
      script_name: 'Check stat'
      targets:
      - deployed-gw-1
      wait_for_task_timeout: 30&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;EDIT&lt;/STRONG&gt;: One other thing I didn't mention is that you'll need to query the task-id from the run-script command to see the results for this particular playbook. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 16:18:33 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Using-Run-Script-with-Ansible/m-p/113565#M471</guid>
      <dc:creator>masher</dc:creator>
      <dc:date>2021-03-15T16:18:33Z</dc:date>
    </item>
  </channel>
</rss>

