Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 24 additions & 31 deletions upi/openstack/04_control-plane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,38 +43,31 @@
- os_networking_type == "Kuryr"
- "os_cp_trunk_name|string not in control_plane_trunks.stdout"

- name: 'Get a token for creating the server group'
os_auth:
register: cloud
- name: 'List the Server groups'
command:
cmd: "openstack server group list -f json -c ID -c Name"
register: server_group_list

- name: 'Parse the Server group ID from existing'
set_fact:
server_group_id: "{{ (server_group_list.stdout | from_json | json_query(list_query) | first).ID }}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I particularly like the fact that in server group list you get IDs, whereas in server group create you get lowercase ids 🤦‍♂️

vars:
list_query: "[?Name=='{{ os_cp_server_group_name }}']"
when:
- "os_cp_server_group_name|string in server_group_list.stdout"

# If microversion 2.15 is not available, replace with:
# - name: 'Create the Control Plane server group'
# uri:
# method: POST
# headers:
# X-Auth-Token: "{{ cloud.ansible_facts.auth_token }}"
# X-OpenStack-Nova-API-Version: '2.64'
# url: "{{ cloud.ansible_facts.service_catalog | selectattr('name', 'match', 'nova') | first | json_query('endpoints') | selectattr('interface', 'match', 'public') | first | json_query('url') }}/os-server-groups"
# body_format: json
# body:
# server_group:
# name: "{{ os_cp_server_group_name }}"
# policy: "soft-anti-affinity"
# register: cp_group
- name: 'Create the Control Plane server group'
uri:
method: POST
headers:
X-Auth-Token: "{{ cloud.ansible_facts.auth_token }}"
X-OpenStack-Nova-API-Version: '2.15'
url: "{{ cloud.ansible_facts.service_catalog | selectattr('name', 'match', 'nova') | first | json_query('endpoints') | selectattr('interface', 'match', 'public') | first | json_query('url') }}/os-server-groups"
body_format: json
body:
server_group:
name: "{{ os_cp_server_group_name }}"
policies:
- soft-anti-affinity
register: cp_group
command:
cmd: "openstack --os-compute-api-version=2.15 server group create -f json -c id --policy=soft-anti-affinity {{ os_cp_server_group_name }}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this compute api version always be available regardless if it's osp 13 or 16? what happens if it's not?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The maximum microversion supported in Queens (on which OSP13 is based) is 2.60. 2.15 has been introduced in Mitaka, we should have some margin :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for the minimum (e.g. "will new OSP versions support old microversions?"), the documentation says that they still target 2.1 as the minimum microversion. No deprecation notice in sight.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

register: server_group_created
when:
- server_group_id is not defined

- name: 'Parse the Server group ID from creation'
set_fact:
server_group_id: "{{ (server_group_created.stdout | from_json).id }}"
when:
- server_group_id is not defined

- name: 'Create the Control Plane servers'
os_server:
Expand All @@ -90,5 +83,5 @@
nics:
- port-name: "{{ os_port_master }}-{{ item.0 }}"
scheduler_hints:
group: "{{ cp_group.json.server_group.id }}"
group: "{{ server_group_id }}"
with_indexed_items: "{{ [os_cp_server_name] * os_cp_nodes_number }}"