mirror of
https://github.com/ansible-collections/hetzner.hcloud
synced 2024-11-10 06:34:13 +00:00
docs: create servers with private ips only (#406)
##### SUMMARY Add an example to show how to create servers that only have private IPs.
This commit is contained in:
parent
8c35ca7fab
commit
6471779c2a
1 changed files with 50 additions and 0 deletions
50
examples/server-with-private-ip-only.yml
Normal file
50
examples/server-with-private-ip-only.yml
Normal file
|
@ -0,0 +1,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 }}"
|
Loading…
Reference in a new issue