mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
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
This commit is contained in:
parent
04f63d0679
commit
df7fa04149
4 changed files with 48 additions and 4 deletions
35
examples/use-refresh-inventory.yml
Normal file
35
examples/use-refresh-inventory.yml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
- 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue