Open vjsaisha opened 2 years ago
- hosts: all
connection: httpapi
vars:
src_obj_host:
- 10.1.1.1
- 10.1.1.2
dst_obj_host:
- 10.2.1.1
tasks:
- name: Get Domain UUID
cisco.fmcansible.fmc_configuration:
operation: getAllDomain
register_as: domain
- name: Create a network object type - Host
cisco.fmcansible.fmc_configuration:
operation: upsertHostObject
data:
name: 'IP-{{item}}'
value: '{{item}}'
type: Host
path_params:
domainUUID: '{{ domain[0].uuid }}'
register_as: networkobjectcreated
loop: '{{ src_obj_host + dst_obj_host }}'
- name: print infor
debug:
msg: '{{ networkobjectcreated}}'
Hopefully you have your answer a long time ago, but try the following
- name: Create a network object type - Host
cisco.fmcansible.fmc_configuration:
operation: upsertHostObject
data:
name: 'IP-{{item}}'
value: '{{item}}'
type: Host
path_params:
domainUUID: '{{ domain[0].uuid }}'
register: networkobjectcreated
loop: '{{ src_obj_host + dst_obj_host }}'
That is move the register_as in the module data to register at the task level.
When we are adding the objects through the loop function and using the register_as function it's not holding all the objects attributes only the last execution item is only holding.
Any way to achieve this?