From a9f5b73d5a7dd644d77756ad428c90eed0fe0f2e Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Wed, 9 Mar 2022 22:05:52 +0100 Subject: [PATCH] refactor: remove yum config and fix vars --- defaults/main.yml | 14 +++++++------- tasks/config.yml | 4 ++-- tasks/main.yml | 1 - tasks/packages.yml | 17 ----------------- tasks/repository.yml | 18 ++++++++++++++++-- templates/etc/dnf/dnf.conf.j2 | 8 ++++++++ templates/etc/yum.conf.j2 | 32 -------------------------------- 7 files changed, 33 insertions(+), 61 deletions(-) delete mode 100644 tasks/packages.yml create mode 100644 templates/etc/dnf/dnf.conf.j2 delete mode 100644 templates/etc/yum.conf.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 401ae5f..401f4eb 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,7 +1,7 @@ --- -packages_repositories: [] -# @var packages_repositories:example: > -# packages_repositories: +packages_yum_repositories: [] +# @var packages_yum_repositories:example: > +# packages_yum_repositories: # - name: epel # filename: Extra-EPEL # desc: Extra Packages for Enterprise Linux (EPEL) @@ -9,7 +9,7 @@ packages_repositories: [] # gpgkey: "http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-$releasever/" # enabled: True # @end -packages_repositories_extra: [] +packages_yum_repositories_extra: [] packages_repofiles_remove: [] @@ -26,7 +26,7 @@ packages_upgrade_enabled: False packages_packages_enablerepo: [] -packages_packages_install: [] -packages_packages_install_extra: [] +packages_install: [] +packages_install_extra: [] -packages_packages_uninstall: [] +packages_uninstall: [] diff --git a/tasks/config.yml b/tasks/config.yml index 2f4ce5e..50ec798 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -1,8 +1,8 @@ --- - name: Adjust packages config file template: - src: etc/packages.conf.j2 - dest: /etc/packages.conf + src: etc/dnf/dnf.conf.j2 + dest: /etc/dnf/dnf.conf owner: root group: root mode: 0644 diff --git a/tasks/main.yml b/tasks/main.yml index a41997a..622735c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,4 +1,3 @@ --- - include_tasks: config.yml - include_tasks: repository.yml -- include_tasks: packages.yml diff --git a/tasks/packages.yml b/tasks/packages.yml deleted file mode 100644 index 3e287d6..0000000 --- a/tasks/packages.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -- block: - - name: Remove common packages - package: - name: "{{ item }}" - enablerepo: "{{ packages_packages_enablerepo }}" - state: absent - loop: "{{ packages_packages_uninstall }}" - - - name: Install common packages - package: - name: "{{ item }}" - enablerepo: "{{ packages_packages_enablerepo }}" - state: present - loop: "{{ packages_packages_install + packages_packages_install_extra }}" - become: True - become_user: root diff --git a/tasks/repository.yml b/tasks/repository.yml index af71415..8c27351 100644 --- a/tasks/repository.yml +++ b/tasks/repository.yml @@ -1,7 +1,7 @@ --- - block: - name: Add common package repositories - packages_repository: + yum_repository: name: "{{ item.name }}" file: "{{ item.filename }}" description: "{{ item.desc | default(omit) }}" @@ -11,7 +11,7 @@ sslverify: "{{ item.sslverify | default('yes') }}" enabled: "{{ item.enabled | default('yes') }}" state: "{{ item.state | default('present') }}" - loop: "{{ packages_repositories + packages_repositories_extra }}" + loop: "{{ packages_yum_repositories + packages_yum_repositories_extra }}" loop_control: label: "{{ item.name }}" notify: __packages_upgrade @@ -23,5 +23,19 @@ loop: "{{ packages_repofiles_remove }}" loop_control: label: "/etc/packages.repos.d/{{ item }}" + + - name: Uninstall common packages + package: + name: "{{ item }}" + enablerepo: "{{ packages_packages_enablerepo }}" + state: absent + loop: "{{ packages_uninstall }}" + + - name: Install common packages + package: + name: "{{ item }}" + enablerepo: "{{ packages_packages_enablerepo }}" + state: present + loop: "{{ packages_install + packages_install_extra }}" become: True become_user: root diff --git a/templates/etc/dnf/dnf.conf.j2 b/templates/etc/dnf/dnf.conf.j2 new file mode 100644 index 0000000..66a0239 --- /dev/null +++ b/templates/etc/dnf/dnf.conf.j2 @@ -0,0 +1,8 @@ +#jinja2: lstrip_blocks: True +{{ ansible_managed | comment }} +[main] +gpgcheck=1 +installonly_limit=3 +clean_requirements_on_remove=True +best=True +skip_if_unavailable=False diff --git a/templates/etc/yum.conf.j2 b/templates/etc/yum.conf.j2 deleted file mode 100644 index e0deb8d..0000000 --- a/templates/etc/yum.conf.j2 +++ /dev/null @@ -1,32 +0,0 @@ -#jinja2: lstrip_blocks: True -{{ ansible_managed | comment }} -[main] -cachedir=/var/cache/yum/$basearch/$releasever -keepcache=0 -debuglevel=2 -logfile=/var/log/yum.log -exactarch=1 -obsoletes=1 -gpgcheck=1 -plugins=1 -installonly_limit=5 -bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum -distroverpkg=centos-release -{% if packages_deltarpm_value != 0 %} -deltarpm={{ packages_deltarpm_value }} -deltarpm_percentage={{ packages_deltarpm_percentage }} -{% endif %} - - -# This is the default, if you make this bigger yum won't see if the metadata -# is newer on the remote and so you'll "gain" the bandwidth of not having to -# download the new metadata and "pay" for it by yum not having correct -# information. -# It is esp. important, to have correct metadata, for distributions like -# Fedora which don't keep old packages around. If you don't like this checking -# interupting your command line usage, it's much better to have something -# manually check the metadata once an hour (yum-updatesd will do this). -# metadata_expire=90m - -# PUT YOUR REPOS HERE OR IN separate files named file.repo -# in /etc/yum.repos.d