- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
08-10-2022 08:50 AM
Hello Palo Alto Community
I've been trying to make work my first Playbook in ansible, to pretty much whatever it works, right now Im trying to create a test address object, but I kept geeting what it looks like, a syntax error this is the configuration of my playbook.
The image attached is the error im seeing(Looks like connection to the device is established correctly, is just that something maybe syntax is wrong.), do you have any idea what I might be missing?
Thanks in Advance
The Galaxy was install correctly
ansible-galaxy collection install paloaltonetworks.panos
This is exactly the playbook configuration.
- hosts: DEV
connection: local
vars:
device:
ip_address: '{{ 1.1.1.1 }}'
username: '{{ 111111111 | default(omit) }}'
password: '{{ 111111111 | default(omit) }}'
api_key: '{{ supersecretkey | default(omit) }}'
tasks :
- name: Create address object
panos_address_object:
provider: '{{ device }}'
name: 'Hello-World'
value: '1.1.1.1'
description: 'Test'
collections :
- paloaltonetworks.panos
08-23-2022 05:58 AM - edited 08-23-2022 06:06 AM
Hello @fersherls , as you have probably noticed Ansible logging messages could be a little more helpful. It looks like the way you're calling your variables within the playbook is problematic.
When you encapsulate some text within double curly braces, you need the text to be the name of a variable.
In this example, we encapsulate the word "example" between braces, and this will allow us to call forward the value of an object with that name
{{ example }}
So in the original, we see that you're trying to store the value of objects in curly braces. this will confuse Ansible, which will look for a variable named 1.1.1.1 and set the value of that object to `ip_address`
ip_address: '{{ 1.1.1.1 }}'
should look like this instead.
ip_address: '1.1.1.1'
additional issue with the username and password you're calling, as Ansible requires that a variable name begin with a string
username: '{{ 111111111 | default(omit) }}'
password: '{{ 111111111 | default(omit) }}'
should look like either of these, with the first example calling for the values of objects named my_username_variable and my_password_variable.
username: '{{ my_username_variable | default(omit) }}'
password: '{{ my_password_variable | default(omit) }}'
username: 'admin'
password: 'password123'
Please let me know if this helps,
Calvin
08-23-2022 05:58 AM - edited 08-23-2022 06:06 AM
Hello @fersherls , as you have probably noticed Ansible logging messages could be a little more helpful. It looks like the way you're calling your variables within the playbook is problematic.
When you encapsulate some text within double curly braces, you need the text to be the name of a variable.
In this example, we encapsulate the word "example" between braces, and this will allow us to call forward the value of an object with that name
{{ example }}
So in the original, we see that you're trying to store the value of objects in curly braces. this will confuse Ansible, which will look for a variable named 1.1.1.1 and set the value of that object to `ip_address`
ip_address: '{{ 1.1.1.1 }}'
should look like this instead.
ip_address: '1.1.1.1'
additional issue with the username and password you're calling, as Ansible requires that a variable name begin with a string
username: '{{ 111111111 | default(omit) }}'
password: '{{ 111111111 | default(omit) }}'
should look like either of these, with the first example calling for the values of objects named my_username_variable and my_password_variable.
username: '{{ my_username_variable | default(omit) }}'
password: '{{ my_password_variable | default(omit) }}'
username: 'admin'
password: 'password123'
Please let me know if this helps,
Calvin
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!