Skip to content

Commit 9381d80

Browse files
committed
Add os_host_aggregates role
Imported from https://github.com/stackhpc/ansible-role-os-host-aggregates
1 parent a6f2394 commit 9381d80

File tree

7 files changed

+140
-0
lines changed

7 files changed

+140
-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+
os\_nova\_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 `os_*` Ansible modules.
20+
21+
`os_host_aggregates_auth` is a dict containing authentication information
22+
compatible with the `auth` argument of `os_*` 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.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: nova-api
49+
roles:
50+
- role: stackhpc.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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
# Path to a directory in which to create a virtualenv.
3+
os_host_aggregates_venv:
4+
5+
# Authentication type.
6+
os_host_aggregates_auth_type:
7+
8+
# Authentication information.
9+
os_host_aggregates_auth: {}
10+
11+
# Endpoint URL type to fetch from the service catalog. Maybe be one of:
12+
# public, admin, or internal.
13+
os_host_aggregates_interface:
14+
15+
# List of nova host aggregates to register. Each item should be a dict containing the
16+
# following items:
17+
# - 'name': Name of the host aggregate.
18+
# - 'availability_zone': Name of the availability zone, optional.
19+
# - 'hosts': List of hosts to add to the aggregate, optional.
20+
# - 'metadata': Dict of key/value pairs to set on the aggregate, optional.
21+
os_host_aggregates: []
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
galaxy_info:
3+
role_name: os_host_aggregates
4+
author: Pierre Riteau
5+
description: >
6+
Role to register nova host aggregates in OpenStack
7+
company: StackHPC Ltd
8+
license: Apache2
9+
min_ansible_version: 2.6
10+
platforms:
11+
- name: EL
12+
versions:
13+
- 7
14+
- 8
15+
galaxy_tags:
16+
- cloud
17+
- nova
18+
- openstack
19+
20+
dependencies:
21+
- role: stackhpc.os_openstacksdk
22+
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+
os_nova_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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
- name: Set a fact about the Ansible python interpreter
3+
set_fact:
4+
old_ansible_python_interpreter: "{{ ansible_python_interpreter | default('/usr/bin/python' + ansible_python.version.major | string) }}"
5+
6+
- import_tasks: host-aggregates.yml
7+
vars:
8+
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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- hosts: all
3+
connection: local
4+
roles:
5+
- stackhpc.os_host_aggregates

0 commit comments

Comments
 (0)