Skip to content

Commit c382516

Browse files
committed
Merge remote-tracking branch 'generic/main' into generic-config-sync
2 parents 9f26e6a + c2508a6 commit c382516

19 files changed

+301
-88
lines changed

.github/workflows/pull-request.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: Pull request
3+
"on":
4+
pull_request:
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-22.04
8+
permissions: {}
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
include:
13+
# NOTE(upgrade): Keep these in sync with Kayobe's supported Ansible and Python versions (see release notes).
14+
- ansible: "2.16"
15+
python: "3.12"
16+
name: Ansible ${{ matrix.ansible }} lint with Python ${{ matrix.python }}
17+
steps:
18+
- name: GitHub Checkout 🛎
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Python ${{ matrix.python-version }} 🐍
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: ${{ matrix.python }}
25+
26+
- name: Install dependencies 📦
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install ansible-core==${{ matrix.ansible }}.* ansible-lint
30+
31+
- name: Linting code 🧪
32+
run: |
33+
ansible-lint -v --force-color

README.rst

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@ OpenStack Configuration
33
=============================================
44

55
This project contains Ansible playbooks and configuration of infrastructure on
6-
an existing OpenStack cloud for the OpenStack system. (Supported up to Yoga
7-
release.)
6+
an existing OpenStack cloud for the OpenStack system.
87

98
Preparation
109
===========
1110

1211
Ensure that Ansible is installed, either via the system package manager or pip.
13-
If required, use a virtualenv to avoid interference with the system python
14-
packages. For example:
12+
It is recommended that you use a python virtual environment to avoid
13+
interference with the system python packages. For example:
1514

1615
.. code-block::
1716
18-
$ virtualenv venv
19-
$ source venv/bin/activate
17+
$ python3 -m venv openstack-venv
18+
$ source openstack-venv/bin/activate
2019
$ python -m pip install --upgrade pip
2120
$ pip install -r requirements.txt
2221
2322
Install Ansible role and collection dependencies from Ansible Galaxy:
2423

2524
.. code-block::
25+
2626
$ ansible-galaxy collection install \
2727
-p ansible/collections \
2828
-r requirements.yml
@@ -87,10 +87,16 @@ variables in `etc/openstack-config.yml`
8787

8888
.. code-block:: yaml
8989
90-
magnum_default_master_flavor_name: # Chosen flavor on target cloud
91-
magnum_default_worker_flavor_name: # Chosen flavor on target cloud
92-
magnum_external_net_name: # External network
93-
magnum_loadbalancer_provider: # Octavia provider (e.g. 'ovn')
90+
# Chosen flavor on target cloud
91+
magnum_default_master_flavor_name:
92+
# Chosen flavor on target cloud
93+
magnum_default_worker_flavor_name:
94+
# External network to use for load balancers etc.
95+
magnum_external_net_name:
96+
# Octavia provider (e.g. 'ovn')
97+
magnum_loadbalancer_provider:
98+
# Optional list of extra labels to add to all generated cluster templates
99+
magnum_template_extra_labels:
94100
95101
then run the provided playbook with
96102

ansible.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[defaults]
2+
bin_ansible_callbacks = True
3+
callbacks_enabled = ansible.posix.profile_tasks
4+
stdout_callback = yaml

ansible/generate-magnum-capi-templates.yml

Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,59 @@
44
vars:
55
root_dir: ../
66
tasks:
7-
8-
- name: Check that required variables are defined
9-
assert:
10-
that:
11-
- magnum_default_master_flavor_name is defined
12-
- magnum_default_worker_flavor_name is defined
13-
- magnum_external_net_name is defined
14-
- magnum_loadbalancer_provider is defined
15-
16-
- name: Fetch capi-helm-charts release information
17-
ansible.builtin.uri:
18-
url: https://api.github.com/repos/stackhpc/capi-helm-charts/releases/latest
19-
register: capi_helm_chart_release_data
20-
21-
- name: Fetch dependencies.json for capi-helm-charts release
22-
ansible.builtin.uri:
23-
url: https://raw.githubusercontent.com/stackhpc/capi-helm-charts/{{ capi_helm_chart_release_data.json.tag_name }}/dependencies.json
24-
register: dependencies_response
25-
26-
- name: Ensure wget packages is installed
27-
become: true
28-
package:
29-
name: wget
30-
state: present
31-
32-
- name: Fetch manifest.json for capi-helm-charts images
7+
- name: Check that required variables are defined
8+
ansible.builtin.assert:
9+
that:
10+
- magnum_default_master_flavor_name is defined
11+
- magnum_default_worker_flavor_name is defined
12+
- magnum_external_net_name is defined
13+
- magnum_loadbalancer_provider is defined
14+
15+
- name: Fetch capi-helm-charts release information
16+
ansible.builtin.uri:
17+
url: https://api.github.com/repos/azimuth-cloud/capi-helm-charts/releases/latest
18+
register: capi_helm_chart_release_data
19+
20+
- name: Fetch dependencies.json for capi-helm-charts release
21+
ansible.builtin.uri:
22+
url: https://raw.githubusercontent.com/azimuth-cloud/capi-helm-charts/{{ capi_helm_chart_release_data.json.tag_name }}/dependencies.json
23+
register: dependencies_response
24+
25+
- name: Ensure wget packages is installed
26+
become: true
27+
ansible.builtin.package:
28+
name: wget
29+
state: present
30+
31+
- name: Fetch manifest.json for capi-helm-charts images # noqa command-instead-of-module
3332
# ansible.builtin.uri:
34-
# url: https://raw.githubusercontent.com/stackhpc/azimuth-images/{{ dependencies_response.json['azimuth-images'] }}/manifest.json
33+
# url: https://raw.githubusercontent.com/azimuth-cloud/azimuth-images/{{ dependencies_response.json['azimuth-images'] }}/manifest.json
3534
# Above URL returns 404 even though similar URL for capi-helm-charts repo works fine
3635
# Not sure why but fall back to wget + JSON parsing for now.
37-
shell: "wget -O - https://github.com/stackhpc/azimuth-images/releases/download/{{ dependencies_response.json['azimuth-images'] }}/manifest.json"
38-
register: manifest_response
39-
changed_when: false
40-
41-
- name: Parse JSON response
42-
set_fact:
43-
new_template_data: "{{ manifest_response.stdout | from_json | dict2items | selectattr('key', 'match', 'kubernetes*') | list }}"
44-
45-
- name: Ensure output dir exists
46-
ansible.builtin.file:
47-
path: "{{ [root_dir, 'generated-magnum-snippets', now(utc=true,fmt='%Y-%m-%d-T%H-%M-%S')] | path_join }}"
48-
state: directory
49-
mode: '0755'
50-
register: output_dir
51-
52-
- name: Write new image config to file
53-
template:
54-
src: "magnum-capi-images.j2"
55-
dest: "{{ output_dir.path }}/images.yml"
56-
57-
- name: Write new cluster template config to file
58-
template:
59-
src: "magnum-capi-templates.j2"
60-
dest: "{{ output_dir.path }}/templates.yml"
36+
ansible.builtin.command: >-
37+
wget -O - https://github.com/azimuth-cloud/azimuth-images/releases/download/{{ dependencies_response.json['azimuth-images'] }}/manifest.json
38+
register: manifest_response
39+
changed_when: false
40+
41+
- name: Parse JSON response
42+
ansible.builtin.set_fact:
43+
new_template_data: "{{ manifest_response.stdout | from_json | dict2items | selectattr('key', 'match', 'kubernetes*') | list }}"
44+
45+
- name: Ensure output dir exists
46+
ansible.builtin.file:
47+
path: "{{ [root_dir, 'generated-magnum-snippets', now(utc=true, fmt='%Y-%m-%d-T%H-%M-%S')] | path_join }}"
48+
state: directory
49+
mode: "0755"
50+
register: output_dir
51+
52+
- name: Write new image config to file
53+
ansible.builtin.template:
54+
src: "magnum-capi-images.j2"
55+
dest: "{{ output_dir.path }}/images.yml"
56+
mode: "0644"
57+
58+
- name: Write new cluster template config to file
59+
ansible.builtin.template:
60+
src: "magnum-capi-templates.j2"
61+
dest: "{{ output_dir.path }}/templates.yml"
62+
mode: "0644"

