Smarter updating of apt index during playbook execution

We can register changes when adding repositories and keys and then
update the apt package index conditionally. This should make it be
more consistent between initial host setup and subsequent re-runs.
This commit is contained in:
2019-03-17 17:29:15 +02:00
parent dee90ed4bc
commit c5b5cda3d3
3 changed files with 27 additions and 0 deletions

View File

@ -1,12 +1,21 @@
---
- name: Add GPG key for MariaDB repo
apt_key: id=0x177F4010FE56CA3336300305F1656F24C74CD1D8 url=https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x177F4010FE56CA3336300305F1656F24C74CD1D8
register: add_mariadb_apt_key
tags: mariadb, packages
- name: Add MariaDB 10.3 repo
template: src=mariadb.list.j2 dest=/etc/apt/sources.list.d/mariadb.list owner=root group=root mode=0644
register: add_mariadb_apt_repository
tags: mariadb, packages
- name: Update apt cache
apt:
update_cache: yes
when:
add_mariadb_apt_key is changed or
add_mariadb_apt_repository is changed
- name: Install mariadb-server
apt: name={{ item }} state=present update_cache=yes
loop: