Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid type conversion warnings?

Tags:

ansible

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

like image 956
dmin Avatar asked May 17 '19 07:05

dmin


People also ask

What is type conversion and why is it necessary?

Type Conversion refers to conversion from one type to another. The main idea behind type conversion is to make variable of one type compatible with variable of another type to perform an operation. For example, to find the sum of two variables, one of int type & other of float type.

What are the two types of type conversion?

There are two types of conversion: implicit and explicit. The term for implicit type conversion is coercion. Explicit type conversion in some specific way is known as casting.

What are the advantages of type conversion?

Advantages of Type Conversion: This is done to take advantage of certain features of type hierarchies or type representations. It helps to compute expressions containing variables of different data types.

What is the meaning of type conversion?

In computer science, type conversion, type casting, type coercion, and type juggling are different ways of changing an expression from one data type to another. An example would be the conversion of an integer value into a floating point value or its textual representation as a string, and vice versa.


1 Answers

Have you tried

value: "{{ item.value |string }}"
like image 165
lewer Avatar answered Sep 23 '22 02:09

lewer