Hi @zol123,
The default() empty set is not being used, it is passing through the "null" from your input variables. If you want to not set a tag if the input variable has tag=null, try omit for the default(), and ensure it gets used in the second parameter for the null use case (ref).
Also, ip_address/username/password are being deprecated, so please update your playbooks to use the provider parameter.
Example:
---
- name: Address objects with a loop
hosts: '{{ target | default("host_labfw") }}'
connection: local
vars:
device:
ip_address: "{{ ip_address }}"
username: "{{ username | default(omit) }}"
password: "{{ password | default(omit) }}"
api_key: "{{ api_key | default(omit) }}"
address_objects:
- {
"address_type": "ip-netmask",
"description": null,
"name": "192.168.0.1_SOLARWINDS",
"tag": "tag-one",
"value": "192.168.0.1/32"
}
- {
"address_type": "ip-netmask",
"description": null,
"name": "192.168.0.2_SOLARWINDS",
"tag": null,
"value": "192.168.0.2/32"
}
collections:
- paloaltonetworks.panos
tasks:
- name: Create address objects
paloaltonetworks.panos.panos_address_object:
provider: '{{ device }}'
name: '{{ item.name }}'
value: '{{ item.value }}'
description: '{{ item.description }}'
tag: '{{ item.tag | default(omit, omit) }}'
commit: false
with_items: '{{ address_objects }}'
Result:
TASK [Create address objects] *******************************************************************************************************************************
changed: [host_labfw] => (item={'address_type': 'ip-netmask', 'description': None, 'name': '192.168.0.1_SOLARWINDS', 'tag': 'tag-one', 'value': '192.168.0.1/32'})
changed: [host_labfw] => (item={'address_type': 'ip-netmask', 'description': None, 'name': '192.168.0.2_SOLARWINDS', 'tag': None, 'value': '192.168.0.2/32'})
PLAY RECAP **************************************************************************************************************************************************
host_labfw : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Hope that helps!
... View more