Extract nova-flavor role into a separate project on galaxy

This allows it to be used by other projects.
This commit is contained in:
Mark Goddard 2017-05-18 10:10:56 +01:00
parent ed229582c3
commit eb5551e3fb
7 changed files with 9 additions and 107 deletions

1
.gitignore vendored
View File

@ -55,6 +55,7 @@ ansible/roles/mrlesmithjr.manage-lvm/
ansible/roles/MichaelRigart.interfaces/
ansible/roles/stackhpc.drac/
ansible/roles/stackhpc.drac-facts/
ansible/roles/stackhpc.os-flavors/
ansible/roles/stackhpc.os-openstackclient/
ansible/roles/stackhpc.os-projects/
ansible/roles/stackhpc.os-shade/

View File

@ -36,7 +36,7 @@
ironic_node_flavor_properties: []
existing_nova_flavors: "{{ nova_flavor_list.stdout | from_json }}"
relevant_existing_flavors: []
nova_flavors: []
os_flavors: []
# Build a list of nodes' flavor-relevant properties.
- name: Set a fact containing the ironic node properties
@ -68,8 +68,8 @@
# won't work for a list of names other than 0 to N-1.
- name: Set a fact containing a list of flavors to register in nova
set_fact:
nova_flavors: >
{{ nova_flavors +
os_flavors: >
{{ os_flavors +
[item.1 | combine({'name': flavor_base_name ~ (item.0 + relevant_existing_flavors | length)})] }}
with_indexed_items: >
{{ ironic_node_flavor_properties |
@ -79,7 +79,7 @@
# Register the new flavors.
- include_role:
role: nova-flavors
nova_flavors_venv: "{{ venv }}"
nova_flavors_auth_type: "{{ openstack_auth_type }}"
nova_flavors_auth: "{{ openstack_auth }}"
role: stackhpc.os-flavors
os_flavors_venv: "{{ venv }}"
os_flavors_auth_type: "{{ openstack_auth_type }}"
os_flavors_auth: "{{ openstack_auth }}"

View File

@ -6,5 +6,6 @@
- src: resmo.ntp
- src: stackhpc.drac
- src: stackhpc.drac-facts
- src: stackhpc.os-flavors
- src: stackhpc.os-projects
- src: yatesr.timezone

View File

@ -1,59 +0,0 @@
Nova Flavors
============
This role can be used to register flavors in nova using the
os\_nova\_flavor module.
Requirements
------------
The OpenStack nova API should be accessible from the target host.
Role Variables
--------------
`nova_flavors_venv` is a path to a directory in which to create a
virtualenv.
`nova_flavors_auth_type` is an authentication type compatible with
the `auth_type` argument of `os_*` Ansible modules.
`nova_flavors_auth` is a dict containing authentication information
compatible with the `auth` argument of `os_*` Ansible modules.
`nova_flavors` is a list of nova flavors to register. Each item should be a
dict containing the items 'name', 'ram', 'disk', and 'vcpus'. Optionally, the
dict may contain 'ephemeral' and 'swap' items.
Dependencies
------------
This role depends on the Kayobe `shade` role.
Example Playbook
----------------
The following playbook registers a nova flavor.
---
- name: Ensure nova flavors are registered
hosts: nova-api
roles:
- role: nova-flavors
nova_flavors_venv: "~/nova-flavors-venv"
nova_flavors_auth_type: "password"
nova_flavors_auth:
project_name: <keystone project>
username: <keystone user>
password: <keystone password>
auth_url: <keystone auth URL>
nova_flavors:
name: flavor-1
ram: 1024
disk: 1024
vcpus: 2
Author Information
------------------
- Mark Goddard (<mark@stackhpc.com>)

View File

@ -1,14 +0,0 @@
---
# Path to a directory in which to create a virtualenv.
nova_flavors_venv:
# Authentication type.
nova_flavors_auth_type:
# Authentication information.
nova_flavors_auth: {}
# List of nova flavors to register. Each item should be a dict containing the
# items 'name', 'ram', 'disk', and 'vcpus'. Optionally, the dict may contain
# 'ephemeral' and 'swap' items.
nova_flavors: []

View File

@ -1,4 +0,0 @@
---
dependencies:
- role: stackhpc.os-shade
os_shade_venv: "{{ nova_flavors_venv }}"

View File

@ -1,23 +0,0 @@
---
- name: Set a fact to ensure Ansible uses the python interpreter in the virtualenv
set_fact:
ansible_python_interpreter: "{{ nova_flavors_venv }}/bin/python"
- name: Ensure nova flavors exist
os_nova_flavor:
auth_type: "{{ nova_flavors_auth_type }}"
auth: "{{ nova_flavors_auth }}"
name: "{{ item.name }}"
ram: "{{ item.ram }}"
vcpus: "{{ item.vcpus }}"
disk: "{{ item.disk }}"
ephemeral: "{{ item.ephemeral | default(omit) }}"
swap: "{{ item.swap | default(omit) }}"
state: present
with_items: "{{ nova_flavors }}"
# This variable is unset before we set it, and it does not appear to be
# possible to unset a variable in Ansible.
- name: Set a fact to reset the Ansible python interpreter
set_fact:
ansible_python_interpreter: /usr/bin/python