tenks/ansible/cleanup_state.yml
Riccardo Pittau 996921a5b6 Fix ansiblelint 208
File permissions not mentioned

Change-Id: I5efbb06ccee9ac7e83bfcf4171c5ae7d2930128b
2020-09-01 11:33:13 +02:00

26 lines
733 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.
# 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