Giter Club home page Giter Club logo

ansible-role-package's Introduction

Package

Ansible Galaxy Build Status Latest tag Gitter chat

A role for managing packages on different operating systems.

This role currently supports apt, yum, dnf, brew, zypper, pacman and portage. Feel free to send a pull or feature request to add your favorite package manager!

Attention:

  • This role handles name differences between package managers but not between distributions using the same package manager.
  • Test coverage is rather small so please do report bugs!

Requirements

  • Hosts should be bootstrapped for ansible usage (have python,...)
  • Root privileges, eg become: yes

Role Variables

Variable Description Default value
package_list List of packages (see details!) []
package_list_host List of packages (see details!) []
package_list_group List of packages (see details!) []
package_state Default package state 'present'
package_update_cache Update the cache? yes
package_cache_valid_time How long is the package cache valid? (seconds) 3600

package_list details

package_list, package_list_host and package_list_group are merged when managing the packages. You can use the host and group lists to specify packages per host or group.

The package list allows you to define which packages must be managed. Each item in the list can have following attributes:

Variable Description required
name Package name yes
state Package state no
apt Package name for apt no
apt_ignore Ignore package for apt no
apt_install_recommends Whether to install recommended dependencies apt no
apk Package name for apk no
apk_ignore Ignore package for apk no
yum Package name for yum no
yum_ignore Ignore package for yum no
dnf Package name for dnf no
dnf_ignore Ignore package for dnf no
brew Package name for brew no
brew_ignore Ignore package for brew no
zypper Package name for zypper no
zypper_ignore Ignore package for zypper no
pacman Package name for pacman no
pacman_ignore Ignore package for pacman no
portage Package name for portage no
portage_ignore Ignore package for portage no
opkg Package name for opkg no
opkg_ignore Ignore package for opkg no

By default package_state and item.name are used when managing the packages. If however item.state is defined or a more specific package name (eg item.apt) these will be used instead. If you want a package to be ignored for some package managers you can add ***_ignore: yes.

package_list example
package_list:
  - name: package
  - name: package1
    state: absent
  - name: package2
    apt: package2_apt_name
  - name: package3
    apt_ignore: yes
    yum: package3_yum_name
    pacman: package3_pacman_name
    portage: package3_portage_name

Dependencies

None.

Example Playbook

---
- hosts: servers
  roles:
  - { role: GROG.package,
      become: yes,
        package_list: [
          { name: htop,
            brew: htop-osx },
          { name: tree }
        ]
    }

Contributing

All assistance, changes or ideas welcome!

Author

By G. Roggemans

License

MIT

ansible-role-package's People

Contributors

bersace avatar glennbrown avatar groggemans avatar lidopaglia avatar nwoetzel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ansible-role-package's Issues

Option to skip package on some package managers

Not all package managers have the same amount off packages to get the same thing working.
There should be an option to install a package only on some packages managers and skip it on others.

handling duplicated package

Hello Gertjan,
Having 3 lists of packages is good idea but test please what happens if the package is on more than one list. The role tries to install it twice or three times. It would be good to eliminate duplicates to speed up installation a bit.
Why would you modify the loop slightly changing

with_flattened:
- "{{ package_list }}"
- "{{ package_list_host }}"
- "{{ package_list_group }}"

with singe line of code like:

with_items: "{{ (package_list + package_list_group + package_list_host ) | list | unique }}"

cheers
Marek Krasnowski

the inline if-expression on line 1 evaluated to false and no else section was defined.

Hello!
I'm getting something like this:


TASK [grog.package : Apt] ************************************************************************************************************************************************************************************
fatal: [XXXX]: FAILED! => {"msg": "the inline if-expression on line 1 evaluated to false and no else section was defined."}

ansible 2.9.6

I don't know why it happened only on one host and I don't know where is miisign "else".

package_lists merge?

Hi Grog, thanks again for you work. I've got a group_vars/all.yml that has a list of packages, then host_vars/host1.yml. It looks like if package_list is defined in host1.yml, only the packages in package_list from host_vars/host1.yml get used. I thought these would be merged, but doesn't seem to be the case. Is this user error, or in fact the case? Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.