Ansible – How to Handle Boolean Conversion in String Fields

ansibleansible-playbook

I'm trying to follow parameters/examples, yet running into following WARNING message while executing Ansible'playbook:

TASK [apt (pre)] ********************************************************************************************
[WARNING]: The value True (type bool) in a string field was converted to u'True' (type string). If this does
not look like what you expect, quote the entire value to ensure it does not change.

relevant part of playbook:

- name: apt (pre)
  apt:
    update_cache: yes
    upgrade: yes

Please advise.

Best Answer

I was able to recreate your results.

What I found is upgrade is expecting a string value. In addition to yes and no you can use dist, full, or safe

Changing your playbook to the following should achieve the desired results:

---
- hosts: localhost
  remote_user: root
  tasks:
          - name: apt (pre)
            apt:
                update_cache: yes
                upgrade: 'yes'

Reference

Ansible Apt Module