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:
@ -1,12 +1,21 @@
|
||||
---
|
||||
- name: Add nginx.org apt signing key
|
||||
apt_key: id=0x573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 url=https://nginx.org/keys/nginx_signing.key state=present
|
||||
register: add_nginx_apt_key
|
||||
tags: nginx, packages
|
||||
|
||||
- name: Add nginx.org repo
|
||||
template: src=nginx_org_sources.list.j2 dest=/etc/apt/sources.list.d/nginx_org_sources.list owner=root group=root mode=0644
|
||||
register: add_nginx_apt_repository
|
||||
tags: nginx, packages
|
||||
|
||||
- name: Update apt cache
|
||||
apt:
|
||||
update_cache: yes
|
||||
when:
|
||||
add_nginx_apt_key is changed or
|
||||
add_nginx_apt_repository is changed
|
||||
|
||||
- name: Install nginx
|
||||
apt: pkg=nginx update_cache=yes state=present
|
||||
tags: nginx, packages
|
||||
|
Reference in New Issue
Block a user