]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
downstream-setup: add tasks to disable and enable yum repos. 52/head
authorAndrew Schoen <aschoen@redhat.com>
Fri, 19 Jun 2015 15:49:39 +0000 (10:49 -0500)
committerAndrew Schoen <aschoen@redhat.com>
Fri, 19 Jun 2015 16:34:55 +0000 (11:34 -0500)
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 <aschoen@redhat.com>
roles/downstream-setup/defaults/main.yml
roles/downstream-setup/tasks/disable_yum_repos.yml [new file with mode: 0644]
roles/downstream-setup/tasks/enable_yum_repos.yml [new file with mode: 0644]
roles/downstream-setup/tasks/main.yml

index 3c5390b8e56299e75dd95480b8cc6398ca644361..617a1f280d0afbbcc4a2ecd7ce0839be6fcc4881 100644 (file)
@@ -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 (file)
index 0000000..022eea1
--- /dev/null
@@ -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 (file)
index 0000000..1920e9c
--- /dev/null
@@ -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
index 95b278bab9538e6280233d232c6f9ecd6e044151..4ad9caa44f43ad28dc197897d21ea4e073bee02d 100644 (file)
   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