From 29d73eed7a175f8d4126570c3321dc966f0547f1 Mon Sep 17 00:00:00 2001 From: Pierre Riteau Date: Wed, 6 Oct 2021 12:23:23 +0200 Subject: [PATCH] Set proxy option in early dnf invocation If hosts need to use a proxy to install packages and python is absent, the call to install the python package will hang, at least on CentOS. Set proxy if it exists in dnf_config using a command-line option. Later uses of dnf will be after dnf.conf has been updated. Change-Id: Ic949577afd3ea07306cebf224637a08a1ecce0f5 Story: 2009274 Task: 43528 --- ansible/kayobe-ansible-user.yml | 6 +++++- releasenotes/notes/dnf-proxy-22a6eb457c06a223.yaml | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/dnf-proxy-22a6eb457c06a223.yaml diff --git a/ansible/kayobe-ansible-user.yml b/ansible/kayobe-ansible-user.yml index 5ca11cf02..cfb6bdcf0 100644 --- a/ansible/kayobe-ansible-user.yml +++ b/ansible/kayobe-ansible-user.yml @@ -40,6 +40,9 @@ gather_facts: no vars: ansible_user: "{{ bootstrap_user }}" + dnf_options: + - "-y" + - "{% if 'proxy' in dnf_config %}--setopt=proxy={{ dnf_config['proxy'] }}{% endif %}" tags: - ensure-python tasks: @@ -49,8 +52,9 @@ failed_when: false register: check_python + # TODO(priteau): Support apt proxy - name: Ensure python is installed - raw: test -e /usr/bin/apt && (sudo apt -y update && sudo apt install -y python3-minimal) || (sudo dnf -y install python3) + raw: "test -e /usr/bin/apt && (sudo apt -y update && sudo apt install -y python3-minimal) || (sudo dnf {{ dnf_options | select | join(' ') }} install python3)" when: check_python.rc != 0 - name: Ensure the Kayobe Ansible user account exists diff --git a/releasenotes/notes/dnf-proxy-22a6eb457c06a223.yaml b/releasenotes/notes/dnf-proxy-22a6eb457c06a223.yaml new file mode 100644 index 000000000..fca378ee5 --- /dev/null +++ b/releasenotes/notes/dnf-proxy-22a6eb457c06a223.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Sets proxy option when using ``dnf`` during user bootstrapping, before + ``dnf.conf`` is updated. This allows Kayobe to install Python 3 during host + configuration when ``dnf`` requires a proxy to operate.