blse2-public/common-debian/tasks/apt-base.yml

93 lines
1.9 KiB
YAML
Raw Permalink Normal View History

2023-05-05 15:47:27 -04:00
---
- name: install apt prerequisite packages
apt:
name:
- gpg
- gnupg
state: latest
when: bootstrap
- set_fact:
update_cache: no
- name: install apt configuration files
template:
src: "etc/apt/apt.conf.d/{{ item }}.j2"
dest: "/etc/apt/apt.conf.d/{{ item }}"
mode: 0644
loop: "{{ apt_configurations }}"
register: configuration
- set_fact:
update_cache: yes
when: configuration.changed
- name: install apt pins configuration file
template:
src: "etc/apt/preferences.d/pins.j2"
dest: "/etc/apt/preferences.d/pins"
mode: 0644
register: pins
- set_fact:
update_cache: yes
when: pins.changed
- name: remove base apt sources files
file:
dest: /etc/apt/sources.list
state: absent
- name: install apt sources files
template:
src: "etc/apt/sources.list.d/source.j2"
dest: "/etc/apt/sources.list.d/{{ item.name }}.list"
mode: 0644
loop: "{{ apt_sources }}"
register: sources
- set_fact:
update_cache: yes
when: sources.changed
- name: install supplemental apt keyrings
apt_key:
url: "{{ item.gpg_url }}"
id: "{{ item.gpg_id }}"
keyring: "/etc/apt/trusted.gpg.d/{{ item.name }}.gpg"
state: present
when: item.gpg_url is defined and item.gpg_url
loop: "{{ apt_sources }}"
register: keyrings
- set_fact:
update_cache: yes
when: keyrings.changed
- name: set apt package preferences
debconf:
name: "{{ item.name }}"
question: "{{ item.question }}"
vtype: "{{ item.vtype }}"
value: "{{ item.value }}"
loop: "{{ apt_preferences }}"
register: preferences
- set_fact:
update_cache: yes
when: preferences.changed
- name: install cleanup scripts
template:
src: "usr/local/sbin/{{ item }}.j2"
dest: "/usr/local/sbin/{{ item }}"
mode: 0755
loop:
- dpkg-cleanup.sh
- kernel-cleanup.sh
- name: update apt cache
apt:
update_cache: yes
when: update_cache