From 15c2048d480aefc09c2aa2c33ae5d9ffedd9217a Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 21 Nov 2019 12:49:57 +0100 Subject: [PATCH] add option to remove whole repo files --- defaults/main.yml | 2 ++ tasks/repository.yml | 39 ++++++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index c6daff2..9e0f234 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -28,6 +28,8 @@ yum_repositories: [] # enabled: True # @end +yum_repofiles_remove: [] + # @var yum_deltarpm_value:description: > # Configure deltarmp. To get it working you have to install `deltarpm` package first! # Value set to `0` means disabled. A positive value defines the number diff --git a/tasks/repository.yml b/tasks/repository.yml index 9f925ec..7527d63 100644 --- a/tasks/repository.yml +++ b/tasks/repository.yml @@ -1,18 +1,27 @@ --- -- name: Add common yum repositories - yum_repository: - name: "{{ item.name }}" - file: "{{ item.filename }}" - 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: "{{ yum_repositories }}" - loop_control: - label: "{{ item.name }}" - notify: __yum_upgrade +- block: + - name: Add common yum repositories + yum_repository: + name: "{{ item.name }}" + file: "{{ item.filename }}" + 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: "{{ yum_repositories }}" + loop_control: + label: "{{ item.name }}" + notify: __yum_upgrade + + - name: Remove repo files + file: + name: "/etc/yum.repos.d/{{ item }}" + state: absent + loop: "{{ yum_repofiles_remove }}" + loop_control: + label: "/etc/yum.repos.d{{ item }}" become: True become_user: root