- Products
- Learn
- Local User Groups
- Partners
- More
CheckMates Fifth Birthday
Celebrate with Us!
days
hours
minutes
seconds
Join the CHECKMATES Everywhere Competition
Submit your picture to win!
Harmony Mobile 4:
New Version, New Capabilities
As YOU DESERVE THE BEST SECURITY
Upgrade to our latest GA Jumbo
CheckFlix!
All Videos In One Space
Hi all,
I just started playing with Ansible. I Needs some help. I build a test setup:
- Using: ansible-galaxy collection install check_point.mgmt, v1.0.6
- Smartcenter R80.40, latest jumbo
Everything is working, I am able to create a network object using a playbook. My working example:
----------- WORKING PLAYBOOK -----------
- name: playbook name
hosts: check_point
connection: httpapi
tasks:
- name: This is the first network
cp_mgmt_network:
name: "TEST"
subnet: 1.1.1.0
mask_length: 24
cp_mgmt_network:
name: "TEST2"
subnet: 2.2.2.0
mask_length: 24
auto_publish_session: true
---------------------------------------------------
Now my challenge, I would like to extend this playbook to add also a host object. My new script:
------------ FAILED PLAYBOOK --------------------
- name: playbook name
hosts: check_point
connection: httpapi
tasks:
- name: "Test with two Check Point networks"
cp_mgmt_network:
name: "TEST"
subnet: 1.1.1.0
mask_length: 24
cp_mgmt_network:
name: "TEST2"
subnet: 2.2.2.0
mask_length: 24
- name: "Add a new host object"
cp_mgmt_host:
name: "Test3"
ip_address: 3.3.3.3
-----------------------------------------------------
Error output:
ERROR! Syntax Error while loading YAML.
did not find expected '-' indicator
The error appears to be in '/etc/ansible/test.yml': line 14, column 6, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
mask_length: 24
- name: "Add a new host object"
^ here
-----------------------------------------------------
Could you please assist? I am really new to ansible.
Thanks!!!
Regards, Paul
It would be helpful if you attached the exact script used.
Indents matter quite a bit and it’s difficult to see with what was pasted to the community.
Hi,
Please try and add a empty line between the tasks of network creation and host creation.
Hi,
Thanks for your help! Still not working with a empty line.
Regards, Paul
Dear funkylicious,
Still not working. The add-host is working if I am using it in a playbook alone. When I combine it with the cp_mgmt_network I get errors. I added the script and output below.
Regards, Paul
---------------------------------------------------------------------
@ansible01:/etc/ansible# cat test2.yml
---
- name: playbook name
hosts: check_point
connection: httpapi
tasks:
- name: "Test with two Check Point networks"
cp_mgmt_network:
name: "TEST"
subnet: 1.1.1.0
mask_length: 24
cp_mgmt_network:
name: "TEST2"
subnet: 2.2.2.0
mask_length: 24
- name: add-host
cp_mgmt_host:
ip_address: 192.8.2.1
name: New host
state: present
---------------------------------------------------------------------
root@ansible01:/etc/ansible# ansible-playbook test2.yml
ERROR! Syntax Error while loading YAML.
did not find expected '-' indicator
The error appears to be in '/etc/ansible/test2.yml': line 16, column 6, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: add-host
^ here
---------------------------------------------------------------------
Hi,
Sorry, but i didn't pay enough attention to your playbook/details.
Apparently, from my understanding you cannot combine multiple modules in the same playbook, e.g cp_mgmt_network and cp_mgmt_host , so you would require individual playbooks for different tasks/modules.
If I misread/misunderstood this, someone please correct me.
Ow really, are you sure about this? Should explain a lot :-)!
Hi,
Its working when I use seperate playbooks, one for each module. For example:
main-playbook.yml
- import_playbook: playbook-add-network-objects.yml
- import_playbook: playbook-add-host-objects.yml
Regards, Paul
Thanks!!! I dont understand whats wrong in the syntax, should be OK?
About CheckMates
Learn Check Point
Advanced Learning
YOU DESERVE THE BEST SECURITY