Home > front end >  Ansible - ip_configurations must by a list, not 'list'
Ansible - ip_configurations must by a list, not 'list'

Time:07-25

Why am I getting this weird error ip_configurations must by a list, not 'list' when trying to update Azure network interface using ansible?

if I change it to something like this then I get the error that AtributeError:'str' object has no attribute 'get'.

  ip_configurations:
    - name: "{{ test1 }}"     
      primary: "{{ test2 }}"

Playbook:

  - json_modify:
      data: "{{ azure_network_interface_info }}"
      pointer: "/networkinterfaces/0/ip_configurations/0"
      action: update
      update: { "public_ip_allocation_method": "Dynamic" }
    register: azure_network_interface_info_modified

  - debug:
      var: azure_network_interface_info_modified.result.networkinterfaces[0].ip_configurations

  - name: Applying NSG to target NIC
    azure_rm_networkinterface:
      name: "{{ azure_vm_network_interface }}"
      resource_group: "{{ resource_group }}"
      subnet_name: "{{ azure_network_interface_info.networkinterfaces[0].subnet }}"
      virtual_network: "{{ azure_network_interface_info.networkinterfaces[0].virtual_network.name }}"
      ip_configurations: "{{ [ azure_network_interface_info_modified.result.networkinterfaces[0].ip_configurations ] }}"
      security_group: "/subscriptions/123456/resourceGroups/cloud-shell-storage/providers/Microsoft.Network/networkSecurityGroups/testing_temp_8"

Error:

     "msg": "Value '[{'name': 'Ubuntu915', 'private_ip_address': '10.0.0.5', 
    'private_ip_allocation_method': 'Dynamic', 'primary': True, 'load_balancer_backend_address_pools': None, 
    'application_gateway_backend_address_pools': None, 'public_ip_address': '/subscriptions/123456/resourceGroups/cloud-shell-
    storage/providers/Microsoft.Network/publicIPAddresses/Ubuntu-915-test', 'public_ip_allocation_method': 'Dynamic', 
    'application_security_groups': None}]' in the sub parameter field 'ip_configurations' must by a list, not 'list'"
                            }

CodePudding user response:

for me ip_configuration is already a list, so you just write:

ip_configurations: "{{  azure_network_interface_info_modified.result.networkinterfaces[0].ip_configurations }}"
  • Related