From 201165cff662caad9b51508272e7f8f2eece7b0c Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Mon, 22 Aug 2016 15:33:57 +0300 Subject: [PATCH] Only update packages indexes if the cache is 1 hour old I have added cache_valid_time=3600 for the first task in each tag that could be possibly running apt-related commands. For ex, the "nginx" tag is also in the "packages" tag, but sometimes you run the nginx tag by itself (perhaps repeatadely), so you'd want to limit the update unless the cache was 1 hour old --- roles/common/tasks/iptables_Debian.yml | 2 +- roles/common/tasks/iptables_Ubuntu.yml | 2 +- roles/common/tasks/packages_Debian.yml | 2 +- roles/common/tasks/packages_Ubuntu.yml | 2 +- roles/mariadb/tasks/main.yml | 2 +- roles/nginx/tasks/main.yml | 2 +- roles/php-fpm/tasks/Debian.yml | 2 +- roles/php-fpm/tasks/Ubuntu.yml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/roles/common/tasks/iptables_Debian.yml b/roles/common/tasks/iptables_Debian.yml index 7a90b16..ff9f09d 100644 --- a/roles/common/tasks/iptables_Debian.yml +++ b/roles/common/tasks/iptables_Debian.yml @@ -1,7 +1,7 @@ --- - name: Install firewalld and deps when: ansible_distribution_major_version == '8' - apt: pkg={{ item }} state=latest + apt: pkg={{ item }} state=latest update_cache=yes cache_valid_time=3600 with_items: - firewalld - tidy diff --git a/roles/common/tasks/iptables_Ubuntu.yml b/roles/common/tasks/iptables_Ubuntu.yml index e13becd..ea603b0 100644 --- a/roles/common/tasks/iptables_Ubuntu.yml +++ b/roles/common/tasks/iptables_Ubuntu.yml @@ -1,7 +1,7 @@ --- - name: Install iptables-persistent when: ansible_distribution_version == '14.04' - apt: pkg=iptables-persistent update_cache=yes + apt: pkg=iptables-persistent update_cache=yes cache_valid_time=3600 tags: packages - name: Copy /etc/iptables/rules.v4 diff --git a/roles/common/tasks/packages_Debian.yml b/roles/common/tasks/packages_Debian.yml index f0a072c..4b08cbc 100644 --- a/roles/common/tasks/packages_Debian.yml +++ b/roles/common/tasks/packages_Debian.yml @@ -3,7 +3,7 @@ template: src=sources.list.j2 dest=/etc/apt/sources.list owner=root group=root mode=0644 - name: Install base packages - apt: name={{ item }} update_cache=yes + apt: name={{ item }} update_cache=yes cache_valid_time=3600 with_items: - git - tmux diff --git a/roles/common/tasks/packages_Ubuntu.yml b/roles/common/tasks/packages_Ubuntu.yml index ef40454..b189ddc 100644 --- a/roles/common/tasks/packages_Ubuntu.yml +++ b/roles/common/tasks/packages_Ubuntu.yml @@ -7,7 +7,7 @@ when: ansible_distribution_version == '14.04' - name: Upgrade base OS - apt: upgrade=dist update_cache=yes + apt: upgrade=dist update_cache=yes cache_valid_time=3600 - name: Install base packages apt: pkg={{ item }} diff --git a/roles/mariadb/tasks/main.yml b/roles/mariadb/tasks/main.yml index 52e054d..02918cb 100644 --- a/roles/mariadb/tasks/main.yml +++ b/roles/mariadb/tasks/main.yml @@ -15,7 +15,7 @@ tags: mariadb, packages - name: Install mariadb-server - apt: name={{ item }} state=present update_cache=yes + apt: name={{ item }} state=present update_cache=yes cache_valid_time=3600 with_items: - mariadb-server - python-mysqldb # for ansible diff --git a/roles/nginx/tasks/main.yml b/roles/nginx/tasks/main.yml index 8f92dba..7c91952 100644 --- a/roles/nginx/tasks/main.yml +++ b/roles/nginx/tasks/main.yml @@ -8,7 +8,7 @@ tags: nginx, packages - name: Install nginx - apt: pkg=nginx update_cache=yes state=latest + apt: pkg=nginx update_cache=yes state=latest cache_valid_time=3600 tags: nginx, packages - name: Copy nginx configs diff --git a/roles/php-fpm/tasks/Debian.yml b/roles/php-fpm/tasks/Debian.yml index 371c975..8699d2e 100644 --- a/roles/php-fpm/tasks/Debian.yml +++ b/roles/php-fpm/tasks/Debian.yml @@ -1,6 +1,6 @@ --- - name: Install php5-fpm and deps - apt: name={{ item }} state=present update_cache=yes + apt: name={{ item }} state=present update_cache=yes cache_valid_time=3600 with_items: - php5-fpm # for WordPress diff --git a/roles/php-fpm/tasks/Ubuntu.yml b/roles/php-fpm/tasks/Ubuntu.yml index c2ec940..7eb14a3 100644 --- a/roles/php-fpm/tasks/Ubuntu.yml +++ b/roles/php-fpm/tasks/Ubuntu.yml @@ -1,6 +1,6 @@ --- - name: Install php7.0-fpm and deps - apt: name={{ item }} state=present update_cache=yes + apt: name={{ item }} state=present update_cache=yes cache_valid_time=3600 with_items: - php7.0-fpm # for WordPress