- CheckMates
- :
- Products
- :
- Developers
- :
- Ansible
- :
- Using Run-Script with Ansible
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Are you a member of CheckMates?
×- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using Run-Script with Ansible
Hi, I am trying to use Run-Script module. Below is my code
---
- 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
shell script
#!/bin/bash
cpstat os -f all
TASK [run-script] ******************************************************************************************************************************************
fatal: [check_point]: FAILED! => {"changed": false, "msg": "Task Some_Server - Check stat with task id af3660dc-9e23-4a90-a398-6d54357a failed. Look at the logs for more details"}
I noticed this playbook is not running my script. What can I do to fix this erroor
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My only guess regarding the SIC error is that the target definition isn't reachable or hasn't been fully configured yet.
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.
script:
description:
- Script body contents.
type: str
required: true
This mirrors the run-script API documentation.
- https://sc1.checkpoint.com/documents/latest/APIs/index.html#cli/run-script~v1.7%20
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.
---
- 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
EDIT: 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try specifying the full path to the script.
If not, I recommend checking the task status in SmartConsole to see what it says.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The shell script is in the same directory as the playbook.
Error message on SmartConsole
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
Connection failed for IP Address
Makes sure that the machine is up and running, and that SIC has been established
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My only guess regarding the SIC error is that the target definition isn't reachable or hasn't been fully configured yet.
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.
script:
description:
- Script body contents.
type: str
required: true
This mirrors the run-script API documentation.
- https://sc1.checkpoint.com/documents/latest/APIs/index.html#cli/run-script~v1.7%20
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.
---
- 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
EDIT: 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.
