thetechnick / hcloud-ansible

Ansible modules and inventory for Hetzner Cloud
MIT License
66 stars 6 forks source link

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

Closed thelegy closed 6 years ago

thelegy commented 6 years ago

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.

thetechnick commented 6 years ago

Hi @kerwindena, thanks for your comprehensive bug report! I will fix this in the next version.

thetechnick commented 6 years ago

https://github.com/hetznercloud/hcloud-go/issues/85

thetechnick commented 6 years ago

Bug is fixed with #8 and released in v0.3.0 Creating a server without starting it has been moved into a new issue #11, which is blocked by the issue in the hcloud-go library.