Giter Club home page Giter Club logo

hcloud-ansible's Introduction

Archived
As I don't use this project anymore myself, I decided to archive it.

Hetzner Cloud - Ansible

GitHub release Build Status

The Hetzner Cloud (hcloud) ansible modules and inventory are used to interact with the resources supported by Hetzner Cloud. The modules and inventory need to be configured with an Hetzner Cloud API token before they can be used.

Inventory Example Usage

# ping all hosts in Hetzner Cloud Project
ansible -i hcloud_inventory all -m ping

# ping all hosts with cx11 server type
ansible -i hcloud_inventory cx11 -m ping

Modules

Installation

Download the binaries for your OS from the releases page and place them into your Ansible library.

Licence

MIT license

hcloud-ansible's People

Contributors

thetechnick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hcloud-ansible's Issues

hcloud_floating_ip: passed id from loop item is not of type int

I have exactly the some construct as the second example for this module in a playbook:

- hcloud_floating_ip:
    state: list
  register: hcloud_floating_ips

- hcloud_floating_ip:
    id: "{{ item.id }}"
    server: "{{ inventory_hostname }}"
  loop: "{{ hcloud_floating_ips.floating_ips }}"

If I let this playbook run, I get:

failed: [node1] (item={'id': <removed>, 'description': 'Cloud Ingress', 'ip': '<removed>', 'type': 'ipv4',
'server_id': 0, 'home_location': 'nbg1'}) => {"changed": false, "item": {"description": "description",
"home_location": "nbg1", "id": <removed>, "ip": "<removed>", "server_id": 0, "type": "ipv4"},
"msg": "Cannot parse arguments file: json: cannot unmarshal string into Go struct field arguments.id of type int"}

Even if I add the int filter to the id of the floating ip like id: "{{ item.id | int }}", I get the same result.
If I use the old style with_items, I get the same failure
If I use the id as a constant, everything works as expexted.

I guess this has something to do with the handling of variables in loops?

Another strange thing is by the way, that I always get back 0 as a server_id. Is this intended?

Reverse DNS configuration

At the moment there seems to be no support in your modules to set the reverse_dns entries, niether within hcloud_server nor within hcloud_floating_ip.

I believe this is mostly analog to hetznercloud/terraform-provider-hcloud#32.

I would like to have either support for reverse_dns entries in the modules mentioned above or maybe its own module just for reverse entries.

hcloud_server force parameter for implicit destruction of servers

As an enhancement I would like to have some kind of force-flag.

If you have a server already up and running as a cx11 for example and you run your hcloud_server module against it but you change the servertype to something else, let's say cx21, the whole server will be taken down and recreated with a complete loss of all data. This seems quite risky to me.

I would like to have a 'force' flag that would need to be set for all actions with potential loss of data. Without this flag set all actions that destroy the server would need to fail. This would make for a much safer use of your module.

For consitency reasons I would also require the force flag for the state=absent but that is not critical as state=absent states the destruction of the server clearly, but for all cases where it happens implicitly I believe it is quite importent.

hcloud_server runtime error when removing server that's not present

Description

hcloud_server fails with a runtime error when specifying an already absent server to be removed.

Example Playbook:

- name: remove hosts
    hcloud_server:
      name:
        - already.absent.host
      state: absent

Error

fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "panic: runtime error: invalid memory address or nil pointer dereference\n[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x122e20b]\n\ngoroutine 1 [running]:\ngithub.com/thetechnick/hcloud-ansible/vendor/github.com/hetznercloud/hcloud-go/hcloud.(*ServerClient).Delete(0xc4200f2068, 0x14280e0, 0xc420010098, 0x0, 0x1, 0x1, 0x0)\n\t/home/nschieder/Projects/go/src/github.com/thetechnick/hcloud-ansible/vendor/github.com/hetznercloud/hcloud-go/hcloud/server.go:284 +0x3b\nmain.(*module).absent(0xc42000e9c0, 0x14280e0, 0xc420010098, 0x0, 0x0, 0xc420010000, 0x0, 0xc420044bc0, 0x1)\n\t/home/nschieder/Projects/go/src/github.com/thetechnick/hcloud-ansible/cmd/hcloud_server/main.go:118 +0x102\nmain.(*module).run(0xc42000e9c0, 0x14280e0, 0xc420010098, 0x0, 0x0, 0xc42003be80, 0x1010be8, 0x20, 0x12afd00)\n\t/home/nschieder/Projects/go/src/github.com/thetechnick/hcloud-ansible/cmd/hcloud_server/main.go:97 +0x2fb\nmain.(*module).Run(0xc42000e9c0, 0xc4200d8520, 0x3c5, 0x1262220, 0xc42000e9c0, 0x0, 0x0)\n\t/home/nschieder/Projects/go/src/github.com/thetechnick/hcloud-ansible/cmd/hcloud_server/main.go:84 +0xd3\ngithub.com/thetechnick/hcloud-ansible/pkg/ansible.RunModule(0x1425fe0, 0xc42000e9c0, 0xc4200860f0)\n\t/home/nschieder/Projects/go/src/github.com/thetechnick/hcloud-ansible/pkg/ansible/module.go:51 +0x3e0\nmain.main()\n\t/home/nschieder/Projects/go/src/github.com/thetechnick/hcloud-ansible/cmd/hcloud_server/main.go:565 +0x76\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 2}

Expected behaviour

Module should return an "ok" status, since server is already absent.

Unable to build

