summaryrefslogtreecommitdiffstats
path: root/controller/ansible
diff options
context:
space:
mode:
authorPavel Raiskup <praiskup@redhat.com>2014-10-22 08:54:05 +0200
committerPavel Raiskup <praiskup@redhat.com>2014-10-22 08:54:05 +0200
commit2422a081a5be0d5ac5afb122361bc283da67341f (patch)
treecb255582060af6547dd9318c56ba0e8c761846a1 /controller/ansible
parent922089746e1029de9be986672fcdeb6bc82e18d7 (diff)
downloadpostgresql-setup-tests-2422a081a5be0d5ac5afb122361bc283da67341f.tar.gz
postgresql-setup-tests-2422a081a5be0d5ac5afb122361bc283da67341f.tar.xz
postgresql-setup-tests-2422a081a5be0d5ac5afb122361bc283da67341f.zip
big reorg: prepare for generalization
Try to split into three separate components -> controller, tester, and 'tasks' (postgresql-tasks in our case). The controller component is the main part which is able to run the task remotely. Tester is more-like library for 'tasks' component (should be reusable on the raw git level). * controller: Almost separated component. * postgresql-tasks: Likewise. * tester: Likewise.
Diffstat (limited to 'controller/ansible')
-rw-r--r--controller/ansible/dummy-wrapper.yml7
-rw-r--r--controller/ansible/fedora.yml64
-rw-r--r--controller/ansible/include/additional-packages.yml6
-rw-r--r--controller/ansible/include/beakerlib.yml1
-rw-r--r--controller/ansible/include/download-results.yml5
-rw-r--r--controller/ansible/include/prepare-testenv.yml3
-rwxr-xr-xcontroller/ansible/run_include19
7 files changed, 105 insertions, 0 deletions
diff --git a/controller/ansible/dummy-wrapper.yml b/controller/ansible/dummy-wrapper.yml
new file mode 100644
index 0000000..524b0ea
--- /dev/null
+++ b/controller/ansible/dummy-wrapper.yml
@@ -0,0 +1,7 @@
+- name: "dummy-wrapper"
+ hosts: "{{ target }}"
+ remote_user: root
+ gather_facts: False
+
+ tasks:
+ - include: "{{ include_file }}"
diff --git a/controller/ansible/fedora.yml b/controller/ansible/fedora.yml
new file mode 100644
index 0000000..cc64eac
--- /dev/null
+++ b/controller/ansible/fedora.yml
@@ -0,0 +1,64 @@
+- name: self-standing testsuite
+ remote_user: root
+ gather_facts: False
+ hosts: localhost
+ vars_files:
+ - "{{ opt_credsfile }}"
+
+ tasks:
+ - name: generate builder name
+ local_action: shell echo `dd if=/dev/urandom bs=1k count=10 | md5sum ; echo DBTESTS`
+ register: vm_name
+
+ - debug: msg="osusername={{ os_username }}"
+
+ - name: spin it up
+ local_action: nova_compute auth_url={{os_auth_url}}
+ flavor_id={{os_flavor_id}} image_id="{{ os_image_id }}" key_name={{ os_keypair }}
+ login_password={{os_nova_password}} login_tenant_name="{{os_tenant_name}}"
+ login_username={{os_username}} security_groups={{os_security_group}}
+ wait=yes name="{{vm_name.stdout}}" wait_for=600
+ register: nova
+
+ - debug: msg="{{ nova.info.addresses }}"
+
+ # This is ugly as hell... Hopefully nothing will be changing.
+ - local_action: command echo "{{ nova.info.addresses[os_network_dev][1].addr }}"
+ register: machine_ip
+
+ - debug: msg="{{ machine_ip.stdout }}"
+
+ - name: wait for the host to be hot
+ local_action: wait_for host={{ machine_ip.stdout }} port=22 delay=5 timeout=600
+
+ - local_action: shell ../ansible_helpers/wait-for-ssh "root@{{ machine_ip.stdout }}"
+
+ - name: add it to the special group
+ local_action: add_host hostname={{ machine_ip.stdout }}
+ groupname=temp_group
+
+- hosts: temp_group
+ user: root
+ gather_facts: False
+ tasks:
+ - copy: src={{ opt_workdir }}/{{ opt_testsuite_name }}.tar.gz
+ dest=/root/{{ opt_testsuite_name }}.tar.gz
+
+ - include: include/beakerlib.yml
+
+ - include: include/prepare-testenv.yml
+
+ - include: include/additional-packages.yml
+ when: dtf_rpm_files_list is defined
+
+ - shell: cd /root && tar -xf {{ opt_testsuite_name }}.tar.gz
+
+ - shell: cd /root/{{ opt_testsuite_name }}&& ./run &>/var/tmp/dtf-run.overview
+ register: test_result
+ ignore_errors: yes
+
+ - include: include/download-results.yml
+
+ - name: stop the vm
+ shell: echo "not implemented yet"
+ when: test_result.rc == 0
diff --git a/controller/ansible/include/additional-packages.yml b/controller/ansible/include/additional-packages.yml
new file mode 100644
index 0000000..f821255
--- /dev/null
+++ b/controller/ansible/include/additional-packages.yml
@@ -0,0 +1,6 @@
+- local_action: shell cat "{{ dtf_rpm_files_list }}" | xargs -n 100
+ register: additional_packages
+
+- debug: msg="{{ additional_packages.stdout }}"
+
+- shell: yum install -y {{ additional_packages.stdout }}
diff --git a/controller/ansible/include/beakerlib.yml b/controller/ansible/include/beakerlib.yml
new file mode 100644
index 0000000..0461f25
--- /dev/null
+++ b/controller/ansible/include/beakerlib.yml
@@ -0,0 +1 @@
+- yum: conf_file=https://beaker-project.org/yum/beaker-server-Fedora.repo state=present name=beakerlib
diff --git a/controller/ansible/include/download-results.yml b/controller/ansible/include/download-results.yml
new file mode 100644
index 0000000..4404e08
--- /dev/null
+++ b/controller/ansible/include/download-results.yml
@@ -0,0 +1,5 @@
+- shell: cp -f /var/tmp/dtf-run.overview /var/tmp/dtf/
+
+- shell: cd /var/tmp ; tar -czf dtf.tar.gz dtf
+
+- fetch: src=/var/tmp/dtf.tar.gz dest="{{ opt_workdir }}/" flat=yes
diff --git a/controller/ansible/include/prepare-testenv.yml b/controller/ansible/include/prepare-testenv.yml
new file mode 100644
index 0000000..a63e51a
--- /dev/null
+++ b/controller/ansible/include/prepare-testenv.yml
@@ -0,0 +1,3 @@
+- yum: state=present name=postgresql-server
+
+- yum: state=present name=postgresql-upgrade
diff --git a/controller/ansible/run_include b/controller/ansible/run_include
new file mode 100755
index 0000000..4e84c7d
--- /dev/null
+++ b/controller/ansible/run_include
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+export ANSIBLE_HOST_KEY_CHECKING=False
+
+workdir="$(dirname "${BASH_SOURCE[0]}")"
+workdir=$(readlink -f "$workdir")
+
+export playbook=$(readlink -f "$1")
+
+( set -x
+ cd "$workdir"
+
+ ansible-playbook -i "$workdir/../config/hosts" \
+ --extra-vars "include_file=$playbook" \
+ --extra-vars "script_name=dummy" \
+ --extra-vars "opt_workdir=/tmp/dtf-$(date +%H%M%S%N)" \
+ --extra-vars "target=host" \
+ "dummy-wrapper.yml"
+)