ansible-collections / hetzner.hcloud

A collection to manage resources on Hetzner Cloud
https://galaxy.ansible.com/ui/repo/published/hetzner/hcloud
GNU General Public License v3.0
100 stars 35 forks source link

Create Primary IP on Server #464

Closed justin-jeffery-ipf closed 4 months ago

justin-jeffery-ipf commented 4 months ago
SUMMARY

I cannot enable a Public IP on an existing server that has it disabled. I should be able to from the CLI documentation.

https://docs.hetzner.cloud/#primary-ips-create-a-primary-ip

ISSUE TYPE
COMPONENT NAME

hetzner.hcloud.primary_ip

ADDITIONAL INFORMATION
- name: Create a basic IPv4 Primary IP
  hetzner.hcloud.primary_ip:
    name: "{{ server.hcloud_server.name }}"
    assignee_id: "{{ server.hcloud_server.id }}"
    type: ipv4
    auto_delete: true

# API:
- name: Enable public IP
  ansible.builtin.uri:
    url: "https://api.hetzner.cloud/v1/primary_ips"
    method: POST
    body_format: json
    body:
      assignee_id: "{{ server.hcloud_server.id }}"
      assignee_type: "server"
      type: "ipv4"
      name: "{{ server.hcloud_server.name }}"
      auto_delete: true
    status_code: 201
    headers:
      Authorization: "Bearer {{ HETZNER_TOKEN }}"
      Content-Type: "application/json"