0

I'm not sure why I'm getting this warning. I've already checked the apt module and it says:

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.

These are the two instances in which update_cache is present:

- 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

Any ideas why I'm getting this warning?

Lethargos
  • 455
  • 2
  • 7
  • 19

1 Answers1

1

update_cache is meant to be an argument to the apt command, but you've placed it as an argument to the task instead.

Remove it from its present position and add it to the apt command, i.e.:

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

P.S. If update_cache blows up, the workaround is to install aptitude. For example:

- 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'
Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • Hi. Thanks for the answer! So how can I make sure that apt is updated after adding a new repo? If the update isn't done, then I won't be able to install any packages from the newly installed repo. – Lethargos Aug 29 '18 at 14:40
  • The answer is you use `update_cache`. So there must be something about your question I don't understand. – Michael Hampton Aug 29 '18 at 14:43
  • Indeed, I hadn't read your answer correctly. it's all there :) Thanks for the explanation :) – Lethargos Aug 29 '18 at 20:19