ansible-collection-hetzner-.../examples/use-refresh-inventory.yml
Jonas L df7fa04149
fix(inventory): always use fresh cache on new cached session (#404)
##### SUMMARY

The class scoped `cache` dict was being shared across all
`cached_session`, we now make sure that the cache is instance scoped.

Fixes #403

##### ISSUE TYPE

- Bugfix Pull Request
2023-11-24 20:50:43 +01:00

35 lines
793 B
YAML

---
- name: Demonstrate the usage of 'refresh_inventory'
hosts: localhost
connection: local
tasks:
- name: Print hostvars
ansible.builtin.debug:
var: hostvars
- name: Create new server
hetzner.hcloud.server:
name: my-server
server_type: cx11
image: debian-12
- name: Refresh inventory
ansible.builtin.meta: refresh_inventory
- name: Run tests
block:
- name: Print updated inventory
ansible.builtin.debug:
var: hostvars
- name: Verify hostvars is not empty
ansible.builtin.assert:
that:
- hostvars != {}
always:
- name: Cleanup server
hetzner.hcloud.server:
name: my-server
state: absent