字符串字段中的值 True(类型 bool)被转换为 u'True'(类型字符串)

ale*_*xus 14 ansible ansible-playbook

我正在尝试遵循参数/示例,但在执行 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.
Run Code Online (Sandbox Code Playgroud)

剧本的相关部分:

- name: apt (pre)
  apt:
    update_cache: yes
    upgrade: yes
Run Code Online (Sandbox Code Playgroud)

请指教。

ken*_*kas 17

我能够重新创建您的结果。

我发现的upgrade是期待一个字符串值。除了yesandno您可以使用dist, full, 或 safe

将您的剧本更改为以下内容应该可以达到预期的结果:

---
- hosts: localhost
  remote_user: root
  tasks:
          - name: apt (pre)
            apt:
                update_cache: yes
                upgrade: 'yes'
Run Code Online (Sandbox Code Playgroud)

参考

Ansible apt 模块