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 On Friday, August 18, 2023 at 8:12:53 AM UTC-6 Todd Lewis wrote: > 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 > > latitude and longitude are both type int, not float. > > > On 8/17/23 11:43 PM, Paul Bauer wrote: > > 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 > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/84cec934-05e7-4ed8-a67a-44d35f83bb0cn%40googlegroups.com > > <https://groups.google.com/d/msgid/ansible-project/84cec934-05e7-4ed8-a67a-44d35f83bb0cn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > > -- > Todd > > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5e735f88-3b31-462f-bf0d-59022b9d3529n%40googlegroups.com.
