Remove packages

56 views
Skip to first unread message

Diogene Laerce

unread,
Aug 6, 2014, 4:19:51 AM8/6/14
to ansible...@googlegroups.com
Hi,

Is there a way, other that with a bash script, to do this
command please (in Ansible of course.. :) )?

$ apt-get remove package*

Thank you,

--
“One original thought is worth a thousand mindless quotings.”
“Le vrai n'est pas plus sûr que le probable.”

Diogene Laerce


signature.asc

Paul Tötterman

unread,
Aug 6, 2014, 4:39:08 AM8/6/14
to ansible...@googlegroups.com, me_bu...@yahoo.fr
$ apt-get remove package*


# Remove "foo" package
 
- apt: name=foo state=absent

Cheers,
Paul

Diogene Laerce

unread,
Aug 6, 2014, 4:50:50 AM8/6/14
to ansible...@googlegroups.com
Thanks but I did see that.

Still it doesn't seem to remove all related packages as the "*"
implies.

For example, I tried to remove apache and all related packages,
and apache2-doc is still installed, as some others.

So 2 solutions : list all packages and remove them one by one, or
the "*" feature in a bash script.

Cheers,
signature.asc

Paul Tötterman

unread,
Aug 6, 2014, 4:51:12 AM8/6/14
to ansible...@googlegroups.com, me_bu...@yahoo.fr
$ apt-get remove package*

Reading a bit more carefully, if your problem is with the glob, maybe try a playbook like this:

---
- hosts: all
  tasks
:
 
- command: dpkg-query -f '${Package}\n' -W 'package*'
   
register: query
 
- apt: name={{item}} state=absent
    with_items
: query.stdout_lines

Cheers,
Paul

Diogene Laerce

unread,
Aug 6, 2014, 5:03:20 AM8/6/14
to ansible...@googlegroups.com


On 08/06/2014 10:51 AM, Paul Tötterman wrote:
> $ apt-get remove package*
>
>
> Reading a bit more carefully, if your problem is with the glob, maybe
> try a playbook like this:
>
> |
> ---
> -hosts:all
> tasks:
> -command:dpkg-query -f '${Package}\n'-W 'package*'
> register:query
> -apt:name={{item}}state=absent
> with_items:query.stdout_lines

Thank you, it does the trick. :)
signature.asc

Christian Rusa

unread,
Aug 6, 2014, 9:05:14 AM8/6/14
to ansible...@googlegroups.com
It is really easy just use apt module with state=absent

http://docs.ansible.com/apt_module.html



On 2014-08-06 10:17, 'Diogene Laerce' via Ansible Project wrote:
> Hi,
>
> Is there a way, other that with a bash script, to do this
> command please (in Ansible of course.. :) )?
>
> $ apt-get remove package*
>
> Thank you,
>


--
toscom - the open source company

Christian Rusa
Breiteneckergasse 32                    1230 Wien
Mobil: 0699 10205595                    Fax: 01 9249633
www.toscom.at                           christi...@toscom.at

Dan Vaida

unread,
Aug 7, 2014, 9:17:57 AM8/7/14
to ansible...@googlegroups.com, me_bu...@yahoo.fr
Hello,

This works just fine for me:
- name: uninstall apache-related packages
  apt: >
    pkg={{ item }} 
    state=absent
    purge=yes
    force=yes
  with_items:
    - apache2*
  sudo: yes
Reply all
Reply to author
Forward
0 new messages