# Looping through data/vars file turns number into a string when creating a site in Cisco DNA Center

**URL:** <https://forum.ansible.com/t/looping-through-data-vars-file-turns-number-into-a-string-when-creating-a-site-in-cisco-dna-center/38349>\
**Category:** Ansible Project\
**Created:** [August 18, 2023, 3:43am UTC](https://forum.ansible.com/t/looping-through-data-vars-file-turns-number-into-a-string-when-creating-a-site-in-cisco-dna-center/38349 "2023-08-18T03:43:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulbauer1](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/paulbauer1/32/3144_2.png) [@paulbauer1](https://forum.ansible.com/u/paulbauer1)\
**Post date:** [August 18, 2023, 3:43am UTC](https://forum.ansible.com/t/looping-through-data-vars-file-turns-number-into-a-string-when-creating-a-site-in-cisco-dna-center/38349/1 "2023-08-18T03:43:34Z")

</div>

When using the task below with the yaml data that is shown below I end up getting an error indicating that my latitude number is not a number. If I just hard code a number in the latitude value the task works as expected. Any suggestions on how to get this to work?

Ansible task

# DNA Center Site Creation

- name: Create building  
cisco.dnac.site\_create:  
dnac\_host: “{{ ansible\_host }}”  
dnac\_username: “{{ username }}”  
dnac\_password: “{{ password }}”  
dnac\_verify: false  
dnac\_port: 443  
dnac\_version: “2.3.3.0”  
site:  
building:  
address: “{{ item.address }}”  
country: “{{ item.country }}”  
latitude: “{{ (item.latitude | float) }}”  
longitude: “{{ (item.longitude | float) }}”  
name: “{{ item.name }}”  
parentName: “{{ item.parent\_name }}”  
type: “{{ item.site\_type }}”  
loop: “{{ sites }}”  
when: item.site\_type == ‘building’

YAML Data

# vars file for dnac-create-site-hierarchy

sites:

# North America

- name: “US”  
site\_type: “area”  
parent\_name: “Global”
- name: “Big Campus”  
site\_type: “area”  
parent\_name: “Global/US”
- name: “Big\_bldg”  
site\_type: “building”  
address: “2222 Big Dr.”  
country: “United States”  
latitude: 44.22222  
longitude: -111.11111  
parent\_name: “Global/US/Big Campus”

Error Message returned from the Cisco DNAC SDK which is required for the Cisco.DNAC Ansible Module

raise MalformedRequest(  
dnacentersdk.exceptions.MalformedRequest: {‘type’: ‘building’, ‘site’: {‘building’: {‘address’: ‘2222 Big Dr.’, ‘country’: ‘United States’, ‘latitude’: ‘44.22222’, ‘longitude’: ‘-111.11111’, ‘name’: ‘Big\_bldg’, ‘parentName’: ‘Global/US/Big Campus’}}} is invalid. Reason: data.site.building.latitude must be number  
failed: [dna-center-lab] (item={‘name’: ‘Big\_bldg’, ‘site\_type’: ‘building’, ‘address’: ‘2222 Big Dr.’, ‘country’: ‘United States’, ‘latitude’: 44.22222, ‘longitude’: -111.11111, ‘parent\_name’: ‘Global/US/Big Campus’}) =\> {  
“ansible\_loop\_var”: “item”,  
“item”: {  
“address”: “2222 Big Dr.”,  
“country”: “United States”,  
“latitude”: 44.22222,  
“longitude”: -111.11111,  
“name”: “Big\_bldg”,  
“parent\_name”: “Global/US/Big Campus”,  
“site\_type”: “building”  
},  
“msg”: “An error occured when executing operation. The error was: {‘type’: ‘building’, ‘site’: {‘building’: {‘address’: ‘2222 Big Dr.’, ‘country’: ‘United States’, ‘latitude’: ‘44.22222’, ‘longitude’: ‘-111.11111’, ‘name’: ‘Big\_bldg’, ‘parentName’: ‘Global/US/Big Campus’}}} is invalid. Reason: data.site.building.latitude must be number”  
}

Thank you,

Paul

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [August 18, 2023, 2:12pm UTC](https://forum.ansible.com/t/looping-through-data-vars-file-turns-number-into-a-string-when-creating-a-site-in-cisco-dna-center/38349/2 "2023-08-18T14:12:41Z")

</div>

It seems like a bug to me, but according to [https://github.com/cisco-en-programmability/dnacenter-ansible/blob/main/plugins/modules/site\_create.py](https://github.com/cisco-en-programmability/dnacenter-ansible/blob/main/plugins/modules/site_create.py) latitude and longitude are both type int, not float.

---

<div class="post-metadata">

**Author:** ![paulbauer1](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/paulbauer1/32/3144_2.png) [@paulbauer1](https://forum.ansible.com/u/paulbauer1)\
**Post date:** [August 18, 2023, 5:57pm UTC](https://forum.ansible.com/t/looping-through-data-vars-file-turns-number-into-a-string-when-creating-a-site-in-cisco-dna-center/38349/3 "2023-08-18T17:57:44Z")

</div>

Thank you for the input. Agreed on the variable type, but it will take a float if hard coded. You won’t get very accurate location without some decimal places. 0.1 is about 9 miles. I’ll see about submitting a bug report.

Paul
