Comments (1)
Hi @liKe2k1,
I was able to reproduce your problem, and the server gets a random/first IP from the "net-region" network IP range (10.145.0.0/16).
To attach the desired IP (10.145.1.11), you can try removing the private_networks
entry when creating the server. When using this field, you will ask to attach an IP within the IP range of that network (10.145.0.0/16). And let the hetzner.hcloud.hcloud_server_network
module attach the correct IP to the server.
Here is my reproduction playbook:
- hosts: all
vars:
hcloud_token: some_token
network_name: net-region
network_region: 10.145.0.0/16
default_os: rocky-9
region: fsn1
subnets:
- name: management
ip_range: 10.145.1.0/24
- name: kubernetes
ip_range: 10.145.5.0/24
- name: client
ip_range: 10.145.10.0/24
servers:
- name: lvjump01
ip: 10.145.1.11
network: management
type: cpx11
tasks:
- name: Create the internal network
hetzner.hcloud.hcloud_network:
api_token: "{{ hcloud_token }}"
name: "{{ network_name }}"
ip_range: "{{ network_region }}"
state: present
run_once: true
delegate_to: localhost
- name: Create subnets
hetzner.hcloud.hcloud_subnetwork:
api_token: "{{ hcloud_token }}"
network: "{{ network_name }}"
ip_range: "{{ item.ip_range }}"
network_zone: eu-central
type: cloud
state: present
with_items: "{{ subnets }}"
run_once: true
delegate_to: localhost
- name: Create a server
hetzner.hcloud.hcloud_server:
api_token: "{{ hcloud_token }}"
name: "{{ servers[0].name }}"
server_type: "{{ servers[0].type }}"
image: "{{ default_os }}"
location: "{{ region }}"
## Comment this out to prevent attaching a random IP from the "{{ network_name }}" ip range.
#private_networks:
# - "{{ network_name }}"
state: started
delegate_to: localhost
run_once: true
- name: Attach a private ip
hetzner.hcloud.hcloud_server_network:
api_token: "{{ hcloud_token }}"
network: "{{ network_name }}"
server: "{{ servers[0].name }}"
ip: "{{ servers[0].ip }}"
state: present
delegate_to: localhost
run_once: true
I hope this helps ?
from hetzner.hcloud.
Related Issues (20)
- Dependency Dashboard
- Drop support for python 3.7 HOT 1
- hcloud_load_balancer_target with HCLOUD_TOKEN env - missing required arguments: api_token HOT 2
- Support algorithm selection for hcloud_load_balancer
- Make `*_info` modules consistent on how they handle invalid ID requests HOT 2
- Allow querying floating_ip_info by name
- hcloud_load_balancer_service returns certificates instead of status codes HOT 1
- hcloud_firewall better error messages for missing port with tcp or udp
- hetzner.hcloud.hcloud_network module is missing network_zone option HOT 4
- Create a server with no public IP and a given static private IP HOT 8
- hcloud_certificate documentation has values in SSH format instead of PEM
- hcloud_certificate domain_names documentation wrong
- hcloud_server delete_protection and rebuild_protection can't be applied HOT 1
- hcloud_firewall cannot delete firewalls that are in use HOT 2
- Drop support for ansible-core 2.13
- 2.4.0 breaks `refresh_inventory`
- Ansible in a venv is not loading the hcloud inventory plugin HOT 3
- hcloud_load_balancer reports change every time HOT 2
- hcloud_load_balancer_service reports change every time HOT 2
- Generate diff for all modules HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hetzner.hcloud.