50cf161bf9
node_name_prefix (default tk0) can be used to set a custom prefix for the node names. vol_name_prefix (default vol) can be used to set a custom prefix for the volume names. Support already existed for these in the action plugin, but the variables were not passed through. Change-Id: If968707285f9a8450bf16ca7a4956de6164986de TrivialFix
51 lines
1.6 KiB
YAML
51 lines
1.6 KiB
YAML
---
|
|
# Ensure we have facts about all hypervisors before scheduling begins.
|
|
- hosts: hypervisors
|
|
gather_facts: true
|
|
|
|
- hosts: localhost
|
|
tasks:
|
|
- name: Check that all specified node types exist
|
|
fail:
|
|
msg: >
|
|
The non-existent node type {{ item.type }} was specified in
|
|
'specs'.
|
|
when: item.type not in node_types
|
|
loop: "{{ specs }}"
|
|
|
|
# Creates a dict mapping each hypervisor's hostname to its hostvars, to be
|
|
# used during scheduling.
|
|
- name: Collect hypervisor hostvars
|
|
set_fact:
|
|
hypervisor_vars: >-
|
|
{{ hypervisor_vars | default({}) | combine({item: hostvars[item]}) }}
|
|
loop: "{{ groups['hypervisors'] }}"
|
|
|
|
- name: Check if an existing state file exists
|
|
stat:
|
|
path: "{{ state_file_path }}"
|
|
register: stat_result
|
|
|
|
- name: Read existing state from file
|
|
include_vars:
|
|
file: "{{ state_file_path }}"
|
|
name: current_state
|
|
when: stat_result.stat.exists
|
|
|
|
- name: Get updated state
|
|
tenks_update_state:
|
|
hypervisor_vars: "{{ hypervisor_vars }}"
|
|
node_name_prefix: "{{ node_name_prefix | default(omit) }}"
|
|
node_types: "{{ node_types }}"
|
|
specs: "{{ specs }}"
|
|
state: "{{ current_state | default(omit) }}"
|
|
vol_name_prefix: "{{ vol_name_prefix | default(omit) }}"
|
|
register: new_state
|
|
|
|
- name: Write new state to file
|
|
copy:
|
|
# tenks_schedule lookup plugin outputs a dict. Pretty-print this to
|
|
# persist it in a YAML file.
|
|
content: "{{ new_state.result | to_nice_yaml }}"
|
|
dest: "{{ state_file_path }}"
|