From a92684fb148ee0ab3260ec42f473338a412d4095 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Mon, 4 Feb 2019 19:29:53 +0000 Subject: [PATCH] Support configuration of yum.conf Options are configured via the 'yum_config' variable. Change-Id: Iaf46dbf22e0ad2b9e43926e899ce454d19662cc3 Story: 2004935 Task: 29327 --- ansible/roles/yum/defaults/main.yml | 4 ++++ .../yum/tasks/{redhat.yml => local-mirror.yml} | 1 - ansible/roles/yum/tasks/main.yml | 11 ++++++++++- doc/source/configuration/hosts.rst | 13 +++++++++++++ etc/kayobe/yum.yml | 4 ++++ releasenotes/notes/yum-config-58274185a00004e8.yaml | 5 +++++ 6 files changed, 36 insertions(+), 2 deletions(-) rename ansible/roles/yum/tasks/{redhat.yml => local-mirror.yml} (99%) create mode 100644 releasenotes/notes/yum-config-58274185a00004e8.yaml diff --git a/ansible/roles/yum/defaults/main.yml b/ansible/roles/yum/defaults/main.yml index 2556ada91..3e76db727 100644 --- a/ansible/roles/yum/defaults/main.yml +++ b/ansible/roles/yum/defaults/main.yml @@ -1,4 +1,8 @@ --- +# Yum configuration. Dict mapping Yum config option names to their values. +# yum_config: +# proxy: http://proxy.example.com +yum_config: {} # Whether or not to use a local Yum mirror. yum_use_local_mirror: false diff --git a/ansible/roles/yum/tasks/redhat.yml b/ansible/roles/yum/tasks/local-mirror.yml similarity index 99% rename from ansible/roles/yum/tasks/redhat.yml rename to ansible/roles/yum/tasks/local-mirror.yml index 0b8f16967..02557a00f 100644 --- a/ansible/roles/yum/tasks/redhat.yml +++ b/ansible/roles/yum/tasks/local-mirror.yml @@ -1,5 +1,4 @@ --- - - name: Replace | Disable YUM fastestmirror plugin (CentOS) replace: dest: /etc/yum/pluginconf.d/fastestmirror.conf diff --git a/ansible/roles/yum/tasks/main.yml b/ansible/roles/yum/tasks/main.yml index 25a170709..e23a47586 100644 --- a/ansible/roles/yum/tasks/main.yml +++ b/ansible/roles/yum/tasks/main.yml @@ -1,6 +1,15 @@ --- - block: - - include_tasks: redhat.yml + - name: Ensure yum.conf configuration exists + ini_file: + path: /etc/yum.conf + section: "main" + option: "{{ item.key }}" + value: "{{ item.value }}" + loop: "{{ query('dict', yum_config) }}" + become: true + + - include_tasks: local-mirror.yml when: yum_use_local_mirror | bool - include_tasks: custom_repo.yml diff --git a/doc/source/configuration/hosts.rst b/doc/source/configuration/hosts.rst index 771c88fa8..d62b33e91 100644 --- a/doc/source/configuration/hosts.rst +++ b/doc/source/configuration/hosts.rst @@ -176,6 +176,19 @@ Package Repositories Kayobe supports configuration of package repositories via Yum, via variables in ``${KAYOBE_CONFIG_PATH}/yum.yml``. +Configuration of yum.conf +------------------------- + +Global configuration of Yum is stored in ``/etc/yum.conf``, and options can be +set via the ``yum_config`` variable. Options are added to the ``[main]`` +section of the file. For example, to configure Yum to use a proxy server: + +.. code-block:: yaml + :caption: ``yum.yml`` + + yum_config: + proxy: https://proxy.example.com + CentOS and EPEL Mirrors ----------------------- diff --git a/etc/kayobe/yum.yml b/etc/kayobe/yum.yml index 2bc32017d..985ab924f 100644 --- a/etc/kayobe/yum.yml +++ b/etc/kayobe/yum.yml @@ -1,4 +1,8 @@ --- +# Yum configuration. Dict mapping Yum config option names to their values. +# yum_config: +# proxy: http://proxy.example.com +#yum_config: # Whether or not to use a local Yum mirror. #yum_use_local_mirror: false diff --git a/releasenotes/notes/yum-config-58274185a00004e8.yaml b/releasenotes/notes/yum-config-58274185a00004e8.yaml new file mode 100644 index 000000000..016204ccf --- /dev/null +++ b/releasenotes/notes/yum-config-58274185a00004e8.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Adds support for configuration of options in ``/etc/yum.conf``, via the + ``yum_config`` variable.