Skip to content

Commit 9ada395

Browse files
jackhodgkissAlex-Welshg0rgamesh
authored
feat: add gitlab role to enable GitLab CI/CD (#29)
* feat: add `gitlab` role to enable GitLab CI/CD Add a new role `gitlab` to enable GitLab CI/CD for use in constructing a CI/CD pipeline that is compatible with `kayobe-automation`. Supports key features and workflows found within the `GitHub` role. * Apply suggestions from code review Co-authored-by: Alex-Welsh <[email protected]> * feat: add `dynamic` in-place hypervisor upgrade * Make downstream runbooks optional (#30) * add a a conditional for downstream pipelines * new line * feat: increase to version `1.2.0` --------- Co-authored-by: Alex-Welsh <[email protected]> Co-authored-by: Rafal Lewandowski <[email protected]>
1 parent 726687d commit 9ada395

File tree

11 files changed

+1039
-1
lines changed

11 files changed

+1039
-1
lines changed

galaxy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace: stackhpc
88
name: kayobe_workflows
99

1010
# The version of the collection. Must be compatible with semantic versioning
11-
version: 1.1.0
11+
version: 1.2.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

roles/gitlab/README.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
Kayobe Automation Pipeline (GitLab)
2+
===================================
3+
4+
This Ansible role is capable of generating Gitlab pipeline files for performing CI/CD related activities with OpenStack via Kayobe.
5+
See the table below for a full list of all the currently supported Kayobe automation tasks.
6+
7+
| **Name** | **Description** | **Stage** |
8+
|:---:|:---:|:---:|
9+
| **build Kayobe docker image** | Build a new Kayobe docker image whenever a new tag is pushed to the repository. The resulting image is then pushed to a docker registry such as [registry.gitlab.com/](registry.gitlab.com/). | build |
10+
| **overcloud container image build** | Build overcloud container images. | overcloud |
11+
| **overcloud container image pull** | Pull overcloud container images from a container registry. | overcloud |
12+
| **overcloud database backup** | Perform a backup of the database used by the overcloud. | overcloud |
13+
| **overcloud database recover** | Recover the database used by the overcloud. | overcloud |
14+
| **overcloud deployment image build** | Build the Ironic Python Agent (IPA) image. | overcloud |
15+
| **overcloud host command run** | Run a command against the overcloud hosts. | overcloud |
16+
| **overcloud host configure** | Perform an overcloud host configure. | overcloud |
17+
| **overcloud host image build** | Build the the image that would deployed to overcloud hosts during provisioning. | overcloud |
18+
| **overcloud host package update** | Perform an overcloud host package update. | overcloud |
19+
| **overcloud host upgrade** | Perform targeted upgrade of key services before an upgrade. | overcloud |
20+
| **overcloud inventory discover** | Get an inventory of nodes. | overcloud |
21+
| **overcloud provision** | Provision overcloud nodes. | overcloud |
22+
| **overcloud prune docker images** | Prune docker images from overcloud hosts. | overcloud |
23+
| **overcloud service configuration generate** | Generate the overcloud service configuration. | overcloud |
24+
| **overcloud service deploy** | Deploy overcloud services. | overcloud |
25+
| **overcloud service reconfigure** | Reconfigure overcloud services. | overcloud |
26+
| **overcloud service upgrade** | Perform an upgrade of overcloud services. | overcloud |
27+
| **seed container image build** | Build container images for seed. | overcloud |
28+
| **seed host configure** | Configure the seed host. | seed |
29+
| **seed host package update** | Update the system packages of the seed host. | seed |
30+
| **seed hypervisor host configure** | Configure the seed hypervisor host. | seed |
31+
| **seed hypervisor host package update** | Perform a package update of the seed hypervisor host. | seed |
32+
| **seed service deploy** | Deploy services on the seed. | seed |
33+
| **seed vm provision** | Provision the seed VM. | seed |
34+
| **infra vm host configure** | Perform a host configure of the infra VMs on demand. | infra vm |
35+
| **infra vm host package update** | Perform a package update of the infra VMs hosts on demand. | infra vm |
36+
| **infra vm provision** | Provision infra VMs on demand. | infra vm |
37+
| **infra vm service deploy** | Perform a service deploy against infra VMs on demand. | infra vm |
38+
| **network connectivity check** | Execute a network connectivity check to ensure all hosts are reachable and can reach `nc external ip ` & `nc external hostname`. | network |
39+
| **physical network configure** | Configure the physical network. | network |
40+
| **config diff** | When a pull request is opened generate diff showing the changes made to the configuration. | merge request |
41+
| **tempest** | Perform tests against the deployed openstack environment with tempest. | tempest |
42+
43+
Also available in Kayobe Automation for GitLab are runbooks which are stages designed to complete complex task such as upgrading all hypervisors in safe and reliable manner.
44+
45+
> :warning: The runbooks are **experimental** and may require careful consideration before being deployed.
46+
47+
| **Name** | **Description** |
48+
|:---:|:---:|
49+
| **runbook overcloud service upgrade** | Perform an upgrade of overcloud services; pull containers, upgrade host, run tempest, backup database, upgrade services, run tempest and prune unused docker images. |
50+
| **runbook in place hypervisor host upgrade** | Perform an in place host upgrade of hypervisors; disable compute services, drain hypervisor, package update, reboot and renable compute services. |
51+
52+
Role Variables
53+
--------------
54+
55+
The following variables can be used to make small adjustments to the composition of the workflows.
56+
57+
`gitlab_output_directory`: control the location where the workflows shall be written to.
58+
59+
`gitlab_Kayobe_environments`: list of environments the workflows should target.
60+
61+
`gitlab_registry`: a string that either points to a registry or is `$CI_REGISTRY_URL` in the case of multiple environments that do not share the same registry.
62+
63+
`gitlab_image_name`: name of the Kayobe image defaults to `Kayobe`.
64+
65+
`gitlab_image_tag`: tag used to select Kayobe image defaults to `latest`
66+
67+
`gitlab_Kayobe_base_image`: select the base image used when building the Kayobe docker image. Default is `quay.io/rockylinux/rockylinux:9`.
68+
69+
`gitlab_tempest_test_suites`: a list of options to be made available within the drop-down list for running tempest. Defaults to `default` and `tempest-full`.
70+
71+
If you wish to make more impactful changes such as which stages and built and what jobs are contained when review `gitlab_stages` in `defaults/main.yml`
72+
73+
`gitlab_stages:` is a dictionary of dictionaries that contains string blocks defining the job within a given stage. Any job may be overwritten by editing the `gitlab_JOB_NAME` or a stage can be extended adding to the `gitlab_STAGE_NAME_extra` dictionary. If you require adding additional stages that add the stage to `gitlab_extra_stages`.
74+
75+
```
76+
gitlab_infra_vm_host_configure: |
77+
rules:
78+
- !reference [.active_stage_web_rule, rules]
79+
stage: infra-vm
80+
resource_group: infra-vm
81+
script:
82+
- !reference [.get_secrets, script]
83+
- .automation/pipeline/infra-vm-host-configure.sh
84+
allow_failure: true
85+
```
86+
87+
```
88+
gitlab_infra_vm_something_new: |
89+
rules:
90+
- !reference [.active_stage_web_rule, rules]
91+
stage: infra-vm
92+
resource_group: infra-vm
93+
script:
94+
- !reference [.get_secrets, script]
95+
- .automation/pipeline/does_something_new.sh
96+
allow_failure: true
97+
98+
gitlab_stage_infra_vm_extra:
99+
infra_vm_something_new: "{{ gitlab_infra_vm_something_new }}"
100+
```
101+
102+
Finally, `gitlab_runbooks` is collection of runbooks which each compose a single stage that is designed complete a larger more involved task. For example upgrade overcloud services complete with backup of database and tempest testing both before and after. Runbooks are created similiar to normal jobs however they may need altering or even overriding to meet the needs of a given environment.
103+
104+
Example Playbook
105+
----------------
106+
107+
The following example playbook will generate a `reference` pipeline which can be found under `.gitlab` and `.gitlab/..`
108+
109+
```yaml
110+
- name: Write Kayobe Automation Pipeline for gitlab
111+
hosts: localhost
112+
roles:
113+
- stackhpc.Kayobe_workflows.gitlab
114+
```
115+
116+
License
117+
-------
118+
119+
Apache License 2.0
120+
121+
Author Information
122+
------------------
123+
124+
[StackHPC](https://www.stackhpc.com/)

0 commit comments

Comments
 (0)