Automate some build and release related activities

This commit is contained in:
Shane McDonald
2020-10-03 14:03:56 -04:00
parent 6f52a0121d
commit 48c8f07877
10 changed files with 92 additions and 51 deletions

View File

@@ -176,14 +176,13 @@ Then push the generated image to Docker Hub:
#### Build a new version of the `awx-operator.yaml` file
Update the awx-operator version in two places:
Update the awx-operator version:
1. `deploy/awx-operator.yaml`: in the `ansible` and `operator` container definitions in the `awx-operator` Deployment.
2. `build/chain-operator-files.yml`: the `operator_image` variable.
- `ansible/group_vars/all`
Once the versions are updated, run the playbook in the `build/` directory:
Once the version has been updated, run from the root of the repo:
ansible-playbook chain-operator-files.yml
ansible-playbook ansible/chain-operator-files.yml
After it is built, test it on a local cluster:

View File

@@ -0,0 +1,24 @@
---
# To run: `ansible-playbook chain-operator-files.yml`
- name: Chain operator files together for easy deployment.
hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Template CRD
template:
src: crd.yml.j2
dest: "{{ playbook_dir }}/../deploy/crds/awx_v1beta1_crd.yaml"
- name: Template awx-operator.yaml
copy:
content: |
# This file is generated by Ansible. Changes will be lost.
# Update templates under ansible/templates/
{{ lookup('template', 'role.yml.j2') }}
{{ lookup('template', 'role_binding.yml.j2') }}
{{ lookup('template', 'service_account.yml.j2') }}
{{ lookup('template', 'operator.yml.j2') }}
{{ lookup('template', 'crd.yml.j2') }}
dest: ../deploy/awx-operator.yaml

5
ansible/group_vars/all Normal file
View File

@@ -0,0 +1,5 @@
operator_image: ansible/awx-operator
operator_version: 0.5.0
pull_policy: Always
operator_file_path: "../deploy/awx-operator.yaml"
operator_template: "../deploy/operator.yaml"

View File

@@ -0,0 +1,55 @@
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: awxs.awx.ansible.com
spec:
group: awx.ansible.com
names:
kind: AWX
listKind: AWXList
plural: awxs
singular: awx
scope: Namespaced
subresources:
status: {}
version: v1beta1
versions:
- name: v1beta1
served: true
storage: true
validation:
openAPIV3Schema:
description: Schema validation for the AWX CRD
type: object
properties:
spec:
type: object
properties:
deployment_type:
type: string
pattern: "^(tower|awx)(-)?.*$"
external_database:
type: boolean
description: |
If true you must supply a secret containing the location and credentials for
connecting to the external database by a user who has permission to create
and apply a schema.
The secret should have the name: <custom resource name>-postgres-configuration and
should look like:
apiVersion: v1
kind: Secret
metadata:
name: <crname>-postgres-configuration
namespace: <target namespace>
stringData:
host: <external ip or url resolvable by the cluster>
port: <external port, this usually defaults to 5432>
database: <desired database name>
username: <username to connect as>
password: <password to connect with>
type: Opaque
required:
- deployment_type

View File

@@ -20,14 +20,14 @@ spec:
- /usr/local/bin/ao-logs
- /tmp/ansible-operator/runner
- stdout
image: "{{ operator_image }}"
image: "{{ operator_image }}:{{ operator_version }}"
imagePullPolicy: "{{ pull_policy|default('Always') }}"
volumeMounts:
- mountPath: /tmp/ansible-operator/runner
name: runner
readOnly: true
- name: operator
image: "{{ operator_image }}"
image: "{{ operator_image }}:{{ operator_version }}"
imagePullPolicy: "{{ pull_policy|default('Always') }}"
volumeMounts:
- mountPath: /tmp/ansible-operator/runner

View File

@@ -1,44 +0,0 @@
---
# To run: `ansible-playbook chain-operator-files.yml`
- name: Chain operator files together for easy deployment.
hosts: localhost
connection: local
gather_facts: false
vars:
operator_image: ansible/awx-operator:0.5.0
pull_policy: Always
operator_file_path: "../deploy/awx-operator.yaml"
operator_template: "../deploy/operator.yaml"
tasks:
- name: Clear out current contents of awx-operator.yml
copy:
dest: "{{ operator_file_path }}"
content: ''
force: true
- name: Concatenate operator files into awx-operator.yml
blockinfile:
path: "{{ operator_file_path }}"
block: "{{ item }}"
marker: ""
marker_begin: ""
marker_end: ""
insertafter: "EOF"
with_file:
- "../deploy/role.yaml"
- "../deploy/role_binding.yaml"
- "../deploy/service_account.yaml"
- "../deploy/operator.yaml"
- "../deploy/crds/awx_v1beta1_crd.yaml"
- name: Remove space at beginning of awx-operator.yml
shell: >
echo "$(tail -n +2 {{ operator_file_path }})" > {{ operator_file_path }}
changed_when: true
- name: Template the awx-operator.yaml file into awx-operator.yml
template:
src: "{{ operator_file_path }}"
dest: "{{ operator_file_path }}"

View File

@@ -1,3 +1,5 @@
# This file is generated by Ansible. Changes will be lost.
# Update templates under ansible/templates/
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole