From 95d7c67acecf7170619d055318a88ad42d748885 Mon Sep 17 00:00:00 2001 From: pjan Date: Thu, 13 Mar 2014 11:45:59 +0800 Subject: [PATCH] Added apt clean-up, updated Readme and defaults --- README.md | 12 ++++++++---- defaults/main.yml | 7 ++++--- handlers/main.yml | 1 - meta/main.yml | 2 +- tasks/main.yml | 15 +++++++++++---- templates/etc_apt_apt.conf.d_10general.j2 | 4 ++-- 6 files changed, 26 insertions(+), 15 deletions(-) delete mode 100644 handlers/main.yml diff --git a/README.md b/README.md index 6441776..f130d21 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,23 @@ ## Ansibles - apt [![Build Status](https://travis-ci.org/Ansibles/apt.png)](https://travis-ci.org/Ansibles/apt) -Update and manage the apt-cache +Ansible role which executes apt-get update to ensure the local APT package cache is up to date. At the same time, it cleans it from packages and .deb files which are no longer needed. + #### Variables ```yaml -apt_cache_valid_time: # time (in seconds) that the apt cache stays valid -apt_install_recommends: # true/false - whether or not to install the "recommended" packages -apt_install_suggests: # true/false - whether or not to install the "suggested" packages +apt_reset_source_list: no # reset the /etc/apt/sources.list to the default +apt_cache_valid_time: 3600 # Time (in seconds) the apt cache stays valid +apt_install_recommends: yes # whether or not to install the "recommended" packages +apt_install_suggests: yes # whether or not to install the "suggested" packages ``` + #### License Licensed under the MIT License. See the LICENSE file for details. + #### Feedback, bug-reports, requests, ... Are [welcome](https://github.com/ansibles/apt/issues)! diff --git a/defaults/main.yml b/defaults/main.yml index 09489f5..08fcb9a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,5 +1,6 @@ # file: apt/defaults/main.yml -apt_cache_valid_time: 3600 -apt_install_recommends: true -apt_install_suggests: true +apt_reset_source_list: no # reset the /etc/apt/sources.list to the default +apt_cache_valid_time: 3600 # Time (in seconds) the apt cache stays valid +apt_install_recommends: yes # whether or not to install the "recommended" packages +apt_install_suggests: yes # whether or not to install the "suggested" packages diff --git a/handlers/main.yml b/handlers/main.yml deleted file mode 100644 index a4214ce..0000000 --- a/handlers/main.yml +++ /dev/null @@ -1 +0,0 @@ -# file: apt/handlers/main.yml diff --git a/meta/main.yml b/meta/main.yml index 5da58c9..35d270d 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -2,7 +2,7 @@ galaxy_info: author: pjan vandaele - description: Update and manage the apt-cache + description: Manages apt and executes apt-get update to ensure the local APT package cache is up to date. min_ansible_version: 1.4 license: MIT platforms: diff --git a/tasks/main.yml b/tasks/main.yml index 676409c..f7b7c89 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,19 +1,26 @@ # file: apt/tasks/main.yml -- name: Aptitude | Update the sources list (/etc/apt/sources.list) +- name: APT | Reset the sources list (/etc/apt/sources.list) copy: src: etc_apt_sources.list dest: /etc/apt/sources.list owner: root group: root mode: 0644 + when: apt_reset_source_list -- name: Aptitude | Update the apt cache +- name: APT | Update the apt cache apt: update_cache: yes cache_valid_time: "{{apt_cache_valid_time}}" -- name: Aptitude | Update the general configuration (/etc/apt/apt.conf.ds/10general) +- name: APT | Remove packages that are no longer needed for dependencies + shell: apt-get -y autoremove + +- name: APT | Remove .deb files for packages no longer on your system + shell: apt-get -y autoclean + +- name: APT | Update the general configuration (/etc/apt/apt.conf.ds/10general) template: src: etc_apt_apt.conf.d_10general.j2 dest: /etc/apt/apt.conf.d/10general @@ -21,7 +28,7 @@ group: root mode: 0644 -- name: Aptitude | Make sure the required packages are installed +- name: APT | Make sure the required packages are installed apt: pkg: "{{item}}" state: present diff --git a/templates/etc_apt_apt.conf.d_10general.j2 b/templates/etc_apt_apt.conf.d_10general.j2 index 7b1f610..9870814 100644 --- a/templates/etc_apt_apt.conf.d_10general.j2 +++ b/templates/etc_apt_apt.conf.d_10general.j2 @@ -1,4 +1,4 @@ -APT::Install-Recommends "{{ apt_install_recommends }}"; -APT::Install-Suggests "{{ apt_install_suggests }}"; +APT::Install-Recommends "{{apt_install_recommends}}"; +APT::Install-Suggests "{{apt_install_suggests}}"; APT::Get::Show-Upgraded "true";