How to avoid type conversion warnings?

回眸只為那壹抹淺笑 提交于 2020-08-07 09:57:21

问题


When I use the dconf module with a loop

- name: dconf | modify settings
  dconf:
    key: "{{ item.key }}"
    value: "{{ item.value }}"
    state: present
  loop:
    - key: "/org/gnome/libgnomekbd/keyboard/layouts"
      value: "['us', 'se']"
    - key: "/org/cinnamon/panels-height"
      value: "['1:40']"
  tags: "dconf"

I get such warnings:

[WARNING]: The value ['us', 'se'] (type list) in a string field was converted to "['us', 'se']" (type string). If this does not look like what you expect, quote the entire value to ensure it does not change.

[WARNING]: The value ['1:40'] (type list) in a string field was converted to "['1:40']" (type string). If this does not look like what you expect, quote the entire value to ensure it does not change.

I tried all possible ways to quote the value but without result


回答1:


Have you tried

value: "{{ item.value |string }}"


来源:https://stackoverflow.com/questions/56181810/how-to-avoid-type-conversion-warnings

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!