diff --git a/README.md b/README.md index 71bd3bef..eac09bf8 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/ansible/chain-operator-files.yml b/ansible/chain-operator-files.yml new file mode 100644 index 00000000..11b83226 --- /dev/null +++ b/ansible/chain-operator-files.yml @@ -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 diff --git a/ansible/group_vars/all b/ansible/group_vars/all new file mode 100644 index 00000000..13e4ac87 --- /dev/null +++ b/ansible/group_vars/all @@ -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" diff --git a/ansible/templates/crd.yml.j2 b/ansible/templates/crd.yml.j2 new file mode 100644 index 00000000..d6fa6c70 --- /dev/null +++ b/ansible/templates/crd.yml.j2 @@ -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: -postgres-configuration and + should look like: + + apiVersion: v1 + kind: Secret + metadata: + name: -postgres-configuration + namespace: + stringData: + host: + port: + database: + username: + password: + type: Opaque + required: + - deployment_type diff --git a/deploy/operator.yaml b/ansible/templates/operator.yml.j2 similarity index 90% rename from deploy/operator.yaml rename to ansible/templates/operator.yml.j2 index 43f73ea5..d6105102 100644 --- a/deploy/operator.yaml +++ b/ansible/templates/operator.yml.j2 @@ -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 diff --git a/deploy/role.yaml b/ansible/templates/role.yml.j2 similarity index 100% rename from deploy/role.yaml rename to ansible/templates/role.yml.j2 diff --git a/deploy/role_binding.yaml b/ansible/templates/role_binding.yml.j2 similarity index 100% rename from deploy/role_binding.yaml rename to ansible/templates/role_binding.yml.j2 diff --git a/deploy/service_account.yaml b/ansible/templates/service_account.yml.j2 similarity index 100% rename from deploy/service_account.yaml rename to ansible/templates/service_account.yml.j2 diff --git a/build/chain-operator-files.yml b/build/chain-operator-files.yml deleted file mode 100644 index 039f3276..00000000 --- a/build/chain-operator-files.yml +++ /dev/null @@ -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 }}" diff --git a/deploy/awx-operator.yaml b/deploy/awx-operator.yaml index b3300fac..e0ffd229 100644 --- a/deploy/awx-operator.yaml +++ b/deploy/awx-operator.yaml @@ -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