Tom's Blog

From tech to non-tech

Ansible Install Multiple Packages on Ubuntu

| Comments

I’ve been playing around with Ansible a lot and I’ve noticed that most of the time the examples that you find in the docs or on the web are not very good.

For example when you try to figure out if it possible to install multiple APT packages with a single command my googlefoo will find that the answer is YES but not a single copy and paste solution. Anyways, here you go, lets have it on the interwebs now. Lets install Apache and PHP5 with a single command!

1
2
3
4
5
- name: Install Apache
  action: apt pkg= state=installed
  with_items:
    - apache2-mpm-prefork
    - libapache2-mod-php5

And as we are at it lets enable couple of Apache modules also.

1
2
3
4
5
- name: enable some Apache modules
  action: apache2_module name= state=present
  with_items:
   - rewrite
   - expires

Comments