Search code examples
network-programmingdeploymentansiblehcloud

Ansible Hetzner Cloud - Create a server in private network


I am using Ansible to create a server in the Hetzner Cloud, the playbook reads:

- name: create the server at Hetzner
  hetzner.hcloud.hcloud_server:
    name: "{{server_hostname}}"
    enable_ipv4: false
    enable_ipv6: false
    server_type: cx11
    location: "{{server_location}}"
    image: ubuntu-22.04
    ssh_keys:
    - "mykey"
    state: present
    api_token: "{{hetzner_secret}}"
    private_networks: ipfire
  register: server

My aim is to integrate the new server into the private network named 'ipfire' that I have previously created. The server should not be accessible via the internet, so I have disabled ipv4 and ipv6. Rather, I'd like to access the server by connecting via OpenVPN to the private network 'ipfire' and connect by use of ssh from there.

Unfortunately, I get an error message as follows:

PLAY [Order servers] ********************************************************************************************************

TASK [hetznerserver : create the server at Hetzner] *************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (hetzner.hcloud.hcloud_server) module: private_networks. Supported parameters include: rebuild_protection, api_token, location, enable_ipv6, upgrade_disk, ipv4, endpoint, ipv6, firewalls, server_type, state, force, labels, ssh_keys, delete_protection, image, id, name, enable_ipv4, placement_group, force_upgrade, user_data, datacenter, rescue_mode, allow_deprecated_image, volumes, backups."}

PLAY RECAP ******************************************************************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0    

The module private_networks does not seem to work like this?


Solution

  • Error messages like Unsupported parameters for (<moduleName>) module: <givenParameter>. Supported parameters include: <supportedParametersList> are usually syntax errors of the module used.

    Therefore one may need to look up the respective documentation, in the example case hcloud_server module – Create and manage cloud servers on the Hetzner Cloud.

    If the documentation shows the Parameters in question are available, it indicates

    • either a version mismatch of module used, means the used version is too old and an update is necessary
    • or an bug within the module code and further debugging and investigation within the module code is necessary

    Code and Documentation Links

    After further investigation it might turn out that the parameter in question was introduced recently, in example

    • Github hetzner.hcloud Issue #150 "Unable to create cloud server without public ipv4 and ipv6"
    • Github hetzner.hcloud Pull #160 "Add possibility to specify private network when creating or updating servers"

    which indicates in your example case that you'll need to update the Ansible Collection module in question since the parameter wasn't introduced in your used version of the module but as of v1.9.0.