ansible [警告]:忽略无效属性:update_cache

ansible [警告]:忽略无效属性:update_cache

我不确定为什么会收到此警告。我已经检查了 apt 模块,它显示:

update_cache 
bool
Choices:
no ←
yes
Run the equivalent of apt-get update before the operation. Can be run as part of the package installation or as a separate step.

以下是 update_cache 存在的两个实例:

- name: Install Apache
      apt:
        name: apache2
        state: present
        update_cache: yes

- name: install php7.2-fpm and all necessary modules
      apt: name={{ item }} state=present
      with_items:
         - php7.2-fpm
         - php7.2-gd
         - php7.2-curl
         - php7.2-mysql
         #- php7.2-mcrypt
         - php7.2-mbstring
         - php7.2-xml
      update_cache: yes
      when: ppastable is success

知道我为什么会收到此警告吗?

答案1

update_cache应该是apt命令的一个参数,但您却将它作为任务的参数。

将其从当前位置移除并将其添加到命令中apt,即:

apt: name={{item}} state=present update_cache=yes

PS 如果update_cache崩溃了,解决方法是安装 aptitude。例如:

- name: Install aptitude on Debian systems (https://github.com/ansible/ansible/issues/18987)
  apt: pkg=aptitude state=latest
  when: ansible_os_family == 'Debian'

- name: Update apt cache (https://github.com/ansible/ansible/issues/18987)
  apt: update_cache=yes
  when: ansible_os_family == 'Debian'

相关内容