feat: add option to remove packages in a pre-task

This commit is contained in:
Robert Kaussow 2024-01-24 22:13:57 +01:00
parent b7357283e3
commit 3b5b1086cd
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
4 changed files with 59 additions and 56 deletions

View File

@ -17,6 +17,9 @@ packages_enablerepo: []
packages_install: []
packages_install_extra: []
packages_uninstall_pre: []
packages_uninstall_pre_extra: []
packages_uninstall:
- setroubleshoot
- mcstransd

View File

@ -1,10 +0,0 @@
---
- name: Adjust packages config file
template:
src: etc/dnf/dnf.conf.j2
dest: /etc/dnf/dnf.conf
owner: root
group: root
mode: 0644
become: True
become_user: root

View File

@ -1,3 +1,57 @@
---
- include_tasks: config.yml
- include_tasks: repository.yml
- block:
- name: Uninstall pre packages
package:
name: "{{ item }}"
state: absent
loop: "{{ packages_uninstall_pre + packages_uninstall_pre_extra }}"
- name: Adjust packages config file
template:
src: etc/dnf/dnf.conf.j2
dest: /etc/dnf/dnf.conf
owner: root
group: root
mode: 0644
- name: Remove repository files
file:
name: "/etc/yum.repos.d/{{ item }}"
state: absent
loop: "{{ packages_repofiles_remove }}"
loop_control:
label: "/etc/yum.repos.d/{{ item }}"
notify: __packages_clean_metadata
- name: Add common repositories
yum_repository:
name: "{{ item.name }}"
file: "{{ item.filename | default(omit) }}"
description: "{{ item.desc | default(omit) }}"
baseurl: "{{ item.baseurl | default(omit) }}"
gpgkey: "{{ item.gpgkey | default(omit) }}"
gpgcheck: "{{ item.gpgcheck | default('yes') }}"
sslverify: "{{ item.sslverify | default('yes') }}"
enabled: "{{ item.enabled | default('yes') }}"
state: "{{ item.state | default('present') }}"
loop: "{{ packages_yum_repositories + packages_yum_repositories_extra }}"
loop_control:
label: "{{ item.name }}"
notify:
- __packages_upgrade
- __packages_clean_metadata
- name: Uninstall packages
package:
name: "{{ item }}"
state: absent
loop: "{{ packages_uninstall + packages_uninstall_extra }}"
- name: Install common packages
package:
name: "{{ item }}"
enablerepo: "{{ packages_enablerepo }}"
state: present
loop: "{{ packages_install + packages_install_extra }}"
become: True
become_user: root

View File

@ -1,44 +0,0 @@
---
- block:
- name: Remove repository files
file:
name: "/etc/yum.repos.d/{{ item }}"
state: absent
loop: "{{ packages_repofiles_remove }}"
loop_control:
label: "/etc/yum.repos.d/{{ item }}"
notify: __packages_clean_metadata
- name: Add common repositories
yum_repository:
name: "{{ item.name }}"
file: "{{ item.filename | default(omit) }}"
description: "{{ item.desc | default(omit) }}"
baseurl: "{{ item.baseurl | default(omit) }}"
gpgkey: "{{ item.gpgkey | default(omit) }}"
gpgcheck: "{{ item.gpgcheck | default('yes') }}"
sslverify: "{{ item.sslverify | default('yes') }}"
enabled: "{{ item.enabled | default('yes') }}"
state: "{{ item.state | default('present') }}"
loop: "{{ packages_yum_repositories + packages_yum_repositories_extra }}"
loop_control:
label: "{{ item.name }}"
notify:
- __packages_upgrade
- __packages_clean_metadata
- name: Uninstall packages
package:
name: "{{ item }}"
enablerepo: "{{ packages_enablerepo }}"
state: absent
loop: "{{ packages_uninstall + packages_uninstall_extra }}"
- name: Install common packages
package:
name: "{{ item }}"
enablerepo: "{{ packages_enablerepo }}"
state: present
loop: "{{ packages_install + packages_install_extra }}"
become: True
become_user: root