Allow teardown of Nova flavors

This commit is contained in:
Will Miller 2018-09-10 15:32:04 +00:00
parent fbd489dddf
commit ee0600fab6
4 changed files with 11 additions and 3 deletions

View File

@ -1,7 +1,7 @@
---
- hosts: localhost
tasks:
- name: Register Nova flavors
- name: Configure Nova flavors
include_role:
name: nova-flavors
vars:
@ -9,3 +9,4 @@
flavors_python_upper_constraints_url: >-
{{ python_upper_constraints_url }}
flavors: "{{ nova_flavors }}"
flavors_state: "{{ 'absent' if cmd == 'teardown' else 'present' }}"

View File

@ -1,7 +1,9 @@
Nova Flavors
============
This role creates flavors in Nova.
This role manages flavors in Nova. If `flavors_state` is `present`, it will
ensure the specified flavors eexist; if it is `absent`, it will ensure they do
not.
Requirements
------------
@ -19,3 +21,5 @@ Role Variables
OpenStack clients.
- `flavors_python_upper_constraints_url`: The URL of the upper constraints file
to pass to pip when installing Python packages.
- `flavors_state`: Whether the specified flavors should be `present` or
`absent`. Default is `present`.

View File

@ -23,3 +23,5 @@ flavors_virtualenv_path:
# The URL of the upper constraints file to pass to pip when installing Python
# packages.
flavors_python_upper_constraints_url:
# Whether the specified flavors should be `present` or `absent`.
flavors_state: present

View File

@ -6,7 +6,7 @@
-c {{ flavors_python_upper_constraints_url }}
virtualenv: "{{ flavors_virtualenv_path }}"
- name: Register Nova flavors
- name: Configure Nova flavors
os_nova_flavor:
auth_type: password
name: "{{ item.name | default(item.resource_class) }}"
@ -28,6 +28,7 @@
| combine(forbidden_traits)
| combine(item.custom_specs | default({}))
}}
state: "{{ flavors_state }}"
vars:
hw_specs:
"resources:DISK_GB": 0