tenks/ansible/cleanup_state.yml
Mark Goddard 512174a828 Bump ansible version constraints to >=2.7,<2.10
This means that ansible 2.9 is typically used, and causes ansible-lint
to fail. Two workarounds have been added to address this:

* Use .get() to avoid passing an undefined object through to_nice_yaml
  filter
* Create a dummy tenks_update_state.py module to avoid ansible-lint
  being confused about our action plugin.

Change-Id: I54388f713e17a47601be2db63a26fc43ca7ac6c8
2020-03-11 16:55:09 +00:00

25 lines
710 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 }}"