我有这个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
...生成此警告:
[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.
我发现错误消息不是非常有用。正确的语法是什么?
我正在MacOS 10.15.4上运行Ansible 2.9.7,目标计算机是使用Vagrant 2.2.7构建的Ubuntu 18.04.3,如果有任何重要的话! :)
编辑:这是我的整个剧本
---
- 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
- name: Ubuntu Update and Upgrade
apt:
upgrade: yes
update_cache: yes
cache_valid_time: 3600
如果您查看apt文档(https://docs.ansible.com/ansible/latest/modules/apt_module.html),则会发现upgrade
键需要一个字符串而不是bool。
Choices: dist full no ← safe yes
所以你必须写这个
- name: Ubuntu Update and Upgrade apt: upgrade: "yes" update_cache: yes cache_valid_time: 3600
删除警告