ansible/roles/common/tasks/packages.yml
2023-09-25 10:40:20 +02:00

80 lines
1.6 KiB
YAML

# 2023-09-25
# Tasks: apt
---
- ansible.builtin.include_vars: "packages/{{ ansible_facts['os_family'] | lower }}.yml"
- name: Comment all entries in sources.list
ansible.builtin.replace:
backup: true
path: /etc/apt/sources.list
regexp: '^(.*)$'
replace: '# \1'
when:
- ansible_facts['system'] == "Linux"
- ansible_facts['os_family'] == "Debian"
tags:
- apt
- sources
- cdrom
- name: Process packages repositories template
ansible.builtin.template:
backup: true
src: "{{ sources_list_template }}"
dest: "{{ sources_list_distribution }}"
owner: root
group: root
mode: u=rw,g=r,o=r
when:
- ansible_facts['system'] == "Linux"
- ansible_facts['os_family'] == "Debian"
tags:
- system
- packages
- template
- repositories
- debian
- name: Upgrade packages
ansible.builtin.apt:
state: present
install_recommends: no
update_cache: yes
upgrade: full
when:
- ansible_facts['system'] == "Linux"
- ansible_facts['os_family'] == "Debian"
tags:
- system
- packages
- add
- name: Install packages
ansible.builtin.apt:
state: present
install_recommends: no
update_cache: yes
name: "{{ packages_needed }}"
when:
- ansible_facts['system'] == "Linux"
- ansible_facts['os_family'] == "Debian"
tags:
- system
- packages
- add
- name: Remove packages
ansible.builtin.apt:
state: absent
autoclean: true
autoremove: true
name: "{{ packages_removed }}"
when:
- ansible_facts['system'] == "Linux"
- ansible_facts['os_family'] == "Debian"
tags:
- system
- packages
- add