openstack-ansible/playbooks/common-tasks/package-cache-proxy.yml
Kyle L. Henderson caa8732633 Update apt after proxy config is dropped
Added an apt update after the apt proxy configuration file is
dropped. The error that was seen is that certain packages could
not be authenticated. Updating apt after the proxy is configure
solves the issue.

Change-Id: Ib971231f81442b74868e692d7d47b1ce827e9c7d
Closes-Bug: #1649416
2016-12-13 08:36:22 -06:00

57 lines
1.7 KiB
YAML

---
# Copyright 2016, Logan Vig <logan2211@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: test proxy URL for connectivity
uri:
url: "{{ repo_pkg_cache_url }}/acng-report.html"
method: "HEAD"
register: proxy_check
failed_when: false
- name: Drop apt package manager proxy
copy:
content: 'Acquire::http { Proxy "{{ repo_pkg_cache_url }}"; };'
dest: "/etc/apt/apt.conf.d/00apt-cacher-proxy"
register: apt_proxy_dropped
when:
- proxy_check.status == 200
- ansible_os_family == 'Debian'
- repo_pkg_cache_enabled | bool
- name: Update apt when proxy is added
apt:
update_cache: yes
when:
- apt_proxy_dropped | changed
- name: Remove apt package manager proxy
file:
dest: "/etc/apt/apt.conf.d/00apt-cacher-proxy"
state: "absent"
when:
- proxy_check.status != 200
- ansible_os_family == 'Debian'
- repo_pkg_cache_enabled | bool
- name: Drop yum package manager proxy
lineinfile:
line: 'proxy={{ repo_pkg_cache_url }}'
dest: "/etc/yum.conf"
state: "{{ (proxy_check.status == 200) | ternary('present', 'absent') }}"
when:
- ansible_os_family == 'RedHat'
- repo_pkg_cache_enabled | bool