Optimise apt cache update task

The update of the apt cache and the package installation
can all be handled in a single task by providing the
package action plugin with the right parameters. This
removes an extra task to optimise execution.

The minimum Ansible version is raised to 2.2 due to a
known bug [1] in Ansible's apt module which does not
update the cache properly if the cache update and the
install are combined in a single task.

[1] https://github.com/ansible/ansible-modules-core/issues/1497

Change-Id: I281016d1e836705afec1579192647ed7c6a7e7cd
This commit is contained in:
Jesse Pretorius 2017-04-21 16:55:14 +01:00
parent f5cd194ad6
commit 508ed6aaa2
2 changed files with 4 additions and 7 deletions

View File

@ -15,10 +15,10 @@
galaxy_info:
author: rcbops
description: Installation and setup of HAProxy
description: Installation and setup of pip
company: Rackspace
license: Apache2
min_ansible_version: 1.6.6
min_ansible_version: 2.2
platforms:
- name: Ubuntu
versions:

View File

@ -13,16 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Ensure apt cache is up to date
apt:
update_cache: yes
cache_valid_time: "{{ cache_timeout }}"
# Under Ubuntu, this will only add the key
- name: Install UCA repository key
apt:
name: "{{ pip_install_external_repo_key_package }}"
state: "{{ pip_install_external_repo_key_package_state | default('present') }}"
update_cache: yes
cache_valid_time: "{{ cache_timeout }}"
when:
- user_external_repo_key is not defined
tags: