Hi,

I would use command (or shell) until it's implemented in apt module.
Here is the feature request issue ticket:
https://github.com/ansible/ansible-modules-core/issues/965

Den måndag 4 januari 2016 kl. 16:11:36 UTC+1 skrev Wayne Pascoe:
>
> 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/ab1efe94-1bad-46c1-bb53-0e4bfc342dce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to