Skip to content
Snippets Groups Projects
main.yml 4.20 KiB
---

- name: REPOS
  ansible.builtin.include_tasks: repos.yml

# Upgrade already installed packages to latest version and clean system

- name: apt update
  ansible.builtin.apt:
    force_apt_get: true
    install_recommends: false
    update_cache: true
  register: apt_status
  retries: 60
  until: apt_status is success or ('Failed to lock apt for exclusive operation' not in apt_status.msg and '/var/lib/dpkg/lock' not in apt_status.msg)
  changed_when: false

- name: apt dist upgrade
  ansible.builtin.apt:
    force_apt_get: true
    install_recommends: false
    upgrade: dist
  register: apt_status
  retries: 60
  until: apt_status is success or ('Failed to lock apt for exclusive operation' not in apt_status.msg and '/var/lib/dpkg/lock' not in apt_status.msg)

- name: apt clean and autoremove
  ansible.builtin.apt:
    force_apt_get: true
    install_recommends: false
    autoclean: true
    autoremove: true
  register: apt_status
  retries: 60
  until: apt_status is success or ('Failed to lock apt for exclusive operation' not in apt_status.msg and '/var/lib/dpkg/lock' not in apt_status.msg)

# Install new packages and remove conflicts

- name: install system utilities
  ansible.builtin.apt:
    force_apt_get: true
    install_recommends: false
    name: "{{ sysconfig_packages }}"
    state: latest
  register: apt_status
  retries: 60
  until: apt_status is success or ('Failed to lock apt for exclusive operation' not in apt_status.msg and '/var/lib/dpkg/lock' not in apt_status.msg)

- name: remove conflicting packages
  ansible.builtin.apt:
    force_apt_get: true
    install_recommends: false
    name:
      - exim4
      - exim4-base
      - exim4-config
      - exim4-daemon-light
    state: absent
    purge: true
  register: apt_status
  retries: 60
  until: apt_status is success or ('Failed to lock apt for exclusive operation' not in apt_status.msg and '/var/lib/dpkg/lock' not in apt_status.msg)

# Enable automatic security upgrades

- name: install unattended-upgrades
  ansible.builtin.apt:
    force_apt_get: true
    install_recommends: false
    name: unattended-upgrades