I think you are on the right track.

I suspect you don't want 'item.datatype' in your with_items list - you only 
need item. when you are dereferencing the variable.

Not tested, but I think maybe something like this is what you are after.  I 
changed subkey to location as it seems subkey has a special meaning in yaml.

Incidentally I use yamllint.com or a yaml-aware editor such as notepad++ to 
help get my syntax straight, that might help here.

--- 
- 
  name: "Insert Updates needed for WSUS"
  win_regedit: 
    data: "{{item.data}}"
    datatype: "{{item.datatype}}"
    key: "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\{{item.location}}"
    value: "{{item.value}}"
  with_items: 
    - location: WindowsUpdate 
      data: "http://x.x.x.x:8530";
      datatype: string
      value: WUServer
    - location: SomeOtherLocation 
      data: "http://x.x.x.x:8530";
      datatype: string
      value: WUServer

Hope this helps,

Jon

On Wednesday, 2 March 2016 14:21:30 UTC, a akin wrote:
>
> Ok, got some help from the docs and doing this now, better but probably 
> still not the best:
>
>     - name: Insert Updates needed for WSUS
>       win_regedit:
>         key: HKLM:\SOFTWARE\Policies\
> Microsoft\Windows\{{item.subkey}}
>         value: "{{item.value}}"
>         data: "{{item.data}}"
>         datatype: "{{item.datatype}}"
>       with_items:
>         - {subkey: 'WindowsUpdate', value: 'WUServer', data: '
> http://x.x.x.x:8530 <http://172.30.1.21:8530>', item.datatype: 'string'}
>
> but I am getting this error:
>     "fatal: [172.x.x.x]: FAILED! => {"failed": true, "msg": "'dict object' 
> has no attribute 'datatype'"}"
>
> No error if I comment out " datatype: "{{item.datatype}}"" but the values 
> are being created as default datatype (string). 
>
> I am on Ansible 2.0.1.0.
>
> Any help appreciated.
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/bf8032ee-8cae-4b97-8e00-9fc015e31a9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to