# win\_dsc UrlAcl and passing int\[\]

**URL:** <https://forum.ansible.com/t/win-dsc-urlacl-and-passing-int/30970>\
**Category:** Ansible Project\
**Created:** [August 7, 2019, 8:29am UTC](https://forum.ansible.com/t/win-dsc-urlacl-and-passing-int/30970 "2019-08-07T08:29:11Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Richard\_Payne](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@Richard\_Payne](https://forum.ansible.com/u/Richard_Payne)\
**Post date:** [August 7, 2019, 8:29am UTC](https://forum.ansible.com/t/win-dsc-urlacl-and-passing-int/30970/1 "2019-08-07T08:29:11Z")

</div>

I’m trying to integrate my existing DSC configuration into my Ansible setup. I’m using the UrlAcl module ([https://www.powershellgallery.com/packages/HttpSys/1.0.1/Content/UrlAcls%5CUrlAcls.ps1](https://www.powershellgallery.com/packages/HttpSys/1.0.1/Content/UrlAcls%5CUrlAcls.ps1)) and its Port property is an int. This is what I’m trying:

- name: UrlAcls - Http Wcf interface specific  
win\_dsc:  
resource\_name: UrlAcl  
Protocol: “http”  
HostName: “{{ ansible\_hostname }}.domain.com”  
Port: [46000…46100]  
SecurityContext: “{{ ansible\_hostname }}\UrlAclPermitted”

It’s telling me that it can’t convert from string to int.

How do I define the Port property as int?

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [August 7, 2019, 8:21pm UTC](https://forum.ansible.com/t/win-dsc-urlacl-and-passing-int/30970/2 "2019-08-07T20:21:48Z")

</div>

You should be using a YAML list or a Python list like the below;

`  
Port:

- 46000
- 46100

# or

Port: [46000, 46100]

`

Thanks

Jordan

---

<div class="post-metadata">

**Author:** ![Richard\_Payne](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@Richard\_Payne](https://forum.ansible.com/u/Richard_Payne)\
**Post date:** [August 8, 2019, 7:19am UTC](https://forum.ansible.com/t/win-dsc-urlacl-and-passing-int/30970/3 "2019-08-08T07:19:38Z")

</div>

Thanks Jordan, but a explicitly written list is not really practical when you have a range 100 or 1000 in length.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [August 8, 2019, 8:00am UTC](https://forum.ansible.com/t/win-dsc-urlacl-and-passing-int/30970/4 "2019-08-08T08:00:20Z")

</div>

{{ range(46000,46100) | list }}

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [August 8, 2019, 8:37am UTC](https://forum.ansible.com/t/win-dsc-urlacl-and-passing-int/30970/5 "2019-08-08T08:37:57Z")

</div>

Ahh sorry I thought you only wanted those numbers. The suggestion above should work.

---

<div class="post-metadata">

**Author:** ![Richard\_Payne](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@Richard\_Payne](https://forum.ansible.com/u/Richard_Payne)\
**Post date:** [August 8, 2019, 8:50am UTC](https://forum.ansible.com/t/win-dsc-urlacl-and-passing-int/30970/6 "2019-08-08T08:50:20Z")

</div>

Hi Kai

This:

Port: {{ range(43000,43200) | list }}

produces:  
`  
ERROR! Syntax Error while loading YAML.  
found unacceptable key (unhashable type: ‘AnsibleMapping’)  
The offending line appears to be:

HostName: “+”  
Port: {{ range(43000,43200) | list }}  
^ here  
We could be wrong, but this one looks like it might be an issue with  
missing quotes. Always quote template expression brackets when they  
start a value. For instance:

with\_items:

- {{ foo }}

Should be written as:

with\_items:

- “{{ foo }}”  
`

So I removed the interpolation:

Port: range(43000,43200) | list

which produces:

`fatal: [dev21-sfapp12]: FAILED! => {"changed": false, "module_version": "1.0.1", "msg": "Convert property 'Port' value from type 'STRING[]' to type 'SINT32[]' failed\r\n At line:11, char:2\r\n Buffer:\r\n Protocol = \"http\";\n};^\n\ninsta\r\n", "reboot_required": false}`

Any thoughts?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [August 8, 2019, 8:55am UTC](https://forum.ansible.com/t/win-dsc-urlacl-and-passing-int/30970/7 "2019-08-08T08:55:43Z")

</div>

As the error message says you need to add quotes.  
When a { comes after a colon you need to quote it with single or double quotes.

&nbsp;&nbsp;Port: "{{ range(43000,43200) | list }}"

---

<div class="post-metadata">

**Author:** ![Richard\_Payne](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@Richard\_Payne](https://forum.ansible.com/u/Richard_Payne)\
**Post date:** [August 9, 2019, 2:07pm UTC](https://forum.ansible.com/t/win-dsc-urlacl-and-passing-int/30970/8 "2019-08-09T14:07:24Z")

</div>

Sure, but then I’m passing a single string to an int array.

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [August 9, 2019, 8:03pm UTC](https://forum.ansible.com/t/win-dsc-urlacl-and-passing-int/30970/9 "2019-08-09T20:03:03Z")

</div>

No you are not, the jinja2 block is evaluated before it’s passed to the module so the data will contain the array you are looking for. Did you try it out?

---

<div class="post-metadata">

**Author:** ![Richard\_Payne](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@Richard\_Payne](https://forum.ansible.com/u/Richard_Payne)\
**Post date:** [August 12, 2019, 7:11am UTC](https://forum.ansible.com/t/win-dsc-urlacl-and-passing-int/30970/10 "2019-08-12T07:11:29Z")

</div>

I thought so, but will try again to confirm.

---

<div class="post-metadata">

**Author:** ![Richard\_Payne](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@Richard\_Payne](https://forum.ansible.com/u/Richard_Payne)\
**Post date:** [August 20, 2019, 12:10pm UTC](https://forum.ansible.com/t/win-dsc-urlacl-and-passing-int/30970/11 "2019-08-20T12:10:53Z")

</div>

You were right Jordan.

I have to say, I really dislike the use of quotes here. It is really not intuitive what data you are passing.

Thanks for everyone’s help.
