claranet.apt

Ansible role - apt

Maintainer License Release Status Ansible version Ansible Galaxy

:star: Star us on GitHub — it motivates us a lot!*

Install packages and add repositories on apt based distributions :

:warning: Requirements

Ansible >= 2.10

:zap: Installation

ansible-galaxy install claranet.apt

:gear: Role variables


Variable Default value Description
apt_upgrade false Do an upgrade (no, yes, safe, full, dist)
apt_autoremove true Remove packages that are no longer needed for dependencies
apt_packages [] Packages list to install
apt_repositories [] Repositories list to configure
apt_ppas [] PPA repositories to add
apt_force false Force installs / removes
apt_install_recommends false Install recommended packages
apt_dpkg_options "" Add dpkg options to apt command
apt_default_release "" Set pin priorities (like apt -t)
apt_config_default defaults/main.yml Defaut config for apt, every new config will be merge with it
apt_config {} New config to set, it will be merge with apt_default_config
apt_config_additional_preformatted_config '' Additional preformatted config
apt_config_listchanges_mail null List changes mail
apt_config_unattended_upgrades_package_state 'auto' Unattended upgrades package state
apt_config_unattended_upgrades_timer_override null Unattended upgrades timer override
apt_config_listchanges_package_state 'auto' List changes package state

:arrows_counterclockwise: Dependencies

N/A

:pencil2: Example Playbook

Install packages

- name: bootstrap instance
  hosts: all
  tasks:
    - include_role:
        name: apt
      vars:
        apt_packages:
          # latest packages
          - name: tree
          - name: python-pip
          # specific package version
          - name: vim=2:8.*
          # deb file
          - deb: "http://repo.zabbix.com/zabbix/6.1/{{ ansible_distribution | lower }}/pool/main/z/zabbix-release/zabbix-release_6.1-2+{{ ansible_distribution |lower }}{{ ansible_distribution_version }}_all.deb"ansible_distribution_release }}_all.deb

PPA package installation

- name: ppa-package-install
  hosts: all
  become: true
  roles:
    - role: claranet.apt
  vars:
    apt_upgrade: true
    apt_ppas:
      # nginx ppa repo
      - repo: ppa:nginx/stable
        # not needed on ubuntu distribution
        codename: trusty
    apt_repositories:
      - types: deb # can be string or list
        urls: "https://deb.nodesource.com/node_18.x"
        suites: "{{ ansible_distribution_release | lower }}"
        components: "main"
        key: https://deb.nodesource.com/gpgkey/nodesource.gpg.key # can be url or content of file
        # key: "{{ lookup('url', 'https://deb.nodesource.com/gpgkey/nodesource.gpg.key', split_lines=False) }}"
    apt_packages:
      - name: nginx
      - name: nodejs

Do an upgrade

- hosts: all
  vars:
    # could be safe | full | dist
    apt_upgrade: true
  roles:
    - apt

:closed_lock_with_key: Hardening

:heart_eyes_cat: Contributing

Mozilla Public License Version 2.0

About

Manage apt keys, repos and packages

Install
ansible-galaxy install claranet.apt
GitHub repository
License
mpl-2.0
Downloads
28.6k
Owner
Open source projects from and contributed to by Claranet.