]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
Add zypper support for teuthology role 418/head
authorKyr Shatskyy <kyrylo.shatskyy@gmail.com>
Wed, 3 Oct 2018 14:29:36 +0000 (16:29 +0200)
committerKyr Shatskyy <kyrylo.shatskyy@gmail.com>
Wed, 3 Oct 2018 14:29:36 +0000 (16:29 +0200)
Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@suse.com>
roles/teuthology/tasks/main.yml
roles/teuthology/tasks/setup_log_access.yml
roles/teuthology/tasks/setup_users.yml
roles/teuthology/tasks/zypper_systems.yml [new file with mode: 0644]
roles/teuthology/templates/teuthology-worker.init [new file with mode: 0644]
roles/teuthology/templates/teuthology.yaml
roles/teuthology/vars/apt_systems.yml
roles/teuthology/vars/zypper_systems.yml [new file with mode: 0644]

index 23c9ccd0370104fb2d00aa665b7766c216dc3762..d5cdb28ae13164cfd92d7b7f7f5168c9036b66a2 100644 (file)
@@ -1,4 +1,7 @@
 ---
+- import_tasks: zypper_systems.yml
+  when: ansible_pkg_mgr == "zypper"
+
 - import_tasks: apt_systems.yml
   when: ansible_pkg_mgr == "apt"
 
   tags:
     - config
 
+- name: Ship /etc/init.d/teuthology-worker
+  template:
+    src: teuthology-worker.init
+    dest: /etc/init.d/teuthology-worker
+    mode: 0755
+  tags:
+    - config
+
 - name: Ship teuthology user's crontab update script
   template:
     src: update-crontab.sh
index c04abe9dd3d0a15402266c888066fdc1540d7f64..95db9d6e925ea077a58e7afdbe7bbe183d5956aa 100644 (file)
@@ -7,12 +7,12 @@
 - name: Ship nginx config
   template:
     src: nginx.conf
-    dest: /etc/nginx/sites-available/test_logs
+    dest: "{{ nginx_available }}/test_logs.conf"
 
 - name: Enable nginx config
   file:
-    src: /etc/nginx/sites-available/test_logs
-    dest: /etc/nginx/sites-enabled/test_logs
+    src: "{{ nginx_available }}/test_logs.conf"
+    dest: "{{ nginx_enabled }}/test_logs.conf"
     state: link
 
 # Ignore errors in case service doesn't exist
index f16426248510e0040ffbe1205c10179b684a0344..e0d3c51eba50ef12e9eb24411d003f145c5266c6 100644 (file)
@@ -1,4 +1,12 @@
 ---
+- name: Create group
+  group:
+    name: "{{ item }}"
+    state: present
+  with_items: "{{ teuthology_users }}"
+  tags:
+    - user
+
 - name: Create users
   user:
     name: "{{ item }}"
