tenks/ansible/cleanup_state.yml
Michal Nasiadka 6af32ae579 Fix ansible-lint errors
Add jinja[spacing] to warn list and fix name[play] issues.

Change-Id: Ie9d1d92e8c2fc2e69e0d1fd14ec859ebc67f6a38
2022-09-06 09:35:31 +02:00

27 lines
761 B
YAML

---
- name: Cleanup Tenks state
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