Probably I'm missing something:

ago@spectre /tmp $ git clone https://github.com/thetechnick/hcloud-ansible.git
Cloning into 'hcloud-ansible'...
remote: Enumerating objects: 395, done.
remote: Total 395 (delta 0), reused 0 (delta 0), pack-reused 395
Receiving objects: 100% (395/395), 383.01 KiB | 1.10 MiB/s, done.
Resolving deltas: 100% (104/104), done.

ago@spectre /tmp $ cd hcloud-ansible

ago@spectre /tmp/hcloud-ansible $ make
can't load package: package github.com/thetechnick/hcloud-ansible/cmd/hcloud_ssh_key: cannot find package "github.com/thetechnick/hcloud-ansible/cmd/hcloud_ssh_key" in any of:
        /usr/lib/go/src/github.com/thetechnick/hcloud-ansible/cmd/hcloud_ssh_key (from $GOROOT)
        /home/ago/go/src/github.com/thetechnick/hcloud-ansible/cmd/hcloud_ssh_key (from $GOPATH)
make: *** [Makefile:18: bin/hcloud_ssh_key] Error 1

ago@spectre /tmp/hcloud-ansible $ make release
GOOS=linux GOARCH=amd64 go build -o bin/linux_amd64/hcloud_server -ldflags "-w -X github.com/thetechnick/hcloud-ansible/pkg/version.VersionTag=v0.3.2 -X github.com/thetechnick/hcloud-ansible/pkg/version.Branch=master -X github.com/thetechnick/hcloud-ansible/pkg/version.BuildDate=1554126550" -a github.com/thetechnick/hcloud-ansible/cmd/hcloud_server
can't load package: package github.com/thetechnick/hcloud-ansible/cmd/hcloud_server: cannot find package "github.com/thetechnick/hcloud-ansible/cmd/hcloud_server" in any of:
        /usr/lib/go/src/github.com/thetechnick/hcloud-ansible/cmd/hcloud_server (from $GOROOT)
        /home/ago/go/src/github.com/thetechnick/hcloud-ansible/cmd/hcloud_server (from $GOPATH)
make: *** [Makefile:58: bin/linux_amd64/hcloud_server] Error 1

hcloud_server doesn't find image by ID

Hcloud_server doesn't find image by ID, using name works as expected. This makes using snapshots unusable, since they have no name, only ID.

fatal: [localhost]: FAILED! => { "changed": false, "msg": "requested image with name 168855 not found" }

Library installation is unclear

Hello, the link to the official documentation for installing the library is not pointing to the right instructions anymore.
I've tried copying the .zip file to the library/ folder inside the playbook, the extracted binaries, in a subfolder library/hcloud/, and even by specifiying a library folder in the ~/.ansible.cfg, no avail.

I'm hoping for some patience, thanks.

Installation

Can you clarify where I can find the mentioned release page to download the binaries?

Problem creating new server

TASK [create new server] ***************************************************************************
fatal: [localhost]: FAILED! => changed=true 
  msg: cannot perform operation because server is locked (locked)

How can the server be locked if it is only being created? There did exist an old server by the same name, but it has already been removed.

Inventory example usage fails

Hi,

I tried to run your example:

ansible -i hcloud_inventory all -m ping

But I get the following output:

[WARNING]: Unable to parse /Users/foobar/hcloud_inventory as an inventory
source

[WARNING]: No inventory was parsed, only implicit localhost is available

[WARNING]: provided hosts list is empty, only localhost is available. Note
that the implicit localhost does not match 'all'

I have copied the hcloud_inventory binary into ~/.ansible/plugins/modules/ on my macOS machine.

Any ideas what's wrong?

Return state showing 'running' falsely (and no image)

When a new server is created with 'state=stopped' the server is spawned and not started but the return values of the hcloud_server module report it as 'running'

Minimal testcase would be the following. You might have to add a token somewhere.

ansible 'localhost' -m hcloud_server -a 'name=test image=debain-9 server_type=cx11 state= stopped'

Expected behaviour is that the server gets created but is not started. The return values of the module need to reflect the state of the server with all the values filled properly and the status being 'off':

localhost | SUCCESS => {
    "changed": true, 
    "msg": "Server 1234 created, Server 1234 stopped", 
    "servers": [
        {
            "datacenter": "nbg1-dc3", 
            "id": 1234, 
            "image": "debian-9", 
            "location": "nbg1", 
            "name": "test", 
            "public_ipv4": "195.201.123.456", 
            "public_ipv6": "2a01:4f8:1c1c:abcd::/64", 
            "server_type": "cx11", 
            "status": "off"
        }
    ]
}

Actual behaviour is that the server gets created but is not started. The return values of the module to reflect the state of the server with the values filled properly but the 'image' variable blank and status being 'running':

localhost | SUCCESS => {
    "changed": true, 
    "msg": "Server 1234 created, Server 1234 stopped", 
    "servers": [
        {
            "datacenter": "nbg1-dc3", 
            "id": 1234, 
            "image": "", 
            "location": "nbg1", 
            "name": "test", 
            "public_ipv4": "195.201.123.456", 
            "public_ipv6": "2a01:4f8:1c1c:abcd::/64", 
            "server_type": "cx11", 
            "status": "running"
        }
    ]
}

I do not know if the 'image' variable being blank is intentional but the status is clearly wrong.

Also the message suggests you are creating the server and stopping it instantly after that. The API seems to supply the start_after_create flag for that case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.