diff --git a/roles/teuthology/tasks/zypper_systems.yml b/roles/teuthology/tasks/zypper_systems.yml
new file mode 100644 (file)
index 0000000..b71cccf
--- /dev/null
@@ -0,0 +1,14 @@
+---
+- name: Include package type specific vars.
+  include_vars: "zypper_systems.yml"
+  tags:
+    - always
+
+- name: Install packages via zypper
+  zypper:
+    name: "{{ item }}"
+    state: latest
+    update_cache: yes
+  with_items: "{{ teuthology_extra_packages }}"
+  tags:
+    - packages
diff --git a/roles/teuthology/templates/teuthology-worker.init b/roles/teuthology/templates/teuthology-worker.init
new file mode 100644 (file)
index 0000000..590b461
--- /dev/null
@@ -0,0 +1,166 @@
+#!/bin/bash
+#
+# Copyright (c) 2015 Red Hat, Inc.
+#
+# Author: Loic Dachary <loic@dachary.org>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+### BEGIN INIT INFO
+# Provides:        teuthology
+# Required-Start:  $network $remote_fs $syslog beanstalkd nginx
+# Required-Stop:   $network $remote_fs $syslog
+# Default-Start:   2 3 4 5
+# Default-Stop:
+# Short-Description: Start teuthology
+### END INIT INFO
+
+export NWORKERS=20
+
+[ -f /etc/default/teuthology ] && source /etc/default/teuthology
+
+user=${TEUTHOLOGY_USERNAME:-teuthworker}
+export HOME=/home/$user
+export WORKER_HOME=$HOME/src/teuthology_master
+#/usr/share/nginx/html
+export WORKER_ARCH=$HOME/archive
+
+[ -d $WORKER_ARCH ] || sudo -u $user mkdir -p $WORKER_ARCH
+
+function worker_pidfile() {
+    echo /var/run/teuthology-worker.$1.pid
+}
+function worker_logfile() {
+    echo /var/log/teuthology.${1}.log
+}
+
+function stop_worker() {
+    wnum=$1
+    wpidfile=$(worker_pidfile $wnum)
+    if [[ -f $wpidfile ]] ; then
+        wpid=$(cat $wpidfile)
+        echo Killing worker $wnum with pid=$wpid...
+        pkill -P $wpid
+        pkill $wpid
+        rm -f $wpidfile
+    fi
+}
+
+function stop_workers() {
+    for i in $(seq 1 $NWORKERS) ; do
+        stop_worker $i
+    done
+}
+
+function start_worker() {
+    local wlogfile=$1
+    local wpidfile=$2
+    local worklogs=/tmp/$user-logs
+    mkdir -p $worklogs && chown $user: $worklogs
+    su - -c "
+cd /home/$user
+source openrc.sh
+cd $WORKER_HOME
+export LC_ALL=C
+virtualenv/bin/teuthology-worker --tube openstack -l $worklogs --archive-dir $WORKER_ARCH
+" $user > $wlogfile 2>&1 & {
+        echo $! > $wpidfile
+        echo "Started worker with pid=$! see log $wlogfile"
+    }
+}
+
+function rkill() {
+    local pid=$1
+    for i in $(pgrep -P $pid) ; do
+        rkill $i
+    done
+    echo Killing process $pid
+    kill -9 $pid
+}
+
+function stop_process() {
+    local pidfile=$1
+    [[ -f $pidfile ]] && {
+        local pid=$(cat $pidfile)
+        rkill $pid
+        ps --no-headers $pid 2>&1 > /dev/null || rm $pidfile
+    }
+}
+
+function start_workers() {
+    for i in $(seq 1 $NWORKERS) ; do
+        local wpidfile=$(worker_pidfile $i)
+        local wlogfile=$(worker_logfile $i)
+        [[ -f $wpidfile ]] && {
+            local wpid=$(cat $wpidfile)
+            ps --no-headers -p $wpid 2>&1 > /dev/null && {
+                echo Worker $i is already running with process $wpid
+                continue
+            }
+        }
+        start_worker $wlogfile $wpidfile
+    done
+}
+echo $1
+case $1 in
+        start-workers)
+            start_workers
+            ;;
+        list-workers)
+            for i in $(ls /var/run | grep teuthology-worker | sort) ; do
+                WPID=$(cat /var/run/$i)
+                WORKER=${i##teuthology-worker.}
+                WORKER=${WORKER%%.pid}
+                STATUS=$(ps --no-headers -p $WPID 2>&1 > /dev/null && echo running || echo dead)
+                echo $WORKER PID:$WPID STATUS:$STATUS
+            done
+            ;;
+        stop-workers)
+            echo Stopping workers
+            stop_workers
+            ;;
+        stop-worker)
+            stop_worker $2
+            ;;
+        restart-workers)
+            $0 stop-workers
+            $1 start-workers
+            ;;
+        start)
+                (
+                   cd /home/$user
+                   source openrc.sh
+                   cd teuthology
+                   . virtualenv/bin/activate
+                   teuthology-lock --list-targets --owner scheduled_$user@teuthology > /tmp/t
+                   if test -s /tmp/t && ! grep -qq 'targets: {}' /tmp/t ; then
+                      teuthology-lock --unlock -t /tmp/t --owner scheduled_$user@teuthology
+                  fi
+                   start_workers
+                )
+                ;;
+        stop)
+                $0 stop-workers
+               ;;
+        restart)
+                $0 stop
+                $0 start
+                ;;
+        *)
+esac
index ee12f4c0ec95c5973680604ed740680356a71641..0c54010f82bd17575f4773bd0e041e7ec32abacb 100644 (file)
@@ -4,7 +4,7 @@ results_server: {{ paddles_address }}
 results_ui_server: {{ pulpito_address }}
 results_email: {{ teuthology_results_email|default('null') }}
 results_sending_email: {{ teuthology_results_sending_email|default('null') }}
-lab_domain: {{ lab_domain }}
+lab_domain: {{ lab_domain|default('teuthology') }}
 default_machine_type: {{ teuthology_default_machine_type|default('null') }}
 max_job_time: {{ teuthology_max_job_time|default(129600) }}
 {{ teuthology_yaml_extra }}
index 878bef1324215e83dfd0845985fe7c90e06b5268..e8c03cf4232911bf0b77903c122b33483705cd2a 100644 (file)
@@ -20,3 +20,5 @@ teuthology_extra_packages:
   - nginx
 
 apache_service: apache2
+nginx_available: "/etc/nginx/sites-available"
+nginx_enabled: "/etc/nginx/sites-enabled"
diff --git a/roles/teuthology/vars/zypper_systems.yml b/roles/teuthology/vars/zypper_systems.yml
new file mode 100644 (file)
index 0000000..280a260
--- /dev/null
@@ -0,0 +1,22 @@
+---
+teuthology_extra_packages:
+  - beanstalkd
+  - git
+  - gcc
+  - libev-devel
+  - libffi48-devel
+  - libmysqlclient-devel
+  - libopenssl-devel
+  - libvirt-devel
+  - libvirt-python
+  - libyaml-devel
+  - lsb-release
+  - nginx
+  - python-devel
+  - python-pip
+  - python-virtualenv
+  - qemu-tools
+
+#apache_service: apache2
+nginx_available: "/etc/nginx"
+nginx_enabled: "/etc/nginx/vhosts.d"