Comments (8)
Hi @apricote can you please here as I am blocked for long time now on this issue. your help here is greatly appreciated.
from hetzner.hcloud.
Hello @samiksha1191
I think the error you are facing is because one of the server or network does not exist (is not found). The error should be improved, I'll fix this.
But is unrelated to your questions: here are a few comments for the code you provided:
- name: Create a basic network
hetzner.hcloud.hcloud_network:
name: "{{ item.name }}"
ip_range: "{{ item.ip_range }}"
state: "{{ infrastructure_state }}"
api_token: "{{ hcloud_token }}"
with_items: "{{ networks }}"
- name: Create a basic subnetwork
# Make sure to use fqcn when calling the collection modules: hetzner.hcloud.hcloud_subnetwork
hcloud_subnetwork:
# I assume you are refering to {{ networks[0].name }}
network: network1
# You should use a different ip_range for your network and subnetwork, e.g.
# 10.0.0.0/8 for the network and only a /16 or /24 for a subnetwork, say 10.0.1.0/24
ip_range: "{{ item.ip_range }}"
network_zone: eu-central
type: cloud
state: present
api_token: "{{ hcloud_token }}"
- name: Create a basic server
# Make sure to use fqcn when calling the collection modules: hetzner.hcloud.hcloud_server
hcloud_server:
name: my-server
server_type: cx11
image: ubuntu-22.04
state: present
enable_ipv4: false
enable_ipv6: false
datacenter: nbg1-dc3
# This will automatically attach a random private ip from the subnet to your server, since you
# want to specific the private IP yourself in the next task, you should not use this
# argument.
private_networks:
- network1
api_token: "{{ hcloud_token }}"
- name: Attach a server to a private network
# Make sure to use fqcn when calling the collection modules: hetzner.hcloud.hcloud_server_network
hcloud_server_network:
# I assume you are refering to {{ networks[0].name }}
network: network1
server: my-server
ip: 10.0.1.10
state: present
api_token: "{{ hcloud_token }}"
from hetzner.hcloud.
Related to #255
from hetzner.hcloud.
Hi @jooola Please don't mark the ticket as closed just yet as the problem is not solved until yet at my end. Allow me sometime until today EOD to confirm back.
from hetzner.hcloud.
Hi @jooola If i am following the instruction you gave above then yes my server now has a private IP of my choice but it is still coming up with a public IP because I can not keep both as false.
enable_ipv4
enable_ipv6
so i commented them in the code but then now it is assuming that since i have not declared any value for the above two parameters, so it is by default assigning one ipv4 address.
In my use case I d not want to have any public IP attached to the server at all. can you please tell me how do i achieve the same?
FYI, my current code looks like below.
**_- name: Create a basic server
hcloud_server:
name: my-server
server_type: cx11
image: ubuntu-22.04
state: present
# enable_ipv4: false
# enable_ipv6: false
datacenter: nbg1-dc3
#private_networks:
#- network1
api_token: "{{ hcloud_token }}"
- name: Create a server network and specify the ip address
hcloud_server_network:
network: network1
server: my-server
ip: 10.0.1.10
state: present
api_token: "{{ hcloud_token }}"_**
from hetzner.hcloud.
Hi @jooola and now I have tried your lines of code as well from the issue #255 but it is still giving me public IP.
Please help here as it is blocking to move further. PFB screenshot FYR.
The code written to spin up this server now is
- name: Create a server
hetzner.hcloud.hcloud_server:
api_token: "{{ hcloud_token }}"
name: my-server
server_type: cx11
image: ubuntu-22.04
location: nbg1
## 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: Create a server network and specify the ip address
hetzner.hcloud.hcloud_server_network:
network: network1
server: my-server
ip: 10.0.1.10
state: present
api_token: "{{ hcloud_token }}"
delegate_to: localhost
run_once: true
from hetzner.hcloud.
Hi @apricote can you please here as well?
from hetzner.hcloud.
Hello @samiksha1191
A server without any networking cannot be started. So you can create a server that is stopped
, attach your private ip, and start the server afterward. Here is an example:
- name: Create server with a private ip and no public ip
hosts: localhost
connection: local
tasks:
- name: Create a server
hetzner.hcloud.hcloud_server:
name: my-server
server_type: cx11
image: ubuntu-22.04
location: nbg1
enable_ipv4: false
enable_ipv6: false
state: stopped
- name: Attach private ip to server
hetzner.hcloud.hcloud_server_network:
network: network1
server: my-server
ip: 10.0.1.10
state: present
- name: Start the server
hetzner.hcloud.hcloud_server:
name: my-server
state: started
Also, a few tips for any future bug report:
- You can wrap your code between triple backticks ` to format it,
**_ _**
is not a valid Markdown syntax, at least on Github. - Make sure to give all information about your problem in the initial report.
from hetzner.hcloud.
Related Issues (20)
- hcloud_firewall better error messages for missing port with tcp or udp
- hetzner.hcloud.hcloud_network module is missing network_zone option HOT 4
- 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
- Create Primary IP on Server
- hcloud_load_balancer_info don't return status HOT 7
- Assign or unassign existing primary IP from the `primary_ip` module HOT 1
- Volume is unassigned if the server argument is not specified
- No inventory was parsed HOT 3
- Use resource action endpoints instead of global one HOT 1
- Cannot connect to a server via ssh after creating them HOT 2
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.