tenks/ansible/cleanup_state.yml
Mark Goddard 6e2bb04fae Add playbook tags
Allows for easily running specific playbooks.

Change-Id: Ia859238042eb286b61758acd8f99361c10dc0a05
2019-03-27 16:43:13 +00:00

23 lines
589 B
YAML

---
- hosts: localhost
tags:
- cleanup-state
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 }}"