Ubuntu playbook syntax

32 views
Skip to first unread message

teddy mills

unread,
Jun 28, 2016, 4:22:55 PM6/28/16
to Ansible Project

This playbook works, but I dont think this is the proper way to install multiple packages.
Can someone correct this and show how it should be done ? TIA



ansible-playbook    /root/aplays/core.pb -u teddy -k

#######################################
- hosts: teddy
  sudo: true
  tasks:
   - name: install sysstat
     apt: name=sysstat update_cache=yes state=latest

   - name: install htop
     apt: name=htop update_cache=yes state=latest

   - name: install curl
     apt: name=curl update_cache=yes state=latest

   - name: install bzip2
     apt: name=bzip2 update_cache=yes state=latest

   - name: install lft
     apt: name=lft update_cache=yes state=latest

   - name: install traceroute
     apt: name=traceroute update_cache=yes state=latest

   - name: install ncdu
     apt: name=ncdu update_cache=yes state=latest

   - name: install midnight-commander mc
     apt: name=mc update_cache=yes state=latest

   - name: install screen
     apt: name=screen update_cache=yes state=latest

   - name: install wget
     apt: name=wget update_cache=yes state=latest

Kai Stian Olstad

unread,
Jun 28, 2016, 5:12:22 PM6/28/16
to ansible...@googlegroups.com
On 28. juni 2016 19:51, teddy mills wrote:
> This playbook works, but I dont think this is the proper way to install
> multiple packages.
> Can someone correct this and show how it should be done ? TIA

If it work and is understandable it's OK in my book, but it could be
more condense.
- name: install apt packages
apt: name={{ item }} update_cache=yes state=latest
with_items:
- sysstat
- htop
- curl
- bzip

I think you see the pattern, just continue to add the rest of the packages.

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages