Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
33 changes: 31 additions & 2 deletions roles/os_flavors/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
OpenStack Flavors
=================

This role can be used to register flavors in Nova using the
`openstack.cloud.compute_flavor` module.
This role can be used to register flavors in Nova and map them to projects
using the `openstack.cloud.compute_flavor` module.

Requirements
------------
Expand Down Expand Up @@ -32,6 +32,16 @@ may contain 'ephemeral', 'flavorid', 'rxtx_factor' and 'swap' items.
Optionally, the dict may also contain an item 'extra_specs', which is a dict of
metadata to attach to the flavor object.

`is_public` default is `true`. It is a mandatory parameter when mapping flavor
to project, and it have to be set to `false` in that case. Non public
flavor can't be mapped. However there is possibility to create flavor which
is private and not mapped to any project. Only 'true' and 'false' are
allowed here.

`project` list of project to which flavor should be mapped. In other
words: this flavor will be visible and usable only in said project. It is
a dict, with possible one element.

Dependencies
------------

Expand Down Expand Up @@ -63,6 +73,25 @@ The following playbook registers a Nova flavor.
hw:cpu_policy: "dedicated"
hw:numa_nodes: "1"

The following playbook will allow uasge of `flavor-1` only in project `projectA`.

---
- name: Map Nova flavors to projects
hosts: localhost
roles:
- role: openstack.cloud.compute_flavor_access
os_flavors_venv: "~/os-flavors-venv"
os_flavors_auth_type: "password"
os_flavors_auth:
project_name: <keystone project>
username: <keystone user>
password: <keystone password>
auth_url: <keystone auth URL>
os_flavors:
- name: flavor-1
is_public: false
project: "projectA"

Author Information
------------------

Expand Down
13 changes: 12 additions & 1 deletion roles/os_flavors/tasks/flavors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,19 @@
ephemeral: "{{ item.ephemeral | default(omit) }}"
swap: "{{ item.swap | default(omit) }}"
rxtx_factor: "{{ item.rxtx_factor | default(omit) }}"
is_public: "{{ item.is_public | default(omit) }}"
is_public: "{{ item.is_public | default('true') }}"
flavorid: "{{ item.flavorid | default(omit) }}"
extra_specs: "{{ item.extra_specs | default(omit) }}"
state: "{{ item.state | default('present') }}"
with_items: "{{ os_flavors }}"

- name: Map nova flavors to projects
openstack.cloud.compute_flavor_access:
auth_type: "{{ os_flavors_auth_type }}"
auth: "{{ os_flavors_auth }}"
cacert: "{{ os_flavors_cacert | default(omit) }}"
interface: "{{ os_flavors_interface | default(omit, true) }}"
name: "{{ item.0.name }}"
state: "{{ item.0.state | default('present') }}"
project: "{{ item.1 | default(omit) }}"
loop: "{{ lookup('subelements', os_flavors, 'project', {'skip_missing': True}) }}"