Code Monkey home page Code Monkey logo

aptitude's Introduction

aptitude

pipeline

travis

readthedocs

Ansible role to use as a wrapper for apt to manage packages.

avatar

Full documentation on Readthedocs.

Source code on:

Github.

Gitlab.

Part of:

doombot

Ingredients

ingredient

Contents

Description

Ansible role to use as a wrapper for apt to manage packages.

This role performs the following actions:

  • Ensure the requirements are installed.
  • Ensure the current user can obtain administrative (root)
    permissions.
  • Update the apt cache.
  • If the packages_purge variable is defined, purge the packages
    listed on it.
  • If the configuration variable is defined, purge the
    packages_purge listed on it.
  • If the packages variable is defined, install the packages
    listed on it.
  • If the configuration variable is defined, install the packages
    listed on it.

Usage

  • To install and execute:
ansible-galaxy install constrict0r.aptitude
ansible localhost -m include_role -a name=constrict0r.aptitude -K
  • Passing variables:
ansible localhost -m include_role -a name=constrict0r.aptitude -K \
    -e "{packages: [gedit, rolldice]}"
  • To include the role on a playbook:
- hosts: servers
  roles:
      - {role: constrict0r.aptitude}
  • To include the role as dependency on another role:
dependencies:
  - role: constrict0r.aptitude
    packages: [gedit, rolldice]
  • To use the role from tasks:
- name: Execute role task.
  import_role:
    name: constrict0r.aptitude
  vars:
    packages: [gedit, rolldice]

To run tests:

cd aptitude
chmod +x testme.sh
./testme.sh

On some tests you may need to use sudo to succeed.

Variables

The following variables are supported:

packages

List of packages to install via apt.

This list can be modified by passing a packages array when including the role on a playbook or via –extra-vars from a terminal.

This variable is empty by default.

# Including from terminal.
ansible localhost -m include_role -a name=constrict0r.aptitude -K -e \
    "{packages: [gedit, rolldice]}"

# Including on a playbook.
- hosts: servers
  roles:
    - role: constrict0r.aptitude
      packages:
        - gedit
        - rolldice

# To a playbook from terminal.
ansible-playbook -i inventory my-playbook.yml -K -e \
    "{packages: [gedit, rolldice]}"

packages_purge

List of packages to purge using apt.

This list can be modified by passing a packages_purge array when including the role on a playbook or via –extra-vars from a terminal.

This variable is empty by default.

# Including from terminal.
ansible localhost -m include_role -a name=constrict0r.aptitude -K -e \
    "{packages_purge: [gedit, rolldice]}"

# Including on a playbook.
- hosts: servers
  roles:
    - role: constrict0r.aptitude
      packages_purge:
        - gedit
        - rolldice

# To a playbook from terminal.
ansible-playbook -i inventory my-playbook.yml -K -e \
    "{packages_purge: [gedit, rolldice]}"

configuration

Absolute file path or URL to a .yml file that contains all or some of the variables supported by this role.

It is recommended to use a .yml or .yaml extension for the configuration file.

This variable is empty by default.

# Using file path.
ansible localhost -m include_role -a name=constrict0r.aptitude -K -e \
    "configuration=/home/username/my-config.yml"

# Using URL.
ansible localhost -m include_role -a name=constrict0r.aptitude -K -e \
    "configuration=https://my-url/my-config.yml"

To see how to write a configuration file see the YAML file format section.

YAML

When passing configuration files to this role as parameters, it’s recommended to add a .yml or .yaml extension to the each file.

It is also recommended to add three dashes at the top of each file:

---

You can include in the file the variables required for your tasks:

---
packages:
  - [gedit, rolldice]

If you want this role to load list of items from files and URLs you can set the expand variable to true:

---
packages: /home/username/my-config.yml

expand: true

If the expand variable is false, any file path or URL found will be treated like plain text.

Attributes

On the item level you can use attributes to configure how this role handles the items data.

The attributes supported by this role are:

item_expand

Boolean value indicating if treat this item as a file path or URL or just treat it as plain text.

---
packages:
  - item_expand: true
    item_path: /home/username/my-config.yml

item_path

Absolute file path or URL to a .yml file.

---
packages:
  - item_path: /home/username/my-config.yml

This attribute also works with URLs.

Requirements

If you want to run the tests, you will also need:

Compatibility

License

MIT. See the LICENSE file for more details.

Links

UML

Deployment

The full project structure is shown below:

deploy

Main

The project data flow is shown below:

main

Author

author

The Travelling Vaudeville Villain.

Enjoy!!!

enjoy

aptitude's People

Watchers

 avatar  avatar

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.