/ansible-role-manage-pkg-ubuntu

Makes it easier to add/remove DEB repositories and install/purge packages on an Ubuntu host.

Primary LanguageJinjaMIT LicenseMIT

manage-pkg-ubuntu

Build Status GitHub tag Ansible Role

Makes it easier to add DEB repositories and install packages on an Ubuntu host.

Steps performed are:

  • Get updated facts about the current Ubuntu running state
  • Update apt package cache
  • Make sure all needed dependency packages are installed
  • Add all keys used to authenticate deb trusted packages
  • Add all apt repositories
  • Refresh apt package cache for new repos
  • Add all deb packages

❗ Requirements


None.

🔡 Role Variables


Variable Description Default Value
__manage_pkg_dependency Default dependencies needed by the role [apt-transport-https, ca-certificates, gnupg-agent]
manage_pkg_key_do Pick the operation to perform on listed keys (present or absent) present
manage_pkg_key List of keys to add (Check Example) [{key: <HEX-KEY>, url: <key-server-url>}]
manage_pkg_repo_do Pick the operation to perform on listed repos (present or absent) present
manage_pkg_repo List of deb repositories (Check Example for formats) []
manage_pkg_dependency List of dependencies "{{ __manage_pkg_dependency }}"
manage_pkg_app_do Pick the operation to perform on listed deb packages (present or absent) present
manage_pkg_app_install_recommends Wheter or not to also add all recommended deb pkgs related to the ones to install no
manage_pkg_app List of applications to install []

🔗 Dependencies


To install dependencies use:

    $ ansible-galaxy install <dependecy.name>

Installation of the required Ansible Roles can also be simply addressed with:

    $ ansible-galaxy install -r requirements.yml

📓 Example Playbook


Here an example of how to use this role in your playbooks:

---
- hosts: servers
  remote_user: ubuntu   # optional (your remote user)
  gather_facts: yes     # optional
  become: yes

  roles:
    - { role: itnok.manage_pkg_ubuntu }

  vars:
    docker_dependency:    # optional (Pick whatever name you like for this variable)
      - curl
      - software-properties-common
    manage_pkg_dependency: "{{ manage_pkg_dependency + docker_dependency }}"
    manage_pkg_key:
      - { key: "", url: "https://download.docker.com/linux/ubuntu/gpg" }
    manage_pkg_repo:
      - "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
      - "ppa:embrosyn/cinnamon"
      - "ppa:noobslab/macbuntu"
    manage_pkg_app:
      - "cinnamon"
      - "docker-ce"
      - "macbuntu-os-icons-v1804"
      - "macbuntu-os-ithemes-v1804"
      - "macbuntu-os-plank-theme-v1804"
      - "plank"

💂‍♂️ License


MIT (read more)