Ansible 2.8.0: Module option conversion to string

11 views
Skip to first unread message

tendo...@gmail.com

unread,
May 25, 2019, 6:13:22 AM5/25/19
to Ansible Project
Ansible 2.8.0 has introduction Module option conversion to string but didn't give any example. I have simple task to set the file descriptor limits for user

- name: Set file descriptor limits for the node user
  pam_limits:
    domain: app
    limit_type: "{{ item }}"
    limit_item: nofile
    value: 65535
  loop:
    - soft
    - hard

It was working fine and didn't give any warning until 2.7.x but after upgrading to ansible 2.8.0, I am getting this warning:

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

I have changed the value part like this:
 value: !!int 65535

But still get the same warning. How I can overcome this warning. Thanks

Felix Fontein

unread,
May 25, 2019, 6:55:26 AM5/25/19
to ansible...@googlegroups.com
Hi,

> Ansible 2.8.0 has introduction Module option conversion to string but
> didn't give any example. I have simple task to set the file

that's not true: Ansible has already been doing that for a long time.
It's only since 2.8.0 that Ansible will warn about such conversions
-- which can be really dangerous, in particular in combination with
booleans.

> descriptor limits for user
>
> - name: Set file descriptor limits for the node user
> pam_limits:
> domain: app
> limit_type: "{{ item }}"
> limit_item: nofile
> value: 65535
> loop:
> - soft
> - hard
>
> It was working fine and didn't give any warning until 2.7.x but after
> upgrading to ansible 2.8.0, I am getting this warning:
>
> [WARNING]: The value 65535 (type int) in a string field was
> converted to '65535' (type string). If this does not look like what
> you expect, quote the entire
> value to ensure it does not change.
>
> I have changed the value part like this:
> * value: !!int 65535*
>
> But still get the same warning.

Not a surprise, since 65535 is still an integer. The "value" option
expects a string.

> How I can overcome this warning.

So you have to quote the value (as the warning says) to make it a
string:

> pam_limits:
> domain: app
> limit_type: "{{ item }}"
> limit_item: nofile
> value: "65535"

Cheers,
Felix


Reply all
Reply to author
Forward
0 new messages