Skip to content

Commit

Permalink
Merge pull request #356 from ecordell/ansible
Browse files Browse the repository at this point in the history
Ansible playbook
  • Loading branch information
ecordell authored May 29, 2018
2 parents 7f2f14b + b33ae2e commit 28acc48
Show file tree
Hide file tree
Showing 22 changed files with 199 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "deploy/aos-olm/openshift-ansible"]
path = deploy/aos-olm/openshift-ansible
url = https://github.com/openshift/openshift-ansible
12 changes: 12 additions & 0 deletions Dockerfile.rhel7
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM registry.centos.org/centos/centos:7

RUN yum update -y
RUN yum install -y golang make

ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH

WORKDIR /go/src/github.com/operator-framework/operator-lifecycle-manager
COPY . .

RUN make build
11 changes: 11 additions & 0 deletions Documentation/install/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ kubectl create namespace tectonic-system
kubectl apply -f deploy/tectonic-alm-operator/manifests/0.4.0
```

## Install with Ansible for openshift

OLM should be installed via [openshift-ansible](https://github.com/openshift/openshift-ansible). The playbook in this
repo is periodically synced with openshift-ansible and should only be used for testing releases.

The playbook assumes that the hosts file has the same format as [openshift-ansible](https://github.com/openshift/openshift-ansible)

```sh
ansible-playbook -i path/to/hosts deploy/aos-olm/playbook/config.yaml
```

## Run locally with minikube

This command starts minikube, builds the OLM containers locally with the minikube-provided docker, and uses the local configuration in [local-values.yaml](local-values.yaml) to build localized deployment resources for OLM.
Expand Down
28 changes: 25 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,35 @@ $(counterfeiter):
generate-mock-client: $(counterfeiter)
go generate ./$(PKG_DIR)/...

make gen-all: gen-ci codegen generate-mock-client
gen-all: gen-ci codegen generate-mock-client

# make ver=0.3.0 tectonic-release
tectonic-release:
./scripts/package-release.sh $(ver) deploy/tectonic-alm-operator/manifests/$(ver) deploy/tectonic-alm-operator/values.yaml

# make ver=0.3.0 release
release:
# make ver=0.3.0 upstream-release
upstream-release:
./scripts/package-release.sh $(ver) deploy/upstream/manifests/$(ver) deploy/upstream/values.yaml


YQ := $(GOPATH)/bin/yq
$(YQ):
go get -u github.com/mikefarah/yq

# make ver=0.3.0 ansible-release
ansible-release: $(YQ)
# ansible release uses openshift-ansible submodule
git submodule init
git submodule update
# copy base role to versioned release
mkdir -p deploy/aos-olm/$(ver)
cp -R deploy/role/. deploy/aos-olm/$(ver)/
# copy manifest files into release
./scripts/package-release.sh $(ver) deploy/aos-olm/$(ver)/files deploy/aos-olm/values.yaml
# generate install/remove tasks based on manifest files
./scripts/k8s_yaml_to_ansible_install.sh deploy/aos-olm/$(ver)/files deploy/aos-olm/$(ver)/tasks/install.yaml
./scripts/k8s_yaml_to_ansible_remove.sh deploy/aos-olm/$(ver)/files deploy/aos-olm/$(ver)/tasks/remove_components.yaml
# link newest release into playbook
ln -sfF ../../../../deploy/aos-olm/$(ver) deploy/aos-olm/playbook/private/roles/olm

release: tectonic-release upstream-release ansible-release
1 change: 1 addition & 0 deletions deploy/aos-olm/openshift-ansible
Submodule openshift-ansible added at ed37b6
4 changes: 4 additions & 0 deletions deploy/aos-olm/playbook/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- import_playbook: private/config.yaml
vars:
operator_lifecycle_manager_install: true
6 changes: 6 additions & 0 deletions deploy/aos-olm/playbook/private/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Operator Lifecycle Manager
hosts: masters[0]
tasks:
- import_role:
name: olm
1 change: 1 addition & 0 deletions deploy/aos-olm/playbook/private/roles/lib_openshift
1 change: 1 addition & 0 deletions deploy/aos-olm/playbook/private/roles/lib_utils
1 change: 1 addition & 0 deletions deploy/aos-olm/playbook/private/roles/olm
22 changes: 22 additions & 0 deletions deploy/aos-olm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
rbacApiVersion: rbac.authorization.k8s.io
namespace: operator-lifecycle-manager
catalog_namespace: operator-lifecycle-manager
alm:
replicaCount: 1
image:
ref: quay.io/coreos/olm@sha256:351f0c4973a88a4ea606721555829776429b0ecb53d5a2bfee6bce459d109e5b
pullPolicy: IfNotPresent
service:
internalPort: 8080

catalog:
replicaCount: 1
image:
ref: quay.io/coreos/catalog@sha256:54571e25474a9a063a144922e7321203e5aa5e63d03f748682d559341359a916
pullPolicy: IfNotPresent
service:
internalPort: 8080

catalog_sources:
- tectonic-ocs
- upstream-components
4 changes: 0 additions & 4 deletions deploy/namespace.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions deploy/role/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
operator_lifecycle_manager_remove: false
operator_lifecycle_manager_install: true
Empty file added deploy/role/files/.gitkeep
Empty file.
16 changes: 16 additions & 0 deletions deploy/role/meta/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
galaxy_info:
author: Evan Cordell
description: Operator Lifecycle Manager
company: Red Hat, Inc.
license: Apache License, Version 2.0
min_ansible_version: 2.1
platforms:
- name: EL
versions:
- 7
categories:
- cloud
dependencies:
- role: lib_utils
- role: lib_openshift
19 changes: 19 additions & 0 deletions deploy/role/tasks/install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---

- name: create operator-lifecycle-manager project
oc_project:
name: operator-lifecycle-manager
state: present
node_selector:
- ""

- name: Make temp directory for manifests
command: mktemp -d /tmp/olm-ansible-XXXXXX
register: mktemp
changed_when: False

- name: Copy manifests to temp directory
copy:
src: "{{ item }}"
dest: "{{ mktemp.stdout }}"
with_fileglob: files/*.yaml
8 changes: 8 additions & 0 deletions deploy/role/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# do any asserts here

- include_tasks: install.yaml
when: operator_lifecycle_manager_install | bool

- include_tasks: remove.yaml
when: operator_lifecycle_manager_remove | bool
8 changes: 8 additions & 0 deletions deploy/role/tasks/remove.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---

- import_tasks: remove_components.yaml

- name: remove openshift-ansible-service-broker project
oc_project:
name: openshift-ansible-service-broker
state: absent
1 change: 1 addition & 0 deletions deploy/role/tasks/remove_components.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
29 changes: 29 additions & 0 deletions scripts/k8s_yaml_to_ansible_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

# requires yq to be installed https://github.com/mikefarah/yq

if [[ ${#@} < 2 ]]; then
echo "Usage: $0 manifests outfile"
echo "* manifests: directory of k8s manifests"
echo "* outfile: the ansible file to append"
exit 1
fi

manifests=$1
outfile=$2

for filename in $manifests/*.yaml; do
kind=$(yq r "$filename" kind)
name=$(yq r "$filename" metadata.name)
cat <<EOF >> $outfile
- name: Apply $name $kind manifest
oc_obj:
state: present
kind: $kind
name: $name
namespace: operator-lifecycle-manager
files:
- "{{ mktemp.stdout }}/$(basename $filename)"
EOF
done
27 changes: 27 additions & 0 deletions scripts/k8s_yaml_to_ansible_remove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

# requires yq to be installed https://github.com/mikefarah/yq

if [[ ${#@} < 2 ]]; then
echo "Usage: $0 manifests outfile"
echo "* manifests: directory of k8s manifests"
echo "* outfile: the ansible file to append"
exit 1
fi

manifests=$1
outfile=$2

for filename in $manifests/*.yaml; do
kind=$(yq r "$filename" kind)
name=$(yq r "$filename" metadata.name)
cat <<EOF >> $outfile
- name: Remove $name $kind manifest
oc_obj:
state: absent
kind: $kind
name: $name
namespace: operator-lifecycle-manager
EOF
done
2 changes: 1 addition & 1 deletion scripts/package-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# requires helm to be installed

if [[ ${#@} < 3 ]]; then
echo "Usage: $0 version alm-sha catalog-sha"
echo "Usage: $0 semver chart values"
echo "* semver: semver-formatted version for this package"
echo "* chart: the directory to output the chart"
echo "* values: the values file"
Expand Down

0 comments on commit 28acc48

Please sign in to comment.