c0227d29b4
Add a cleanup_state.yml playbook that is run after every deployment and teardown. It will remove any nodes marked as 'absent' from the state file, by calling schedule.py with `prune_only=True`.
21 lines
561 B
YAML
21 lines
561 B
YAML
---
|
|
- hosts: localhost
|
|
tasks:
|
|
- name: Load state from file
|
|
include_vars:
|
|
file: "{{ state_file_path }}"
|
|
name: tenks_state
|
|
|
|
- name: Prune absent nodes from state
|
|
tenks_update_state:
|
|
prune_only: true
|
|
state: "{{ tenks_state }}"
|
|
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 }}"
|