2023-10-01 10:30:46 +00:00
|
|
|
# 2023-10-01
|
2023-09-25 08:40:20 +00:00
|
|
|
# Tasks: apt
|
|
|
|
---
|
|
|
|
|
|
|
|
- ansible.builtin.include_vars: "packages/{{ ansible_facts['os_family'] | lower }}.yml"
|
|
|
|
|
2023-10-01 10:30:46 +00:00
|
|
|
#- 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: Check if sources.list exist
|
|
|
|
ansible.builtin.stat:
|
|
|
|
path: "{{ item }}"
|
|
|
|
with_items:
|
|
|
|
- "/etc/apt/sources.list"
|
|
|
|
when:
|
|
|
|
- ansible_facts['system'] == "Linux"
|
|
|
|
- ansible_facts['os_family'] == "Debian"
|
|
|
|
register: sources_list_stat
|
|
|
|
|
|
|
|
- name: Copy sources.list to disabled
|
|
|
|
ansible.builtin.copy:
|
|
|
|
remote_src: true
|
|
|
|
src: "{{ item.stat.path }}"
|
|
|
|
dest: "{{ item.stat.path }}.disabled"
|
|
|
|
with_items:
|
|
|
|
- "{{ sources_list_stat.results }}"
|
|
|
|
when:
|
|
|
|
- item.stat.exists == true
|
|
|
|
- ansible_facts['system'] == "Linux"
|
|
|
|
- ansible_facts['os_family'] == "Debian"
|
|
|
|
|
|
|
|
- name: Remove original sources.list
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ item.stat.path }}"
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- "{{ sources_list_stat.results }}"
|
2023-09-25 08:40:20 +00:00
|
|
|
when:
|
2023-10-01 10:30:46 +00:00
|
|
|
- item.stat.exists == true
|
2023-09-25 08:40:20 +00:00
|
|
|
- ansible_facts['system'] == "Linux"
|
|
|
|
- ansible_facts['os_family'] == "Debian"
|
|
|
|
|
|
|
|
- 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
|