Skip to content

Commit 86b450a

Browse files
authored
Merge pull request #11 from stackhpc/host-aggregates
Add os_host_aggregates role
2 parents 8f718d5 + 81805f2 commit 86b450a

File tree

7 files changed

+120
-0
lines changed

7 files changed

+120
-0
lines changed

roles/os_host_aggregates/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
OpenStack Host Aggregates
2+
=========================
3+
4+
This role can be used to register host aggregates in Nova using the
5+
`openstack.cloud.host_aggregate` module.
6+
7+
Requirements
8+
------------
9+
10+
The OpenStack Nova API should be accessible from the target host.
11+
12+
Role Variables
13+
--------------
14+
15+
`os_host_aggregates_venv` is a path to a directory in which to create a
16+
virtualenv.
17+
18+
`os_host_aggregates_auth_type` is an authentication type compatible with the
19+
`auth_type` argument of `openstack.cloud` Ansible modules.
20+
21+
`os_host_aggregates_auth` is a dict containing authentication information
22+
compatible with the `auth` argument of `openstack.cloud` Ansible modules.
23+
24+
`os_host_aggregates_cacert` is an optional path to a CA certificate bundle.
25+
26+
`os_host_aggregates_interface` is the endpoint URL type to fetch from the
27+
service catalog. Maybe be one of `public`, `admin`, or `internal`.
28+
29+
`os_host_aggregates` is a list of Nova host aggregates to register. Each item
30+
should be a dict containing the item 'name', and optionally:
31+
32+
* 'availability_zone' (name of the availability zone to set on the aggregate)
33+
* 'hosts' (list of hostnames to add to the aggregate)
34+
* 'metadata' (dict of key/value pairs to set on the aggregate)
35+
36+
Dependencies
37+
------------
38+
39+
This role depends on the `stackhpc.openstack.os_openstacksdk` role.
40+
41+
Example Playbook
42+
----------------
43+
44+
The following playbook registers a Nova host aggregate.
45+
46+
---
47+
- name: Ensure Nova host aggregates are registered
48+
hosts: localhost
49+
roles:
50+
- role: stackhpc.openstack.os_host_aggregates
51+
os_host_aggregates_venv: "~/os-host-aggregates-venv"
52+
os_host_aggregates_auth_type: "password"
53+
os_host_aggregates_auth:
54+
project_name: <keystone project>
55+
username: <keystone user>
56+
password: <keystone password>
57+
auth_url: <keystone auth URL>
58+
os_host_aggregates:
59+
- name: db_aggregate
60+
availability_zone: az1
61+
hosts:
62+
- host1
63+
- host2
64+
metadata:
65+
type: dbcluster
66+
67+
Author Information
68+
------------------
69+
70+
- Pierre Riteau (<[email protected]>)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
# Path to a directory in which to create a virtualenv.
3+
os_host_aggregates_venv:
4+
# Authentication type.
5+
os_host_aggregates_auth_type:
6+
# Authentication information.
7+
os_host_aggregates_auth: {}
8+
# Endpoint URL type to fetch from the service catalog. Maybe be one of:
9+
# public, admin, or internal.
10+
os_host_aggregates_interface:
11+
# List of nova host aggregates to register. Each item should be a dict containing the
12+
# following items:
13+
# - 'name': Name of the host aggregate.
14+
# - 'availability_zone': Name of the availability zone, optional.
15+
# - 'hosts': List of hosts to add to the aggregate, optional.
16+
# - 'metadata': Dict of key/value pairs to set on the aggregate, optional.
17+
os_host_aggregates: [] # noqa var-naming[no-role-prefix]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
dependencies:
3+
- role: stackhpc.openstack.os_openstacksdk
4+
os_openstacksdk_venv: "{{ os_host_aggregates_venv }}"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
- name: Ensure nova host aggregates exist
3+
openstack.cloud.host_aggregate:
4+
auth_type: "{{ os_host_aggregates_auth_type }}"
5+
auth: "{{ os_host_aggregates_auth }}"
6+
cacert: "{{ os_host_aggregates_cacert | default(omit) }}"
7+
interface: "{{ os_host_aggregates_interface | default(omit, true) }}"
8+
name: "{{ item.name }}"
9+
availability_zone: "{{ item.availability_zone | default(omit) }}"
10+
hosts: "{{ item.hosts | default(omit) }}"
11+
metadata: "{{ item.metadata | default(omit) }}"
12+
state: present
13+
with_items: "{{ os_host_aggregates }}"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- name: Set a fact about the Ansible python interpreter
3+
ansible.builtin.set_fact:
4+
old_ansible_python_interpreter: "{{ ansible_python_interpreter | default('/usr/bin/python3') }}"
5+
6+
- name: Import host-aggregates.yml
7+
ansible.builtin.import_tasks: host-aggregates.yml
8+
vars:
9+
ansible_python_interpreter: "{{ os_host_aggregates_venv ~ '/bin/python' if os_host_aggregates_venv != None else old_ansible_python_interpreter }}"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
localhost ansible_connection='local' ansible_python_interpreter='/usr/bin/env python'
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
- name: Test os_host_aggregates role
3+
hosts: all
4+
connection: local
5+
roles:
6+
- stackhpc.openstack.os_host_aggregates

0 commit comments

Comments
 (0)