Add support for apt proxy setting

Add support for configuring apt's proxy setting on Ubuntu hosts.

Change-Id: Iea1daff70fca5cf49f4e7f44af71a900678bb5c9
Story: 2009035
Task: 42782
This commit is contained in:
Skylar Kelty 2021-07-06 11:32:46 +01:00 committed by Pierre Riteau
parent f1212d0f07
commit f24b3176eb
10 changed files with 77 additions and 3 deletions

12
ansible/apt.yml Normal file
View File

@ -0,0 +1,12 @@
---
- name: Ensure APT is configured
hosts: seed-hypervisor:seed:overcloud
vars:
ansible_python_interpreter: /usr/bin/python3
tags:
- apt
tasks:
- name: include apt role
include_role:
name: apt
when: ansible_facts.os_family == 'Debian'

View File

@ -4,3 +4,9 @@
# Apt cache TTL in seconds. Default is 3600.
apt_cache_valid_time: 3600
# Apt proxy URL for HTTP. Default is empty (no proxy).
apt_proxy_http:
# Apt proxy URL for HTTPS. Default is {{ apt_proxy_http }}.
apt_proxy_https: "{{ apt_proxy_http }}"

View File

@ -0,0 +1,12 @@
---
###############################################################################
# Apt package manager configuration.
# Apt cache TTL in seconds. Default is 3600.
apt_cache_valid_time: 3600
# Apt proxy URL for HTTP. Default is empty (no proxy).
apt_proxy_http:
# Apt proxy URL for HTTPS. Default is {{ apt_proxy_http }}.
apt_proxy_https: "{{ apt_proxy_http }}"

View File

@ -0,0 +1,17 @@
---
- name: Configure apt proxy
template:
src: "01proxy.j2"
dest: /etc/apt/apt.conf.d/01proxy
owner: root
group: root
mode: 0664
become: true
when: apt_proxy_http | default('', true) | length > 0 or apt_proxy_https | default('', true) | length > 0
- name: Remove old apt proxy config
file:
path: /etc/apt/apt.conf.d/01proxy
state: absent
become: true
when: apt_proxy_http | default('', true) | length == 0 and apt_proxy_https | default('', true) | length == 0

View File

@ -0,0 +1,8 @@
Acquire {
{% if apt_proxy_http | default('', true) | length > 0 -%}
HTTP::proxy "{{ apt_proxy_http }}";
{% endif -%}
{% if apt_proxy_https | default('', true) | length > 0 -%}
HTTPS::proxy "{{ apt_proxy_https }}";
{% endif -%}
}

View File

@ -307,6 +307,10 @@ Apt cache
The Apt cache timeout may be configured via ``apt_cache_valid_time`` (in
seconds) in ``etc/kayobe/apt.yml``, and defaults to 3600.
Apt can be configured to use a proxy via ``apt_proxy_http`` and
``apt_proxy_https`` in ``etc/kayobe/apt.yml``. These should be set to the full
URL of the relevant proxy (e.g. ``http://squid.example.com:3128``).
SELinux
=======
*tags:*

View File

@ -5,6 +5,12 @@
# Apt cache TTL in seconds. Default is 3600.
#apt_cache_valid_time:
# Apt proxy URL for HTTP. Default is empty (no proxy).
#apt_proxy_http:
# Apt proxy URL for HTTPS. Default is {{ apt_proxy_http }}.
#apt_proxy_https:
###############################################################################
# Dummy variable to allow Ansible to accept this file.
workaround_ansible_issue_8743: yes

View File

@ -449,7 +449,7 @@ class SeedHypervisorHostConfigure(KollaAnsibleMixin, KayobeAnsibleMixin,
playbooks = _build_playbook_list(
"ssh-known-host", "kayobe-ansible-user",
"dnf", "pip", "kayobe-target-venv")
"apt", "dnf", "pip", "kayobe-target-venv")
if parsed_args.wipe_disks:
playbooks += _build_playbook_list("wipe-disks")
playbooks += _build_playbook_list(
@ -603,7 +603,7 @@ class SeedHostConfigure(KollaAnsibleMixin, KayobeAnsibleMixin, VaultMixin,
# Run kayobe playbooks.
playbooks = _build_playbook_list(
"ssh-known-host", "kayobe-ansible-user",
"dnf", "pip", "kayobe-target-venv")
"apt", "dnf", "pip", "kayobe-target-venv")
if parsed_args.wipe_disks:
playbooks += _build_playbook_list("wipe-disks")
playbooks += _build_playbook_list(
@ -976,7 +976,7 @@ class OvercloudHostConfigure(KollaAnsibleMixin, KayobeAnsibleMixin, VaultMixin,
# Kayobe playbooks.
playbooks = _build_playbook_list(
"ssh-known-host", "kayobe-ansible-user",
"dnf", "pip", "kayobe-target-venv")
"apt", "dnf", "pip", "kayobe-target-venv")
if parsed_args.wipe_disks:
playbooks += _build_playbook_list("wipe-disks")
playbooks += _build_playbook_list(

View File

@ -317,6 +317,7 @@ class TestCase(unittest.TestCase):
utils.get_data_files_path("ansible", "ssh-known-host.yml"),
utils.get_data_files_path(
"ansible", "kayobe-ansible-user.yml"),
utils.get_data_files_path("ansible", "apt.yml"),
utils.get_data_files_path("ansible", "dnf.yml"),
utils.get_data_files_path("ansible", "pip.yml"),
utils.get_data_files_path(
@ -487,6 +488,7 @@ class TestCase(unittest.TestCase):
utils.get_data_files_path("ansible", "ssh-known-host.yml"),
utils.get_data_files_path(
"ansible", "kayobe-ansible-user.yml"),
utils.get_data_files_path("ansible", "apt.yml"),
utils.get_data_files_path("ansible", "dnf.yml"),
utils.get_data_files_path("ansible", "pip.yml"),
utils.get_data_files_path(
@ -1032,6 +1034,7 @@ class TestCase(unittest.TestCase):
utils.get_data_files_path("ansible", "ssh-known-host.yml"),
utils.get_data_files_path(
"ansible", "kayobe-ansible-user.yml"),
utils.get_data_files_path("ansible", "apt.yml"),
utils.get_data_files_path("ansible", "dnf.yml"),
utils.get_data_files_path("ansible", "pip.yml"),
utils.get_data_files_path(

View File

@ -0,0 +1,6 @@
---
features:
- |
Adds support for configuring apt's proxy setting for Ubuntu hosts.
See `story 2009035
<https://storyboard.openstack.org/#!/story/2009035>`_ for details.