![ansible [警告]: 無効な属性を無視します: update_cache](https://rvso.com/image/726422/ansible%20%5B%E8%AD%A6%E5%91%8A%5D%3A%20%E7%84%A1%E5%8A%B9%E3%81%AA%E5%B1%9E%E6%80%A7%E3%82%92%E7%84%A1%E8%A6%96%E3%81%97%E3%81%BE%E3%81%99%3A%20update_cache.png)
なぜこの警告が表示されるのかわかりません。すでに 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 が存在する 2 つのインスタンスです。
- 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
PSupdate_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'