Skip to content

Commit 52aa648

Browse files
authored
Merge pull request #1 from stackhpc/github-v1
GitHub V1
2 parents a9db335 + 067d39b commit 52aa648

17 files changed

+440
-1286
lines changed

galaxy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace: stackhpc
88
name: kayobe_automation_workflows
99

1010
# The version of the collection. Must be compatible with semantic versioning
11-
version: 0.1.0
11+
version: 1.0.0
1212

1313
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
1414
readme: README.md
@@ -47,7 +47,7 @@ tags:
4747
dependencies: {}
4848

4949
# The URL of the originating SCM repository
50-
repository: https://github.com/jackhodgkiss/kayobe-automation-workflows
50+
repository: https://github.com/stackhpc/ansible-collection-kayobe-workflows
5151

5252
# The URL to any online docs
5353
# documentation: http://docs.example.com

poetry.lock

Lines changed: 0 additions & 885 deletions
This file was deleted.

pyproject.toml

Lines changed: 0 additions & 19 deletions
This file was deleted.

roles/github/README.md

Lines changed: 58 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Kayobe Automation Workflow (GitHub)
1+
Kayobe Automation Workflows (GitHub)
22
=========
33

44
This Ansible role is capable of generating GitHub workflow files for performing CI/CD related activities with OpenStack via Kayobe.
@@ -16,11 +16,10 @@ See the table below for a full list of all the currently supported kayobe automa
1616
| **run-overcloud-container-image-pull** | Pull container images from a container registry. |
1717
| **run-overcloud-database-backup** | Perform a backup of the database used by the overcloud. |
1818
| **run-overcloud-host-configure** | Perform an overcloud host configure. |
19-
| **run-overcloud-host-package-update** | Update system packages on the overcloud hosts. |
19+
| **run-overcloud-host-package-update** | Perform an overcloud host package update. |
2020
| **run-overcloud-inventory-discover** | Get an inventory of nodes. |
2121
| **run-overcloud-provision** | Provision overcloud nodes. |
2222
| **run-overcloud-service-deploy** | Deploy overcloud services. |
23-
| **run-overcloud-service-reconfigure** | Reconfigure services across the overcloud. |
2423
| **run-overcloud-service-upgrade** | Perform an upgrade of overcloud services. |
2524
| **run-seed-host-configure** | Configure the seed host. |
2625
| **run-seed-host-package-update** | Update the system packages of the seed host. |
@@ -35,19 +34,23 @@ Role Variables
3534

3635
The following variables can be used to make small adjustments to the composition of the workflows.
3736

38-
`output_directory`: control the location where the workflows shall be written to.
37+
`github_output_directory`: control the location where the workflows shall be written to.
3938

40-
`runner_name`: name of the GitHub runner used by the workflows see [runs-on](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on).
39+
`github_runs_on`: control which runner can accept this workflow. See GitHub for more information on [runs-on](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on).
4140

42-
`image_url`: full URL of the kayobe container image complete with registry and tag.
41+
`github_image_url`: full URL of the kayobe container image complete with registry and tag.
4342

44-
`registry_password`: password used to authenticate with the docker registry.
43+
`github_registry_username`: username used to authenticate with the docker registry.
4544

