yum groupinstall "Development tools" for mutliple Linux-based OS

969 views
Skip to first unread message

Igor P.

unread,
Jul 27, 2016, 12:28:42 PM7/27/16
to Ansible Project
Hi,

I am new to Ansible and I am working a playbook that requires to have Development-tool installed on on CentOS based server. However, I was thinking about writing playbook that will be applicable to Debian-based OSs such as Ubuntu for example. What would be the module that can install Development-tools on both Fedora and Debian based systems?

This is what I currently have:

tasks:
- name: Install Development Tools, git, curl, htop
yum: name={{ item }} state=present update_cache=yes
with_items:
- "@development_tools"
- git
- curl
- htop


Thanks for you help.

Mark Janssen

unread,
Jul 28, 2016, 6:58:55 AM7/28/16
to ansible...@googlegroups.com
Add a conditional on your current task to only run on centos/redhat, something along the lines of:
when: ansible_os_family == "RedHat" 

And then make a second task:
tasks:
- name: Install Development Tools, git, curl, htop
    apt: name={{ item }} state=present
with_items:
-
build-essential

- git
- curl
- htop
when: ansible_os_family == "Debian"

--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d67a4b96-d83b-447e-b525-5be26589721c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Mark Janssen  --  maniac(at)maniac.nl
Unix / Linux Open-Source and Internet Consultant
Maniac.nl Sig-IO.nl Vps.Stoned-IT.com

Mark Janssen

unread,
Jul 28, 2016, 7:01:47 AM7/28/16
to ansible...@googlegroups.com
Or... use something like:

pkg: name="{{item}} state=installed
with_items:
  - {{devtools}}

and then have devtools be a list of the relevant packages set in group_vars or some included file based on OS
Reply all
Reply to author
Forward
0 new messages