Skip to content

Instantly share code, notes, and snippets.

@hostmaster
Created January 12, 2014 14:55
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save hostmaster/8385567 to your computer and use it in GitHub Desktop.
Save hostmaster/8385567 to your computer and use it in GitHub Desktop.
ansible playbook choose APT or YUM for package installation
- name: Install wget package (Debian based)
  action: apt pkg='wget' state=installed
  only_if: "'$ansible_pkg_mgr' == 'apt'"
 
- name: Install wget package (RedHat based)
  action: yum name='wget' state=installed
  only_if: "'$ansible_pkg_mgr' == 'yum'"
@ku1ik
Copy link

ku1ik commented Oct 15, 2014

Thx for this! Exactly what I was looking for.

@samjacobson
Copy link

Or this (so long as the package has the same name on all distros):

- name: Install wget
  action: "{{ ansible_pkg_mgr }} name=wget state=present"

@QuingKhaos
Copy link

Much easier:

- name: Install wget
  package: name=wget state=present

@naviat
Copy link

naviat commented Oct 16, 2018

@EmiiKhaos: awesome!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment