mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
The CX Gen 2 and CPX Gen 1 types are deprecated and will be removed from the API at the end of the year. This replaces all usages in our docs, so users do not have to figure it out themselves.
35 lines
794 B
YAML
35 lines
794 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: cpx22
|
|
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
|