info:
  summary: Kanku development jobs
  description: |+
               This KankuFile supports developers in 
               
               * developing kanku
               * testing kanku
               * setting up VMs for kanku in server/developer mode

               The following jobs are available:
                 * sm: create tested kanku vm in server mode
                 * dm: create tested kanku vm in developer mode
                 * tm: create kanku vm in testing mode and run resonable test suites
                 * cl: cleanup - remove domains like `kanku destroy` does 
                       (for usage in job_groups)

               You can start each job separatly with:

                 `kanku up -j <job_name>`

               Enjoy YLWK!

guest:
  url: https://[% ctx.ipaddress %]/kanku/#/job_history/1

domain_name: kanku-devel
default_job: tasks

jobs:
  tasks:
    -
      use_module: Kanku::Handler::SetJobContext
      options:
        login_user: root
        login_pass: kankudai
    -
      use_module: Kanku::Handler::OBSCheck
      options:
        project: devel:kanku:images
        package: openSUSE-Tumbleweed-JeOS:ext4
        repository: images_tumbleweed
    -
      use_module: Kanku::Handler::ImageDownload
    -
      use_module: Kanku::Handler::ResizeImage
      options:
        disk_size: 100G
    -
      use_module: Kanku::Handler::RemoveDomain
    -
      use_module: Kanku::Handler::CreateDomain
      options:
        memory: 6G
        vcpu: 2
        use_9p: 1
        pwrand:
          users:
            - root
            - kanku
    -
      use_module: Kanku::Handler::PrepareSSH
    -
      use_module: Kanku::Handler::ExecuteCommandViaSSH
      options:
        commands:
          - zypper -n ar https://download.opensuse.org/repositories/devel:/kanku:/perl/openSUSE_Tumbleweed/devel:kanku:perl.repo
          - zypper -n ar https://download.opensuse.org/repositories/devel:/kanku:/staging/openSUSE_Tumbleweed/devel:kanku:staging.repo
          - zypper --gpg-auto-import-keys ref -s
          # Only for development
          - zypper -n in make apache2 sqlite3
    # Install kanku server mode and run tests
    -
      use_module: Kanku::Handler::ExecuteCommandViaSSH
      options:
        commands:
          - rcnetwork restart
          - zypper -n in rabbitmq-server rabbitmq-server-plugins openvswitch openssh-clients
          - zypper -n in kanku-iptables kanku-web kanku-dispatcher kanku-triggerd kanku-scheduler kanku-config-example-jobs kanku-cli kanku-worker kanku-tests
          - kanku setup server --apache --ssl > /tmp/setup.log 2>&1 || { cat /tmp/setup.log; exit 1; }
          - systemctl enable --now kanku-iptables
          - systemctl enable --now kanku-web
          - systemctl enable --now kanku-dispatcher
          - systemctl enable --now kanku-triggerd
          - systemctl enable --now kanku-scheduler
          - virsh net-start kanku-ovs
          - kanku login -a http://localhost:5000/kanku -u admin -p opensuse -k None
          - rcapache2 restart
          - systemctl enable --now kanku-worker
          - |+
            cat <<EOF > /tmp/wait
            RUNNING=1

            while [ \$RUNNING -gt 0 ];do
              RUNNING=\$(kanku rhistory list --state running --state dispatching --ll FATAL --format json|json_xs -e 'print \$_->{total_entries};' -t none)
              sleep 1
            done
            SUCCEED=\$(kanku rhistory list --state succeed --ll FATAL --format json|json_xs -e 'print \$_->{total_entries};' -t none)
            [ \$SUCCEED -gt 0 ] && exit 0
            exit 1
            EOF
          - sh -x /tmp/wait > /tmp/wait.log 2>&1
          - prove -v /usr/share/kanku/t/*.ts

job_groups:
 all:
   - cl
   - sm
   - cl
