996921a5b6
File permissions not mentioned Change-Id: I5efbb06ccee9ac7e83bfcf4171c5ae7d2930128b
49 lines
1.4 KiB
YAML
49 lines
1.4 KiB
YAML
---
|
|
# Ensure we have facts about all hypervisors before scheduling begins.
|
|
- hosts: hypervisors
|
|
tags:
|
|
- schedule
|
|
gather_facts: true
|
|
|
|
- hosts: localhost
|
|
tags:
|
|
- schedule
|
|
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 }}"
|
|
|
|
- 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:
|
|
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.
|
|
# NOTE(mgoddard): Use .get to avoid a nasty error in ansible-lint
|
|
# (cannot represent an object).
|
|
content: "{{ new_state.get('result') | to_nice_yaml }}"
|
|
dest: "{{ state_file_path }}"
|
|
mode: preserve
|