blob: 67cf47e51bfc308c34e778c055d9e7f09eef4931 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
---
- name: Demonstrate creating a server that only has a private ip
hosts: localhost
connection: local
vars:
servers:
- name: my-server1
private_ip: 10.0.0.2
- name: my-server2
private_ip: 10.0.0.3
tasks:
- name: Create a network
hetzner.hcloud.network:
name: my-network
ip_range: 10.0.0.0/8
state: present
- name: Create a subnetwork
hetzner.hcloud.subnetwork:
network: my-network
ip_range: 10.0.0.0/16
network_zone: eu-central
type: cloud
state: present
- name: Create servers without public IPs
hetzner.hcloud.server:
name: "{{ item.name }}"
server_type: cx11
image: debian-12
enable_ipv4: false
enable_ipv6: false
state: stopped # A server without networking cannot be started!
loop: "{{ servers }}"
- name: Attach private IP to servers
hetzner.hcloud.server_network:
network: my-network
server: "{{ item.name }}"
ip: "{{ item.private_ip }}"
state: present
loop: "{{ servers }}"
- name: Start servers
hetzner.hcloud.server:
name: "{{ item.name }}"
state: started
loop: "{{ servers }}"
|