Browse Source

add standard battery of tests

Student User 2 months ago
parent
commit
1aeee65d5f
5 changed files with 61 additions and 0 deletions
  1. 7 0
      tests/deploy-apache.yml
  2. 5 0
      tests/do-nothing.yml
  3. 1 0
      tests/inventory
  4. 42 0
      tests/rollback.yml
  5. 6 0
      tests/vars.yml

+ 7 - 0
tests/deploy-apache.yml

@@ -0,0 +1,7 @@
+---
+- hosts: all
+  vars_files:
+    - vars.yml
+  roles:
+    - myroles.deploystuff
+...

+ 5 - 0
tests/do-nothing.yml

@@ -0,0 +1,5 @@
+---
+- hosts: all
+  roles:
+    - myroles.deploystuff
+...

+ 1 - 0
tests/inventory

@@ -0,0 +1 @@
+servera.lab.example.com ansible_user=devops

+ 42 - 0
tests/rollback.yml

@@ -0,0 +1,42 @@
+---
+- hosts: all
+  become: yes
+  vars_files:
+    - vars.yml
+  tasks:
+    - name: ensure the service is stopped
+      service:
+        name: "{{ service }}"
+        state: stopped
+        enabled: no
+      when: service != None
+      ignore_errors: true
+
+    - name: ensure the firewall ports are closed
+      firewalld:
+        service: "{{ fwsvc }}"
+        state: disabled
+        immediate: true
+        permanent: true
+      when: fwsvc != None
+      ignore_errors: true
+
+    - name: remove the packages
+      yum:
+        name: "{{ packages }}"
+        state: absent
+
+    - name: remove any published templates
+      file:
+        path: "{{ item.dest }}"
+        state: absent
+      loop: "{{ configs }}"
+      when: configs is defined
+
+    - name: remove any static files
+      file:
+        path: "{{ item.dest }}"
+        state: absent
+      loop: "{{ staticfiles }}"
+      when: staticfiles is defined
+...

+ 6 - 0
tests/vars.yml

@@ -0,0 +1,6 @@
+packages:
+  - httpd
+test_programs:
+  - apachectl configtest
+service: httpd
+fwsvc: http