Hi all,
I'm trying to create some simple playbooks to manage a few hosts. One of
the tasks I'm trying to complete is to autoremove unneeded packages. I'm
using Ansible 2.1.0 on Ubuntu 14.04 (control machine and managed hosts).
I started with the following playbook:
---
- hosts: vpn_endpoint
tasks:
- name: update apt packages
apt: upgrade=dist update_cache=yes
become: yes
- name: autoremove unneeded packages
command: apt-get -y autoremove
become: yes
This worked, but provided the following warning:
TASK [autoremove unneeded packages]
> ********************************************
> changed: [host]
> [WARNING]: Consider using apt-get module rather than running apt-get
>
Some searching showed me some projects that use a variable 'apt_autoremove:
yes' (e.g.
https://github.com/weareinteractive/ansible-apt/blob/master/README.md) but
I do not see any mention of this in the source at
https://github.com/ansible/ansible-modules-core/blob/stable-2.0/packaging/os/apt.py
I tried modifying my playbook to be the following:
---
- hosts: all
vars:
apt_cache_valid_time: 3600
apt_autoremove: yes
apt_autoclean: yes
tasks:
- name: update apt packages
apt: upgrade=dist update_cache=yes
become: yes
After doing that, I no longer see the warning, but the autoremove step on
the host is not being done (see the following output for apt-get
dist-upgrade).
Calculating upgrade... Done
> The following packages were automatically installed and are no longer
> required:
> linux-headers-3.13.0-32 linux-headers-3.13.0-32-generic
> linux-headers-3.13.0-51 linux-headers-3.13.0-51-generic
> linux-image-3.13.0-32-generic linux-image-3.13.0-51-generic
> linux-image-extra-3.13.0-32-generic linux-image-extra-3.13.0-51-generic
> Use 'apt-get autoremove' to remove them.
>
So that brings me to my question - what's the right way to do an auto
remove step with apt and Ansible ? Should I stick to the command module and
ignore the warning ? If so, is there any way to supress the warning just
for this specific task ?
Thanks in advance,
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/9f2c9fab-f51c-4c58-af74-4e9556a0f0b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.