ansible/group_vars/all/openstack

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,26 @@ openstack_host_aggregates: []
6262
# List of clusters templates in the openstack project. Format is as required by the
6363
# stackhpc.os-container-clusters role.
6464
openstack_container_clusters_templates: []
65+
66+
###############################################################################
67+
# Configuration variables for a CloudKitty ratings service deployment.
68+
69+
# A list where each item is a dictionary mapping the associated fields,
70+
# with the 'mappings' field also being a list of dictionaries.
71+
# Example of the mappings and their fields can be found below,
72+
# however for more information please refer to the README.md file.
73+
#
74+
openstack_ratings_hashmap_field_mappings: []
75+
76+
# Much like the field mappings above, the service mappings are a list of
77+
# dictionaries, however these are not associated with a field.
78+
#
79+
openstack_ratings_hashmap_service_mappings: []
80+
81+
###############################################################################
82+
# Configuration of volumes for OpenStack.
83+
openstack_volumes_types: []
84+
85+
###############################################################################
86+
# Configuration of Cloudkitty for OpenStack.
87+
openstack_cloudkitty_enable: false

ansible/openstack-ratings.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
- name: Generate OpenStack software ratings
3+
hosts: localhost
4+
tags:
5+
- ratings
6+
roles:
7+
- role: stackhpc.openstack.os_ratings
8+
os_ratings_hashmap_field_mappings: "{{ openstack_ratings_hashmap_field_mappings }}"
9+
os_ratings_hashmap_service_mappings: "{{ openstack_ratings_hashmap_service_mappings }}"
10+
os_ratings_venv: "{{ openstack_venv }}"

ansible/openstack-volume-types.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: Ensure OpenStack volume types exist
3+
hosts: localhost
4+
tags:
5+
- volume-types
6+
roles:
7+
- role: stackhpc.openstack.os_volumes
8+
os_volumes_venv: "{{ openstack_venv }}"
9+
os_volumes_auth_type: "{{ openstack_auth_type }}"
10+
os_volumes_auth: "{{ openstack_auth }}"
11+
os_volumes_cacert: "{{ openstack_cacert }}"
12+
os_volumes_types: "{{ openstack_volumes_types }}"

ansible/openstack.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
---
22
# Top level playbook that includes all others.
3-
- import_playbook: openstack-project.yml
4-
- import_playbook: openstack-networks.yml
5-
- import_playbook: openstack-flavors.yml
6-
- import_playbook: openstack-images.yml
7-
- import_playbook: openstack-host-aggregates.yml
8-
- import_playbook: openstack-container-clusters.yml
3+
4+
- import_playbook: openstack-project.yml # noqa name[play]
5+
- import_playbook: openstack-networks.yml # noqa name[play]
6+
- import_playbook: openstack-flavors.yml # noqa name[play]
7+
- import_playbook: openstack-images.yml # noqa name[play]
8+
- import_playbook: openstack-host-aggregates.yml # noqa name[play]
9+
- import_playbook: openstack-volume-types.yml # noqa name[play]
10+
- import_playbook: openstack-container-clusters.yml # noqa name[play]
11+
- import_playbook: openstack-ratings.yml # noqa name[play]
12+
when: openstack_cloudkitty_enable | bool

ansible/templates/magnum-capi-images.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
name: "{{ item.value.name }}"
1616
type: qcow2
1717
image_url: "{{ item.value.url }}"
18-
visibility: "community"
18+
visibility: "public"
1919
properties:
2020
os_distro: "ubuntu"
21-
os_version: "20.04"
21+
os_version: "22.04"
2222
kube_version: "{{ item.value.kubernetes_version }}"
2323

2424
{% endfor %}

ansible/templates/magnum-capi-templates.j2

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
keystone_auth_enabled: "false"
1717
capi_helm_chart_version: "{{ capi_helm_chart_release_data.json.tag_name }}"
1818
octavia_provider: {{ magnum_loadbalancer_provider }}
19+
{% if magnum_template_extra_labels is defined and magnum_template_extra_labels is not none %}
20+
{{ magnum_template_extra_labels | to_nice_yaml | indent(4) -}}
21+
{% endif %}
1922
external_network_id: {{ magnum_external_net_name }}
2023
master_flavor: {{ magnum_default_master_flavor_name }}
2124
flavor: {{ magnum_default_worker_flavor_name }}
@@ -28,4 +31,4 @@
2831
dns_nameserver: "{{ (magnum_cluster_default_dns_nameservers | default(['1.1.1.1', '8.8.8.8', '8.8.4.4'])) | join(',') }}"
2932
public: "{{ magnum_cluster_templates_public | default('True') }}"
3033

31-
{% endfor %}
34+
{% endfor %}

0 commit comments

Comments
 (0)