我有一段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
键需要一个字符串而不是布尔。
Choices:
dist
full
no ←
safe
yes
所以你必须写这个
- name: Ubuntu Update and Upgrade
apt:
upgrade: "yes"
update_cache: yes
cache_valid_time: 3600
删除警告