Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: create servers with private ips only #406

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exclude_paths:
- .git/
- .github/
- changelogs/
- examples/
- tests/integration/targets/certificate
- tests/integration/targets/firewall
- tests/integration/targets/floating_ip
Expand Down
50 changes: 50 additions & 0 deletions examples/server-with-private-ip-only.yml
Original file line number Diff line number Diff line change
@@ -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 }}"