Adjust Nova Allocation Ratios Playbook

+ Create Role nova-config which can be reused to configure any item
  in nova.conf if supplied a correctly formatted list of dictionary
  items.

Change-Id: I6100541e2d48783846262008ddef0da07f4af310
This commit is contained in:
akrzos 2016-07-28 11:26:23 -04:00
parent 30d277c145
commit 9c98d7ea26
3 changed files with 135 additions and 0 deletions

View File

@ -0,0 +1,75 @@
---
#
# Playbook to change Nova allocation ratios
#
# Examples:
# ansible-playbook -i hosts browbeat/adjustment-nova-allocation.yml -e "cpu_allocation_ratio=24"
# ansible-playbook -i hosts browbeat/adjustment-nova-allocation.yml -e "cpu_allocation_ratio=24 ram_allocation_ratio=10.0"
# ansible-playbook -i hosts browbeat/adjustment-nova-allocation.yml -e "cpu_allocation_ratio=24 ram_allocation_ratio=10.0 disk_allocation_ratio=10.0"
#
# * Note not setting a variable does not change that configuration item then. Setting no variables
# and running the playbook sets all configuration items back to defaults
#
# Defaults (defaults being what OSPd9 comes with out of the box cpu/ram/disk - 16/1/1)
# ansible-playbook -i hosts browbeat/adjustment-nova-allocation.yml
#
- hosts: controller
remote_user: heat-admin
gather_facts: false
vars:
# Create initial blank configuration list
nova_configuration: []
# Defaults
default_cpu_allocation_ratio: 16
default_ram_allocation_ratio: 1
default_disk_allocation_ratio: 1
# Each configuration item needs to be a list so it can be merged
cpu_allocation_ratio_item: []
ram_allocation_ratio_item: []
disk_allocation_ratio_item: []
pre_tasks:
- name: Set default cpu_allocation_ratio/ram_allocation_ratio/disk_allocation_ratio configuration for Nova
set_fact:
nova_configuration:
- section: DEFAULT
option: cpu_allocation_ratio
value: "{{default_cpu_allocation_ratio}}"
- section: DEFAULT
option: ram_allocation_ratio
value: "{{default_ram_allocation_ratio}}"
- section: DEFAULT
option: disk_allocation_ratio
value: "{{default_disk_allocation_ratio}}"
when: cpu_allocation_ratio is undefined and ram_allocation_ratio is undefined and disk_allocation_ratio is undefined
- name: Set cpu_allocation_ratio configuration for Nova
set_fact:
cpu_allocation_ratio_item:
- section: DEFAULT
option: cpu_allocation_ratio
value: "{{cpu_allocation_ratio}}"
when: cpu_allocation_ratio is defined
- name: Set ram_allocation_ratio configuration for Nova
set_fact:
ram_allocation_ratio_item:
- section: DEFAULT
option: ram_allocation_ratio
value: "{{ram_allocation_ratio}}"
when: ram_allocation_ratio is defined
- name: Set disk_allocation_ratio configuration for Nova
set_fact:
disk_allocation_ratio_item:
- section: DEFAULT
option: disk_allocation_ratio
value: "{{disk_allocation_ratio}}"
when: disk_allocation_ratio is defined
- name: Merge configuration items
set_fact:
nova_configuration: "{{nova_configuration + cpu_allocation_ratio_item + ram_allocation_ratio_item + disk_allocation_ratio_item }}"
roles:
- nova-config

View File

@ -0,0 +1,39 @@
---
#
# Nova handlers for browbeat adjustment
#
- name: unmanage nova services
become: true
command: pcs resource unmanage {{ item }}
with_items:
- openstack-nova-api
- openstack-nova-scheduler
- openstack-nova-conductor
ignore_errors: true
- name: restart nova services
become: true
service: name={{ item }} state=restarted
with_items:
- openstack-nova-api
- openstack-nova-scheduler
- openstack-nova-conductor
- name: manage nova services
become: true
command: pcs resource manage {{ item }}
with_items:
- openstack-nova-api
- openstack-nova-scheduler
- openstack-nova-conductor
ignore_errors: true
- name: cleanup nova services
become: true
command: pcs resource cleanup {{ item }}
with_items:
- openstack-nova-api
- openstack-nova-scheduler
- openstack-nova-conductor
ignore_errors: true

View File

@ -0,0 +1,21 @@
---
#
# Configure nova.conf tasks
#
- name: Configure nova.conf
become: true
ini_file:
dest: /etc/nova/nova.conf
mode: 0640
section: "{{ item.section }}"
option: "{{ item.option }}"
value: "{{ item.value }}"
backup: yes
with_items:
- "{{nova_configuration}}"
notify:
- unmanage nova services
- restart nova services
- manage nova services
- cleanup nova services