46-
`kayobe_arguments`: a dictionary of arguments that can be used to override the default arguments found within `vars/main.yml`. For example if you wanted to change the value of `KAYOBE_ENVIRONMENT` from its default of `production` you can simply add `KAYOBE_ENVIRONMENT` to this dictionary and it will take precedence over the defaults.
45+
`github_registry_password`: password used to authenticate with the docker registry.
46+
47+
`github_kayobe_arguments`: a dictionary of arguments that can be used to override the default arguments found within `vars/main.yml`. For example if you wanted to change the value of `KAYOBE_ENVIRONMENT` from its default of `production` you can simply add `KAYOBE_ENVIRONMENT` to this dictionary and it will take precedence over the defaults.
48+
49+
`github_*_hook:` see section [Template Hooks](#template-hooks) for information about this variables
4750

4851
If you wish to make more impactful changes such as which workflows are built and what they contain then see the list of dictionaries called `workflows` in `defaults/main.yml`
4952

50-
`workflows:` is a list of dictionaries that contains each of the workflows described above. A given list element is made up of the following:
53+
`github_workflows:` is a list of dictionaries that contains each of the workflows described above. A given list element is made up of the following:
5154

5255
- `name`: the name which the workflow shall refer to itself as within GitHub workflows user interface.
5356

@@ -57,62 +60,69 @@ If you wish to make more impactful changes such as which workflows are built and
5760

5861
- `arguments`: list of arguments keys used by the automation task the contents will be acquired from `kayobe_arguments` or the defaults.
5962

60-
The following will override `workflows` to ensure only `Run overcloud database backup` is generated.
63+
- `path_override`: Some workflows benefit from a dedicated workflow template as the `generic.yml.j2` cannot meet the requirements of all workflows. Therefore it might be beneficial to create specific templates within the `{{ playbook_dir }}/templates/` directory and set this variable to that specific path.
64+
65+
- `use_bespoke`: As mentioned in `path_override` some workflows require a more specific template to meet their needs. Setting this to true would create a workflow from a bespoke template if one exists within the roles `templates` directory. Note this is intended for **internal use only**.
66+
67+
The following will override `github_workflows` to ensure only `Build Kayobe Image` and `Run Kolla Config Diff` is generated.
6168

6269
```yaml
63-
workflows:
64-
- name: Run overcloud database backup
65-
file_name: run-overcloud-database-backup.yml
66-
trigger:
67-
workflow_dispatch: *combined_inputs
68-
schedule:
69-
cron: "30 0 * * *"
70-
arguments:
71-
- KOLLA_TAGS
72-
- KOLLA_LIMIT
73-
- KAYOBE_TAGS
74-
- KAYOBE_LIMIT
75-
- HOME
70+
github_workflows:
71+
- "{{ build_kayobe_image }}"
72+
- "{{ run_kolla_config_diff }}"
7673
```
7774
78-
Example Playbook
79-
----------------
80-
81-
The following example playbook will generate a series of `reference` workflows which can be found under `.github/workflows`
75+
In the following example `github_build_kayobe_image` has been changed to use a user provided template stored within their `{{ playbook_dir }}/templates`
8276

8377
```yaml
84-
- name: Write Kayobe Automation Workflows
85-
hosts: localhost
86-
collections:
87-
- stackhpc.kayobe_automation_workflows
78+
github_build_kayobe_image:
79+
file_name: build-kayobe-docker-image.yml
80+
path_override: "{{ playbook_dir }}/templates/build-kayobe-docker-image.yml.j2"
8881
```
8982

90-
Hooks [Experimental]
91-
--------------------
9283

93-
> :warning: This feature is marked as `experimental` at the moment as it is not clear how to configure `ansible.builtin.template` to look at the `${{ playbook_dir }}/templates/hooks/`.
9484

95-
Workflows can be expanded with the use of `hooks` which are templates that if provided can be inserted into the appropriate location enabling the introduction of additional steps within the workflow job.
96-
This could include the use of HashiCorp Vault or installing and configuring a network proxy.
85+
Template Hooks
86+
--------------
87+
88+
Workflows can be expanded with the use of hooks which are variables that if provided can be inserted into the appropriate location enabling the introduction of additional steps within the workflow job. This could include the use of HashiCorp Vault or installing and configuring a network proxy.
89+
90+
There are currently three hooks available
91+
92+
- `github_checkout_hook`: a hook that occurs before the repository is cloned by the `checkout` action.
9793

94+
- `github_kayobe_hook`: a hook that occurs after the the repository has been cloned and before the kayobe automation task has started.
9895

96+
- `github_final_hook`: a hook that occurs after the kayobe automation task has finished.
97+
98+
A hook must be defined as a variable and should be a scalar block string.
9999

100100
```yaml
101+
github_checkout_hook: |
102+
- name: Import secrets via Hashicorp Vault
103+
id: secrets
104+
uses: hashicorp/[email protected]
105+
with:
106+
url: https://vault.stackhpc.com:8200
107+
method: approle
108+
roleId: ${{ secrets.ROLE_ID }}
109+
secretId: ${{ secrets.SECRET_ID }}
110+
tlsSkipVerify: true
111+
secrets: |
112+
stackhpc/data/github kayobe_vault_password_${{ needs.env.outputs.environment }} | KAYOBE_VAULT_PASSWORD ;
113+
stackhpc/data/github kayobe_automation_ssh_private_key_${{ needs.env.outputs.environment }} | KAYOBE_AUTOMATION_SSH_PRIVATE_KEY ;
114+
```
101115

102-
- name: Import secrets via Hashicorp Vault
103-
id: secrets
104-
uses: hashicorp/[email protected]
105-
with:
106-
url: https://vault.stackhpc.com:8200
107-
method: approle
108-
roleId: ${{ secrets.ROLE_ID }}
109-
secretId: ${{ secrets.SECRET_ID }}
110-
tlsSkipVerify: true
111-
secrets: |
112-
stackhpc/data/github kayobe_vault_password_${{ needs.env.outputs.environment }} | KAYOBE_VAULT_PASSWORD ;
113-
stackhpc/data/github kayobe_automation_ssh_private_key_${{ needs.env.outputs.environment }} | KAYOBE_AUTOMATION_SSH_PRIVATE_KEY ;
116+
Example Playbook
117+
----------------
114118

119+
The following example playbook will generate a series of `reference` workflows which can be found under `.github/workflows`
115120

121+
```yaml
122+
- name: Write Kayobe Automation Workflows for GitHub
123+
hosts: localhost
124+
roles:
125+
- stackhpc.kayobe_automation_workflows.github
116126
```
117127

118128
License

0 commit comments

Comments
 (0)