]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
Adds a new role and playbook for package management
authorAndrew Schoen <aschoen@redhat.com>
Thu, 3 Dec 2015 20:20:18 +0000 (14:20 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Thu, 3 Dec 2015 20:20:18 +0000 (14:20 -0600)
Signed-off-by: Andrew Schoen <aschoen@redhat.com>
packages.yml [new file with mode: 0644]
roles/packages/defaults/main.yml [new file with mode: 0644]
roles/packages/tasks/cleanup.yml [new file with mode: 0644]
roles/packages/tasks/main.yml [new file with mode: 0644]
roles/packages/tasks/packages.yml [new file with mode: 0644]
roles/packages/tasks/setup.yml [new file with mode: 0644]

diff --git a/packages.yml b/packages.yml
new file mode 100644 (file)
index 0000000..d19956e
--- /dev/null
@@ -0,0 +1,4 @@
+---
+- hosts: all
+  roles:
+    - packages 
diff --git a/roles/packages/defaults/main.yml b/roles/packages/defaults/main.yml
new file mode 100644 (file)
index 0000000..0d928a4
--- /dev/null
@@ -0,0 +1,8 @@
+---
+# When cleanup is true the tasks being used might
+# perform cleanup steps if applicable.
+cleanup: false
+
+apt_packages: []
+
+yum_packages: []
diff --git a/roles/packages/tasks/cleanup.yml b/roles/packages/tasks/cleanup.yml
new file mode 100644 (file)
index 0000000..3a42ef6
--- /dev/null
@@ -0,0 +1,6 @@
+---
+- debug: msg="Performing cleanup related tasks..."
+
+- include: packages.yml
+  vars:
+    state: "absent"
diff --git a/roles/packages/tasks/main.yml b/roles/packages/tasks/main.yml
new file mode 100644 (file)
index 0000000..eab8c93
--- /dev/null
@@ -0,0 +1,14 @@
+---
+# These are tasks which perform actions corresponding to the names of
+# the variables they use.  For example, `disable_yum_repos` would actually
+# disable all repos defined in that list.
+- include: setup.yml
+  when: not cleanup
+
+# These are tasks which reverse the actions corresponding to the names of
+# the variables they use. For example, `disable_yum_repos` would actually
+# enable all repos defined in that list. The primary use for this is through
+# teuthology, so that you can tell a teuthology run to disable a set of repos
+# for the test run but then re-enable them during the teuthology cleanup process.
+- include: cleanup.yml
+  when: cleanup
diff --git a/roles/packages/tasks/packages.yml b/roles/packages/tasks/packages.yml
new file mode 100644 (file)
index 0000000..718c840
--- /dev/null
@@ -0,0 +1,17 @@
+---
+- name: Install or remove apt packages
+  apt:
+    update_cache: true
+    name: "{{ item }}"
+    state: "{{ state }}"
+  with_items: apt_packages
+  when: apt_packages|length > 0 and
+        ansible_pkg_mgr == "apt"
+
+- name: Install or remove yum packages
+  yum:
+    name: "{{ item }}"
+    state: "{{ state }}"
+  with_items: yum_packages
+  when: yum_packages|length > 0 and
+        ansible_pkg_mgr == "yum"
diff --git a/roles/packages/tasks/setup.yml b/roles/packages/tasks/setup.yml
new file mode 100644 (file)
index 0000000..7273472
--- /dev/null
@@ -0,0 +1,4 @@
+---
+- include: packages.yml
+  vars:
+    state: "present"