Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
pycklets / resources / ansible-role / freckfrackery.install-pkgs
  ..
  defaults
  files
  filter_plugins
  handlers
  meta
  tasks
  templates
  .gitignore
  CHANGELOG.md
  LICENSE
  README.md
Size: Mime:

freckfrackery.install-pkgs

Platforms

Warning, this is a Beta role

This role has been marked by the author as a beta role, which means that it might be significantly changed in the future. Be careful while using this role in a production environment.


An Ansible role to install a list of packages, platform-independent.

Role variables

List of default variables available in the inventory:

---
# defaults file for freckfrackery.install-pkgs

install_packages: []                # as list of packages to install
install_ignore_errors: false        # whether to ignore install errors

install_pkg_mgrs: true              # whether to install package managers
# install_become: true                # whether to use 'become'

List of internal variables used by the role:

__install_package_list_main__

Usage

Details

As package names for the same application can be different for different platforms, the items in install_packages need to be able to reflect this. Depending on the package and the intended target platforms, this configuration can be more or less involved.

In the most complete case, a package item looks like this:

install_packages:
  - name: <package_name>
    pkg_mgr: <package manager>
    become: <pkg_mgn_become>
    pkgs:
      <platform_identifier_1>: <pkg_name>
      <platform_identifier_2>: <pkg_name>
      <platform_identifier_3>: <pkg_name>
      ...
      default: <pkg_name>

'default' is an optional key that can be used as a fallback for when nothing else matches. If the 'default' key is not specified, the 'name' key will be used.

If any of the platform_identifier keys has the string 'omit' as value, no package will be installed if it is matched.

The 'become' key can usually be omitted, as the 'install' module knows good defaults for each of the package managers. There are some cases where specifing might make sense though (for example with 'pip').

You can check the verbose Ansible log output of a test run for all potential platform identifiers for the current platform.

Alternatively, if you use a package manager where the package name is the same on all platforms, you can use this role to specify lists of lists of packages, where each sub-list has the same metadata (e.g. package manager):

install_packages:
  - name: <name of package group>
    pkg_mgr: <pkg_mgr_1>
    pkgs:
      - <pkg_name_1>
      - <pkg_name_2>
      ...
  - name: <name of package group 2>
    pkg_mgr: <pkg_mgr_2>
    pkgs:
      - <pkg_name_3>
      - <pkg_name_4>
Platform identifiers

Platform identifiers will be matched from the most to least specific, first match will win:

  • full distribution version string
  • full release string
  • distribution major string
  • distribution (Debian, Ubuntu, RedHat, CentOS, Darwin, ...)
  • os family (Debian, RedHat, Darwin)
  • platform (Linux, Darwin, Windows, Java, ...)

Matching happens case insensitive.

Supported package managers
apt

TODO

yum

TODO

homebrew

TODO

nix

TODO

conda

TODO

pip

TODO

git

TODO

unarchive

TODO

vagrant

TODO

Please check the examples below for more details.

Examples

Same package name on all platforms, short form

In the most simple case, the packages to install have the same name on each of the intended target platforms. If this is the case, each package item can be the package name as a string.

- include_role:
    name: freckfrackery.install-pkgs
  vars:
    install_packages:
      - zile
      - top

Same package name on all platforms, long form

Same scenario as above, just using the full form to describe it:

- include_role:
    name: freckfrackery.install-pkgs
  vars:
    install_packages:
      - name: zile
      - name: top

A package with different package names on different platforms

This isn't an uncommon occurence for the more 'basic', underlaying dependency packages. For example Debian and RedHat have different post-fixes for their development packages (<package>-dev and <package>-dvel).

Matching happens case independent. If the platform is neither Debian nor RedHat based, nothing will be installed. Ubuntu would still match, as it is Debian based for example.

- include_role:
    name: freckfrackery.install-pkgs
  vars:
    install_packages:
      - name: python-dev
        pkg_mgr: auto    # can be skipped, as it's the default
        pkgs:
          debian: python-dev
          redhat: python-devel
          default: omit

Mixed package names, some the same, some different on different platforms, long as well as short form.

It's easy to mix both ways of describing your packages:

- include_role:
    name: freckfrackery.install-pkgs
  vars:
    install_packages:
      - top
      - name: python-dev
        pkgs:
          Debian: python-dev
          RedHat: python-devel

Different package managers

A package list can also contain packages that will be installed by different package managers ('auto' refers to the default system package manager):

- include_role:
    name: freckfrackery.install-pkgs
  vars:
    install_packages:
      - name: htop
        pkg_mgr: nix
      - name: cookiecutter
        pkg_mgr: pip
      - name: zile
        pkg_mgr: auto

Different package managers, multiple packages per package manager.

Same as the above example, just using package groups instead of single packages.

- include_role:
    name: freckfrackery.install-pkgs
  vars:
    install_packages:
      - name: system utils
        pkg_mgr: nix
        pkgs:
          - htop
          - netcat
      - name: python utils
        pkg_mgr: pip
        virtualenv: ~/.virtualenvs/global_virtualenv
        pkgs:
          - cookiecutter
          - thefuck

Requirements

This role needs:

Authors and license

freckfrackery.install-pkgs role was written by:

License: Parity Public License


This role is part of the freckles project.

README.md generated by Ansigenome.