]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
downstream-setup: make yum_repos clean up after itself on teardown 48/head
authorAndrew Schoen <aschoen@redhat.com>
Mon, 15 Jun 2015 21:26:44 +0000 (16:26 -0500)
committerAndrew Schoen <aschoen@redhat.com>
Tue, 16 Jun 2015 15:17:38 +0000 (10:17 -0500)
This lets us pass a teardown==True var to downstream-setup with the
yum_repos var defined and it will instead remove the repos defined in
yum_repos instead of downloading them.

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
roles/downstream-setup/defaults/main.yml
roles/downstream-setup/tasks/main.yml

index 15c78c18aafd0d290980479d76a86af21c4efddb..15647c7618cc39802e0ed0b227bda9034e97c022 100644 (file)
@@ -1,4 +1,9 @@
 ---
+# When teardown is true the tasks being used might
+# perform teardown steps if applicable.
+teardown: false
+
+
 # yum_repos is a list of hashes that
 # define the url to download the yum repo
 # from and the name to save it as in etc/yum.repos.d
@@ -8,6 +13,8 @@
 #     - url: "http://path/to/epel.repo"
 #       name: "epel"
 #
+# When using the yum_repos var and if teardown is true it will
+# delete the repos instead of creating them.
 yum_repos: []
 
 # a list of repo names as strings to delete from /etc/yum.repos.d
index 2c53da92484051469fe76e4d9b0e5a7cd4ea2f5f..d194da903805c1a415cf14bb0418343121c0cd6f 100644 (file)
@@ -1,9 +1,17 @@
 ---
 - include: yum_repos.yml
-  when: yum_repos|length > 0
+  when: yum_repos|length > 0 and
+        not teardown
   tags:
     - yum-repos
 
+- name: Set remove_yum_repos on teardown
+  set_fact:
+    remove_yum_repos: "[{% for repo in yum_repos %}'{{ repo.name}}',{% endfor %}]"
+  when: yum_repos|length > 0 and
+        teardown and
+        remove_yum_repos|length == 0
+
 - include: remove_yum_repos.yml
   when: remove_yum_repos|length > 0
   tags: