extract APT configuration into apt role

This commit is contained in:
Jérémy Lecour 2017-10-10 16:34:53 +02:00 committed by Jérémy Lecour
parent 517c0e672b
commit fae9cd9208
4 changed files with 57 additions and 0 deletions

View file

@ -11,6 +11,7 @@ Tasks are extracted in several files, included in `tasks/main.yml` :
## Available variables
* `apt_config` : customize apt configuration (default: `True`) ;
* `apt_install_basics` : change basic sources components (default: `True`) ;
* `apt_basics_components` : basic sources components (default: `main`) ;
* `apt_install_backports` : install backports sources (default: `False`) ;

View file

@ -1,4 +1,10 @@
---
apt_config: True
apt_evolinux_config: True
apt_hooks: True
apt_remove_aptitude: True
apt_upgrade: True
apt_install_basics: True
apt_basics_components: "main"

44
apt/tasks/config.yml Normal file
View file

@ -0,0 +1,44 @@
---
- name: Evolinux config for APT
lineinfile:
dest: /etc/apt/apt.conf.d/z-evolinux.conf
line: "{{ item.line }}"
regexp: "{{ item.regexp }}"
create: yes
state: present
mode: "0640"
with_items:
- { line: "APT::Install-Recommends \"false\";", regexp: 'APT::Install-Recommends' }
- { line: "APT::Install-Suggests \"false\";", regexp: 'APT::Install-Suggests' }
when: apt_evolinux_config
- name: DPkg invoke hooks
lineinfile:
dest: /etc/apt/apt.conf.d/z-evolinux.conf
line: "{{ item }}"
create: yes
state: present
mode: "0640"
with_items:
- "DPkg::Pre-Invoke { \"df /tmp | grep -q /tmp && mount -oremount,exec /tmp || true\"; };"
- "DPkg::Pre-Invoke { \"df /usr | grep -q /usr && mount -oremount,rw /usr || true\"; };"
- "DPkg::Post-Invoke { \"df /tmp | grep -q /tmp && mount -oremount /tmp || true\"; };"
- "DPkg::Post-Invoke { \"df /usr | grep -q /usr && mount -oremount /usr || true\"; };"
when: apt_hooks
- name: Remove Aptitude
apt:
name: aptitude
state: absent
when: apt_remove_aptitude
- name: Updating APT cache
apt:
update_cache: yes
changed_when: False
- name: Upgrading system
apt:
upgrade: dist
when: apt_upgrade

View file

@ -7,6 +7,12 @@
tags:
- apt
- name: Custom configuration
include: config.yml
when: apt_config
tags:
- apt
- name: Install basics repositories
include: basics.yml
when: apt_install_basics