From de7f9c38f995aceb9e05ed0754946e708085ca11 Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Fri, 19 Jun 2015 10:49:39 -0500 Subject: [PATCH] downstream-setup: add tasks to disable and enable yum repos. This works similar to downloading yum_repos. You can specific a repo file to disable using 'disable_yum_repos' and enable them by using 'enable_yum_repos'. If you use 'disable_yum_repos' with 'cleanup' it will enable the repos listed in 'disable_yum_repos' - this feature is used with teuthology and the Ansible task. Signed-off-by: Andrew Schoen --- roles/downstream-setup/defaults/main.yml | 14 ++++++++++++++ .../tasks/disable_yum_repos.yml | 9 +++++++++ .../tasks/enable_yum_repos.yml | 9 +++++++++ roles/downstream-setup/tasks/main.yml | 18 ++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 roles/downstream-setup/tasks/disable_yum_repos.yml create mode 100644 roles/downstream-setup/tasks/enable_yum_repos.yml diff --git a/roles/downstream-setup/defaults/main.yml b/roles/downstream-setup/defaults/main.yml index 3c5390b..617a1f2 100644 --- a/roles/downstream-setup/defaults/main.yml +++ b/roles/downstream-setup/defaults/main.yml @@ -20,3 +20,17 @@ yum_repos: [] # a list of repo names as strings to delete from /etc/yum.repos.d # the name should not include the .repo extension remove_yum_repos: [] + +# a list of repo names as strings to disable in /etc/yum.repos.d +# the name should not include the .repo extension +# When using the disable_yum_repos var and if cleanup is true it will +# delete the repos instead of creating them. +# NOTE: this does not work on repo files with multiple entries in them, +# it will only disable the first entry in the repo file. +disable_yum_repos: [] + +# a list of repo names as strings to enable in /etc/yum.repos.d +# the name should not include the .repo extension +# NOTE: this does not work on repo files with multiple entries in them, +# it will only enable the first entry in the repo file. +enable_yum_repos: [] diff --git a/roles/downstream-setup/tasks/disable_yum_repos.yml b/roles/downstream-setup/tasks/disable_yum_repos.yml new file mode 100644 index 0000000..022eea1 --- /dev/null +++ b/roles/downstream-setup/tasks/disable_yum_repos.yml @@ -0,0 +1,9 @@ +--- +- name: Disable yum repos. + lineinfile: + dest: "/etc/yum.repos.d/{{ item }}.repo" + line: "enabled=0" + regexp: "enabled=1" + backrefs: yes + state: present + with_items: disable_yum_repos diff --git a/roles/downstream-setup/tasks/enable_yum_repos.yml b/roles/downstream-setup/tasks/enable_yum_repos.yml new file mode 100644 index 0000000..1920e9c --- /dev/null +++ b/roles/downstream-setup/tasks/enable_yum_repos.yml @@ -0,0 +1,9 @@ +--- +- name: Enable yum repos. + lineinfile: + dest: "/etc/yum.repos.d/{{ item }}.repo" + line: "enabled=1" + regexp: "enabled=0" + backrefs: yes + state: present + with_items: enable_yum_repos diff --git a/roles/downstream-setup/tasks/main.yml b/roles/downstream-setup/tasks/main.yml index 95b278b..4ad9caa 100644 --- a/roles/downstream-setup/tasks/main.yml +++ b/roles/downstream-setup/tasks/main.yml @@ -16,3 +16,21 @@ when: remove_yum_repos|length > 0 tags: - delete-yum-repos + +- include: disable_yum_repos.yml + when: disable_yum_repos|length > 0 and + not cleanup + tags: + - disable-yum-repos + +- name: Set enable_yum_repos on cleanup + set_fact: + enable_yum_repos: "{{ disable_yum_repos }}" + when: disable_yum_repos|length > 0 and + cleanup and + enable_yum_repos|length == 0 + +- include: enable_yum_repos.yml + when: enable_yum_repos|length > 0 + tags: + - enable-yum-repos -- 2.39.5