Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible warning about boolean type conversion

I have this snippet of Ansible:

  - name: check for reboot request
    stat:
      path: /var/run/reboot-required
    register: reboot_request

  - name: reboot if requested
    reboot:
      reboot_timeout: 180
      test_command: whoami
    when: reboot_request.stat.exists

...which generates this warning:

[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.

I find the error message not super-helpful. What would be the proper syntax?

I am running Ansible 2.9.7 on MacOS 10.15.4 and the target machine is Ubuntu 18.04.3 built with Vagrant 2.2.7, if any of that matters! :)

EDIT: Here is my whole playbook

---
- hosts: all
  become: yes
  tasks:
  - name: Ubuntu Update and Upgrade 
    apt:
      upgrade: yes
      update_cache: yes
      cache_valid_time: 3600

  - name: check for reboot request
    stat:
      path: /var/run/reboot-required
    register: reboot_request

  - name: reboot if requested
    reboot:
      reboot_timeout: 180
      test_command: whoami
    when: reboot_request.stat.exists

like image 480
guest Avatar asked Oct 15 '25 04:10

guest


1 Answers

It looks like the issue is here

  - name: Ubuntu Update and Upgrade 
    apt:
      upgrade: yes
      update_cache: yes
      cache_valid_time: 3600

If you look at the apt documentation (https://docs.ansible.com/ansible/latest/modules/apt_module.html) you fill find that the upgrade key needs a string not a bool.

Choices:
dist
full
no ←
safe
yes

So you have to write this

  - name: Ubuntu Update and Upgrade 
    apt:
      upgrade: "yes"
      update_cache: yes
      cache_valid_time: 3600

To remove the warning

like image 142
papey Avatar answered Oct 16 '25 18:10

papey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!