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

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.

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"

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