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'

相關內容