Skip to content

Commit

Permalink
Setup openshift cluster in Zuul CI
Browse files Browse the repository at this point in the history
  • Loading branch information
rpitonak committed Sep 5, 2019
1 parent 2f1ac05 commit a3f5336
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 2 deletions.
34 changes: 32 additions & 2 deletions .zuul.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,37 @@
name: packit-service/packit-service
check:
jobs:
- noop
- packit-service-pre-commit
- packit-service-tests
gate:
jobs:
- noop
- packit-service-pre-commit
- packit-service-tests

- job:
name: packit-service-pre-commit
parent: base
description: Check precommit
run: files/zuul-pre-commit.yaml
extra-vars:
ansible_python_interpreter: /usr/bin/python3
nodeset:
nodes:
- name: test-node
label: cloud-fedora-30

- job:
name: packit-service-tests
parent: base
description: Run tests of packit via rpms
pre-run:
- files/install-openshift.yaml
- files/deploy-service.yaml
run: files/zuul-tests.yaml
extra-vars:
with_testing: true
ansible_python_interpreter: /usr/bin/python3
nodeset:
nodes:
- name: test-node
label: cloud-fedora-30
60 changes: 60 additions & 0 deletions files/deploy-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
- name: Deploy packit-service into OpenShift with staging secrets
hosts: localhost
tasks:
- name: Download the deployment
git:
repo: 'https://github.com/packit-service/deployment.git'
dest: /tmp/deployment
clone: yes
- name: Install packages for deployment
dnf:
name:
- ansible-2.7.10-1.fc30 # because of packit-service deployment
- python3-openshift
- make

- name: get token
command: echo asdasdasdasd
register: kubeconfig_token

- name: Create dev.yml template
copy:
content: |
# Openshift project/namespace name
project: myproject
# Openshift cluster url (example: https://192.168.42.66:8443)
host: https://127.0.0.1:443
# oc login <the above host value>, oc whoami -t
# OR via Openshift web GUI: click on your login in top right corner, 'Copy Login Command', take the part after --token=
api_key: {{ kubeconfig_token }}
# To work-around 'SSL: CERTIFICATE_VERIFY_FAILED'
verify_ssl: no
# don't deploy fedmsg dc; good for local testing
without_fedmsg: false
# don't deploy redis-commander dc; good for staging deployment
without_redis_commander: false
# don't deploy flower dc; good for staging deployment
without_flower: false
# you can set the sandbox namespace name explicitly like this
sandbox_namespace: "packit-dev-sandbox"
dest: /tmp/deployment/vars/dev.yml.j2
- name: Create dev.yaml
template:
src: /tmp/deployment/vars/dev.yml.j2
dest: /tmp/deployment/vars/dev.yml

- name: Actually deploy
command: make deploy
environment:
DEPLOYMENT: dev
ANSIBLE_STDOUT_CALLBACK: debug
args:
chdir: /tmp/deployment/
58 changes: 58 additions & 0 deletions files/install-openshift.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
- name: Install dependencies for packit service.
hosts: all
tasks:
- name: Install basic utilities which should be in environment.
dnf:
name:
- git
- rpmdevtools
- docker
- podman
state: present
become: true
- name: Put SELinux in permissive mode, logging actions that would be blocked.
selinux:
policy: targeted
state: permissive
become: true
- name: Make sure docker is running
systemd:
name: docker
state: started
become: true
- name: Create docker deamon config
file:
path: /etc/docker/daemon.json
state: touch
become: true
- name: Add OpenShift insecure registry into docker deamon config
copy:
content: |
{"insecure-registries" : [ "172.30.0.0/16" ]}
dest: /etc/docker/daemon.json
become: true
- name: Restart docker because config has changed
systemd:
state: restarted
daemon_reload: yes
name: docker
become: true
- name: Install OpenShift server
dnf:
name:
- origin
state: present
become: true
- name: Start Openshift cluster
command: oc cluster up --base-dir=/tmp
environment:
PATH: "{{ ansible_env.PATH }}:/usr/local/bin"
DOCKER_CONFIG: "/etc/docker/daemon.json"
become: true

- name: Create sandbox project
command: oc new-project packit-dev-sandbox
environment:
PATH: "{{ ansible_env.PATH }}:/usr/local/bin"
become: true
Empty file added files/install-rpm-packages.yaml
Empty file.
3 changes: 3 additions & 0 deletions files/tasks/packit-service-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: "Build packit-service image from current src dir"
command: make build
14 changes: 14 additions & 0 deletions files/tasks/zuul-project-setup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- set_fact:
project_dir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
when: zuul is defined
- name: stat {{ project_dir }}
stat:
path: '{{ project_dir }}'
tags:
- no-cache
register: src_path
- name: Let's make sure {{ project_dir }} is present
assert:
that:
- 'src_path.stat.isdir'
11 changes: 11 additions & 0 deletions files/zuul-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- name: This is a recipe for how to run packit tests
hosts: all
tasks:
- include_tasks: tasks/zuul-project-setup.yaml
- include_tasks: tasks/packit-service-image.yaml
- import_playbook: deploy-service.yaml
- name: Run tests
command: make check_in_container
args:
chdir: '{{ project_dir }}'

0 comments on commit a3f5336

Please sign in to comment.