Improve support for HTTP proxy

- Configure the package manager (yum or dnf) to support the proxy
  parameter.
- Pass the proxy parameters when using redhat_subscription module.
- Adding rhsm_rhsm_proxy_proto to not hardcode http in the proxy
  url.

rhbz#1816255

Change-Id: I64b2dc97c512cecb7f4e6bcfa283733b3f2c1dc8
This commit is contained in:
Emilien Macchi 2020-03-23 15:53:58 -04:00
parent 6c67a4085a
commit 7987a09f6e
5 changed files with 36 additions and 0 deletions

View File

@ -34,6 +34,7 @@ Role Variables
| `rhsm_server_prefix` | `/subscription` or `/rhsm` | RHS server prefix. `/subscription` when using registering via `portal`, `/rhsm` when registering via `satellite`. |
| `rhsm_insecure` | `False` | Disable certificate validation. |
| `rhsm_ssl_verify_depth` | `3` | Depths certificates should be validated when checking. |
| `rhsm_rhsm_proxy_proto` | `[undefined]` | protocol used to reach the proxy server (http or https). |
| `rhsm_rhsm_proxy_hostname` | `[undefined]` | FQDN of outbound proxy server. |
| `rhsm_rhsm_proxy_port` | `[undefined]` | Port to use for proxy server. |
| `rhsm_rhsm_proxy_user` | `[undefined]` | Username to use for proxy server. |

View File

@ -17,6 +17,7 @@ rhsm_server_hostname: subscription.rhn.redhat.com
rhsm_server_prefix: "{{ '/rhsm' if rhsm_method == 'satellite' else '/subscription' }}"
rhsm_insecure: False
rhsm_ssl_verify_depth: 3
# rhsm_rhsm_proxy_proto: ""
# rhsm_rhsm_proxy_hostname: ""
# rhsm_rhsm_proxy_port: ""
# rhsm_rhsm_proxy_user: ""

View File

@ -23,6 +23,32 @@
- rhsm
- rhsm_conf
- name: Block to set rhsm_package_manager_config_file
tags:
- rhsm
- rhsm_conf
block:
- name: Set rhsm_package_manager_config_file for yum
set_fact:
rhsm_package_manager_config_file: /etc/yum.conf
when:
- ansible_facts.ansible_pkg_mgr == 'yum'
- name: Set rhsm_package_manager_config_file for dnf
set_fact:
rhsm_package_manager_config_file: /etc/dnf/dnf.conf
when:
- ansible_facts.ansible_pkg_mgr == 'dnf'
- name: Configure proxy settings to package manager
ini_file:
path: "{{ rhsm_package_manager_config_file }}"
section: main
option: proxy
value: "{{ rhsm_rhsm_proxy_proto | default('http') }}://{{ rhsm_rhsm_proxy_hostname }}:{{ rhsm_rhsm_proxy_port }}"
tags:
- rhsm
- rhsm_conf
- block:
- include_tasks: "{{ rhsm_method }}.yml"
tags:

View File

@ -15,6 +15,10 @@
consumer_name: "{{ rhsm_consumer_hostname | default(omit) }}"
force_register: True
rhsm_baseurl: "{{ rhsm_baseurl | default(omit) }}"
server_proxy_hostname: "{{ rhsm_rhsm_proxy_hostname | default(omit) }}"
server_proxy_port: "{{ rhsm_rhsm_proxy_port | default(omit) }}"
server_proxy_user: "{{ rhsm_rhsm_proxy_user | default(omit) }}"
server_proxy_password: "{{ rhsm_rhsm_proxy_password | default(omit) }}"
register: subscrition_result
tags:
- rhsm

View File

@ -10,6 +10,10 @@
consumer_name: "{{ rhsm_consumer_hostname | default(omit) }}"
force_register: "{{ rhsm_force_register | default(omit) }}"
rhsm_baseurl: "{{ rhsm_baseurl | default(omit) }}"
server_proxy_hostname: "{{ rhsm_rhsm_proxy_hostname | default(omit) }}"
server_proxy_port: "{{ rhsm_rhsm_proxy_port | default(omit) }}"
server_proxy_user: "{{ rhsm_rhsm_proxy_user | default(omit) }}"
server_proxy_password: "{{ rhsm_rhsm_proxy_password | default(omit) }}"
register: subscrition_result
tags:
- rhsm