Code Monkey home page Code Monkey logo

hetzner.hcloud's People

Contributors

adi146 avatar andersson007 avatar apricote avatar galaxy102 avatar gundalow avatar hacklschorsch avatar hcloud-bot avatar hoerup avatar jjeff07 avatar jooola avatar lkaemmerling avatar lrsksr avatar n00b42 avatar nuux avatar ohdearaugustin avatar renovate[bot] avatar resmo avatar simonhaas avatar svanrossem avatar tagirb avatar tofi86 avatar urbanekpj avatar xoxys 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  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  avatar  avatar  avatar

hetzner.hcloud's Issues

hcloud_server: traceback when state=started in diff mode

SUMMARY

Non exisitng server with state=started and check mode fails with traceback

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'status'
fatal: [mail1.ngine.ch]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 102, in <module>\n  File \"<stdin>\", line 94, in _ansiballz_main\n  File \"<stdin>\", line 40, in invoke_module\n  File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_hcloud_server_payload_s8f9ff5_/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 564, in <module>\n  File \"/tmp/ansible_hcloud_server_payload_s8f9ff5_/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 548, in main\n  File \"/tmp/ansible_hcloud_server_payload_s8f9ff5_/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 454, in start_server\nAttributeError: 'NoneType' object has no attribute 'status'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
ISSUE TYPE
  • Bug Report
COMPONENT NAME

hcloud_server

ANSIBLE VERSION
ansible 3.0.0
CONFIGURATION

OS / ENVIRONMENT
STEPS TO REPRODUCE
- name: create server with ssh key
  hcloud_server:
    name: "{{ hcloud_server_name }}"
    server_type: "{{ hcloud_server_type }}"
    image: "{{ hcloud_server_image }}"
    location: "{{ hcloud_server_location }}"
    ssh_keys: "{{ hcloud_ssh_key_name }}"
    api_token: "{{ hcloud_api_token or omit }}"
    state: started
  register: server
EXPECTED RESULTS

no traceback

ACTUAL RESULTS

traceback


Updating an existing server with a firewall deactivates and deletes backups

SUMMARY

With hetzner.hcloud.hcloud_firewall I create a new firewall. Then I attach it with hetzner.hcloud.hcloud_server to a server. During the process of attaching the server to the firewall the backup functionality is disabled and existing backups are deleted. This can be seen in the Hcloud activities log as well.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

hcloud_server.py

STEPS TO REPRODUCE
- name: Firewall for "{{inventory_hostname}}"
  hetzner.hcloud.hcloud_firewall:
    api_token: "{{ HCLOUD_TOKEN }}"
    name: "{{ inventory_hostname }}"
    state: present
    rules: "{{ fw_rules }}"
  delegate_to: localhost

- name: Attach server to firewall
  hetzner.hcloud.hcloud_server:
    api_token: "{{ HCLOUD_TOKEN }}"
    name: "{{ inventory_hostname }}"
    firewalls:
      - "{{ inventory_hostname }}"
    state: present
  delegate_to: localhost
EXPECTED RESULTS

Server is added to Firewall with no additional changes to the server.

ACTUAL RESULTS

At least backups get deactivated for the added server. During deactivation all backups are deleted. Currently, I can't say if any other parameters of the server also get changed or are affected. But at least backups are gone when running the playbook.

hcloud_volume_info instead of hcloud_volume_facts

hcloud_volume_info shouldn't require api_token if it's already in the environment variable of the machine running ansible. That's how hcloud_volume_facts worked. There's no need to give this value again all of a sudden.

I'm getting Failed to import the required Python library (hcloud-python) on staging's Python /usr/bin/python3 error as well when I'm running this. Why does hcloud_volume_info require pip hcloud to be installed (because hcloud_volume_facts didn't).

hetzner.hcloud.hcloud_load_balancer failing on dns_ptr error (from hcloud-python)

SUMMARY

The hcloud_load_balancer is failing on keyword argument error in the Python hcloud_load_balancer.py file.

  File "/home/vsts/.local/lib/python3.8/site-packages/hcloud/load_balancers/client.py", line 311, in <listcomp>
    BoundLoadBalancer(self, load_balancer_data) for load_balancer_data in response["load_balancers"]
  File "/home/vsts/.local/lib/python3.8/site-packages/hcloud/load_balancers/client.py", line 29, in __init__
    ipv4_address = IPv4Address(**public_net['ipv4'])
ISSUE TYPE
  • Bug Report
COMPONENT NAME

hcloud_load_balancer

ANSIBLE VERSION
ansible==2.10.7
COLLECTION VERSION
# /home/vsts/.local/lib/python3.8/site-packages/ansible_collections
Collection                Version
------------------------- -------
amazon.aws                1.4.0  
junipernetworks.junos     1.3.0  
mellanox.onyx             1.0.0  
netapp.aws                20.9.0 
netapp.elementsw          20.11.0
netapp.ontap              20.12.0
netapp_eseries.santricity 1.1.0  
netbox.netbox             1.2.1  
ngine_io.cloudstack       1.2.0  
ngine_io.exoscale         1.0.0  
ngine_io.vultr            1.1.0  
openstack.cloud           1.2.1  
openvswitch.openvswitch   1.1.0  
ovirt.ovirt               1.3.0  
purestorage.flasharray    1.6.2  
purestorage.flashblade    1.4.0  
servicenow.servicenow     1.0.4  
splunk.es                 1.0.2  
theforeman.foreman        1.5.1  
vyos.vyos                 1.1.1  
wti.remote                1.0.1  

CONFIGURATION
ansible-config dump --only-changed
( nothing )
OS / ENVIRONMENT

Linux fv-az234-103 5.8.0-1039-azure #42~20.04.1-Ubuntu SMP Thu Jul 15 14:11:07 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"

STEPS TO REPRODUCE
- name: Create the main load balancer
  hetzner.hcloud.hcloud_load_balancer:
    api_token: '{{hetzner_api_token}}'
    name: lb-{{dns_shortname_suffix}}
    load_balancer_type: lb11
    location: fsn1
    state: present
  register: load_balancer
EXPECTED RESULTS

The load balancer will be created

ACTUAL RESULTS

Failed with Python traceback

TASK [hetzner-master : Create the main load balancer] **************************
task path: /home/vsts/work/1/s/roles/hetzner-master/tasks/main.yml:62
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: vsts
<127.0.0.1> EXEC /bin/sh -c 'echo ~vsts && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/vsts/.ansible/tmp `"&& mkdir "` echo /home/vsts/.ansible/tmp/ansible-tmp-1629878340.800816-2282-78190925982195 `" && echo ansible-tmp-1629878340.800816-2282-78190925982195="` echo /home/vsts/.ansible/tmp/ansible-tmp-1629878340.800816-2282-78190925982195 `" ) && sleep 0'
Using module file /home/vsts/.local/lib/python3.8/site-packages/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_load_balancer.py
<127.0.0.1> PUT /home/vsts/.ansible/tmp/ansible-local-1926w14howjl/tmpl12c18bc TO /home/vsts/.ansible/tmp/ansible-tmp-1629878340.800816-2282-78190925982195/AnsiballZ_hcloud_load_balancer.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/vsts/.ansible/tmp/ansible-tmp-1629878340.800816-2282-78190925982195/ /home/vsts/.ansible/tmp/ansible-tmp-1629878340.800816-2282-78190925982195/AnsiballZ_hcloud_load_balancer.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /home/vsts/.ansible/tmp/ansible-tmp-1629878340.800816-2282-78190925982195/AnsiballZ_hcloud_load_balancer.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/vsts/.ansible/tmp/ansible-tmp-1629878340.800816-2282-78190925982195/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/home/vsts/.ansible/tmp/ansible-tmp-1629878340.800816-2282-78190925982195/AnsiballZ_hcloud_load_balancer.py", line 102, in <module>
    _ansiballz_main()
  File "/home/vsts/.ansible/tmp/ansible-tmp-1629878340.800816-2282-78190925982195/AnsiballZ_hcloud_load_balancer.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/vsts/.ansible/tmp/ansible-tmp-1629878340.800816-2282-78190925982195/AnsiballZ_hcloud_load_balancer.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.hetzner.hcloud.plugins.modules.hcloud_load_balancer', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib/python3.8/runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_hetzner.hcloud.hcloud_load_balancer_payload_st38147l/ansible_hetzner.hcloud.hcloud_load_balancer_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_load_balancer.py", line 323, in <module>
  File "/tmp/ansible_hetzner.hcloud.hcloud_load_balancer_payload_st38147l/ansible_hetzner.hcloud.hcloud_load_balancer_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_load_balancer.py", line 317, in main
  File "/tmp/ansible_hetzner.hcloud.hcloud_load_balancer_payload_st38147l/ansible_hetzner.hcloud.hcloud_load_balancer_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_load_balancer.py", line 268, in present_load_balancer
  File "/tmp/ansible_hetzner.hcloud.hcloud_load_balancer_payload_st38147l/ansible_hetzner.hcloud.hcloud_load_balancer_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_load_balancer.py", line 187, in _get_load_balancer
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Rules in firewall (With a loop) are replaced instead of added

SUMMARY

When using UFW this works:

    - name: Allow all access from master to this host
      ufw:
        rule: allow
        src: "{{ hostvars[item].ansible_default_ipv4.address }}"
      with_items: "{{ groups.rke_master }}"

But when using the same setup with hetzner.hcloud.hcloud_firewall the last ip address will replace the previous ones.
I humbly suggest that this is not expected behavior for a loop in ansible.

      - name: Creating a test firewall
        hetzner.hcloud.hcloud_firewall:
          name: test
          rules:
            - direction: in
              protocol: icmp
              source_ips:
                - "{{ hostvars[item].ansible_default_ipv4.address }}/32"
          state: present
        with_items: "{{ groups.rke_master }}"
ISSUE TYPE
  • Bug Report
COMPONENT NAME
  • hcloud_firewall
ANSIBLE VERSION
ansible 2.10.3
  config file = /home/mark/Documents/nmvo/infra/ansible/ansible.cfg
  configured module search path = ['/home/mark/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/mark/.local/lib/python3.8/site-packages/ansible
  executable location = /home/mark/.local/bin/ansible
  python version = 3.8.6 (default, Jan 27 2021, 15:42:20) [GCC 10.2.0]
OS / ENVIRONMENT

Hetzner cloud

EXPECTED RESULTS

Addresses are added to the rule, not replaced

Ansible doesn't parse specific project or hcloud.yml file

SUMMARY

I have a really weird behavior
I have 3 projects where I use ansible hcloud plugin via "export HCLOUD_TOKEN"
2 of them work as expected.
But one has a strange behavior
export HCLOUD_TOKEN=token1
ansible-inventory -vvv -i app/appname1/prod/prod-hcloud.yml --list
shows group of servers

export HCLOUD_TOKEN=problem_project_token
ansible-inventory -vvv -i app/appname2/prod/prod-hcloud.yml --list
can't parse...

prod-hcloud.yml files differs only by tag label keys
plugin: hcloud
label_selector: "environment=prod, app=appname, tag=tag1"
groups:
sync: labels["environment"]=="prod" and labels["app"]=="appname" and labels["tag"]=="tag1"

Meanwhile I was able to nock to Hetzner API via the problem token and get my servers info!
Even more I do provision my infra via terraform using the same token...
The only thing I can't do - parse inventory only in one project

  • I've create a bunch of tokens in that project and non of them is working with my inventory file
    Ok, i thought that something wrong with my inventory file and I export token from other project and did
    ansible-inventory -vvv -i app/appname2/prod/prod-hcloud.yml --list
    surely it doesn't show servers since there is no server with such labels, but it didn't error at least
ISSUE TYPE
  • Bug Report
COMPONENT NAME

hcloud used for ansible dynamic inventory

ANSIBLE VERSION
ansible 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
CONFIGURATION
DEFAULT_GATHERING(env: ANSIBLE_GATHERING) = smart
HOST_KEY_CHECKING(env: ANSIBLE_HOST_KEY_CHECKING) = False
OS / ENVIRONMENT

Ubuntu 20.04.1 LTS (Focal Fossa)

STEPS TO REPRODUCE
export HCLOUD_TOKEN=token_with_rw_generated_in_project_console
ansible-inventory -i app/appname/dev/dev-hcloud.yml --list

**dev-hcloud.yml**
plugin: hcloud
label_selector: "environment=dev, app=appname, tag=tag1"
groups:
  sync: labels["environment"]=="dev" and labels["app"]=="appname" and labels["tag"]=="tag1"
At least shows that there is no such servers without errors

ansible-inventory -i app/appname/prod/prod-hcloud.yml --list

**prod-hcloud.yml**
plugin: hcloud
label_selector: "environment=prod, app=appname, tag=tag2"
groups:
  sync: labels["environment"]=="prod" and labels["app"]=="appname" and labels["tag"]=="tag2"

Shows output:
[WARNING]: * Failed to parse app/appname/prod/prod-hcloud.yml with auto plugin: 'NoneType' object has no attribute 'name'
[WARNING]: * Failed to parse app/appname/prod/prod-hcloud.yml with yaml plugin: Plugin configuration YAML file, not YAML inventory
[WARNING]: * Failed to parse app/appname/prod/prod-hcloud.yml with ini plugin: Invalid host pattern 'plugin:' supplied, ending in ':' is not allowed, this character is
reserved to provide a port.
[WARNING]: Unable to parse app/appname/prod/prod-hcloud.yml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available

Token hasn't been changed while execution of both commands

2 other projects has mirrored configuration where i change app labels

EXPECTED RESULTS
ACTUAL RESULTS

Firewall: Creation of "out" rules not possible

SUMMARY

When you try to create a firewall with "out" rules you end up with an error message. This is (as far as I can tell) due to the way destination_ips and source_ips are handled in hcloud_firewall.py

    @staticmethod
    def define_module():
        return AnsibleModule(
            argument_spec=dict(
                id={"type": "int"},
                name={"type": "str"},
                rules=dict(
                    type="list",
                    elements="dict",
                    options=dict(
                        direction={"type": "str", "choices": ["in", "out"]},
                        protocol={"type": "str", "choices": ["icmp", "udp", "tcp"]},
                        port={"type": "str"},
                        source_ips={"type": "list", "elements": "str"},
                        destination_ips={"type": "list", "elements": "str", "default": []},
                    ),
                    required_together=[["direction", "port", "protocol", "source_ips"]]
                ),
                labels={"type": "dict"},
                state={
                    "choices": ["absent", "present"],
                    "default": "present",
                },
                **Hcloud.base_module_arguments()
            ),
            required_one_of=[['id', 'name']],
            required_if=[['state', 'present', ['name']]],
            supports_check_mode=True,
        )

While for destination_ips a default is given, this is not true for source_ips. When a rule with just destination_ips is created, the process fails because source_ips as no value.

If a default value is also given for source_ips then the required-together line is most likely less effective as at least source_ips will always have a value.

Removing the default values and changing the required part to

                    required_together=[["direction", "port", "protocol"]],
                    required_if=[['direction', 'out', ['destination_ips']], ['direction', 'in', ['source_ips']]]

did work to some extend for me, however then the process stops at another place when one of the other is empty (see _prepare_result_rule(self, rule) and _create_firewall(self)

Unfortunately, my Python skill are not good enough to provide a good fix and PR...

ISSUE TYPE
  • Bug Report
COMPONENT NAME

hcloud_firewall.py

Update Firewall on existing server results in AttibuteError

SUMMARY

When updating the firewall config of an existing server, the ansible hcloud_server role runs into an AttributeError.
Applying an firewall to a newly created server also has no effect.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

hetzner.hcloud.hcloud_server

ANSIBLE VERSION
ansible [core 2.11.2] 
  config file = /home/breidi/coding/ansible-provisioning/ansible.cfg
  configured module search path = ['/home/breidi/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/dist-packages/ansible
  ansible collection location = /home/breidi/.ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 2.11.3
  libyaml = True

COLLECTION VERSION
hetzner.hcloud 1.4.3
CONFIGURATION
COLLECTIONS_PATHS(ansible.cfg) = ['~/.ansible/collections']
COLLECTIONS_SCAN_SYS_PATH(ansible.cfg) = False
HOST_KEY_CHECKING(ansible.cfg) = False
INTERPRETER_PYTHON(ansible.cfg) = auto
OS / ENVIRONMENT

Debian Sid
Linux 5.10.0-8-amd64 #1 SMP Debian 5.10.46-1 (2021-06-24) x86_64 GNU/Linux

STEPS TO REPRODUCE
  • create firewall-1 (empty)
  • create firewall-2 (with some rules)
  • create VM with firewall-1 applied
  • apply firewall-2 on created VM
  tasks:
    - name: Create firewall-1
      hetzner.hcloud.hcloud_firewall:
        name:   "fw-1"
        state: present
      register: fw_1_result

    - name: Create firewall-2
      hetzner.hcloud.hcloud_firewall:
        name:   "fw-2"
        state: present
        rules:
          - direction: in
            protocol: tcp
            port: "22"
            source_ips:
              - 0.0.0.0/0
      register: fw_2_result

    - name: Create servers
      hetzner.hcloud.hcloud_server:
        name:   "srv-1"
        server_type: "cx11"
        image: "debian-10"
        firewalls:
          - "{{ fw_1_result.hcloud_firewall.id }}"

    - name: Apply fw-2
      hetzner.hcloud.hcloud_server:
        name:   "srv-1"
        state: present
        firewalls:
          -  "{{ fw_2_result.hcloud_firewall.id }}"
EXPECTED RESULTS

Applying/changing a firewall works.

ACTUAL RESULTS

Initial firewall is not applied to the created server. Applying a firewall results in an error.

Traceback (most recent call last):
  File "/tmp/ansible_hetzner.hcloud.hcloud_server_payload_irhqjgji/ansible_hetzner.hcloud.hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 480, in _update_server
  File "/usr/local/lib/python3.9/dist-packages/hcloud/firewalls/client.py", line 341, in apply_to_resources
    url="/firewalls/{firewall_id}/actions/apply_to_resources".format(firewall_id=firewall.id),
AttributeError: 'NoneType' object has no attribute 'id'

Floating IP Idempotency

Floating IP Idempotency

The floating ip module is not idempotent, when you rerun the task on the same server it will show up as changed.

Example:

- name: Create floating ip
  hetzner.hcloud.hcloud_floating_ip:
      api_token: "{{ hcloud_token }}"
      name: test-ip
      server: test-server
      force: true
      type: ipv4
      state: present

PR otw

hcloud_load_balancer_info missing

hcloud_load_balancer_info is missing.

currently there is no way to get information about your loadbalancer in the ansible module.

Use vault variable for hcloud token in plugin configuration

SUMMARY

I would like to keep my hcloud token in ansible vault so it is encrypted.
I would like to use the token to configure hcloud ansible plugin for dynamic inventory.

This does not work currently.

Is there any way to have this working so I can have all secrets for the project in a single place?

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

hetzner.hcloud.hcloud

ADDITIONAL INFORMATION

I've installed

- name: hetzner.hcloud
    version: 1.2.1

An my configuration is:

plugin: hetzner.hcloud.hcloud
token: "{{ vault_hcloud_token }}"
keyed_groups:
  - key: location
    prefix: hcloud_location
  - key: image_os_flavor
    separator: ""
  - key: status
    prefix: server_status

I think this is related/alternative to my issue #48 .

I did found this which is not encouraging:

https://stackoverflow.com/questions/63166542/use-variable-in-ansible-inventory-aws-plugin
"
group_vars and inventory files are not evaluated by jinja2, so you cannot use mustache expressions in them like that; if you have a dynamic inventory you can do anything that your programming language allows you to do โ€“ mdaniel Jul 30 '20 at 16:02
"

Add note that backups cannot be set in same task with server creation

SUMMARY

When creating a server with backups: yes, backups will not be enabled. This is correct (working as expected), but it is nowhere documented. A little note or hint should be added about this to avoid confusion.

ISSUE TYPE
  • Documentation Report
COMPONENT NAME

hcloud_server.py

ANSIBLE VERSION
ansible 2.9.9
  config file = /home/toms/.ansible.cfg
  configured module search path = ['/home/toms/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.3 (default, May 17 2020, 18:15:42) [GCC 10.1.0]

usage of hcloud_rdns results in warning and error

SUMMARY

using hetzner.hcloud.hcloud_server.hcloud_rdns results first in a warning

[WARNING]: Collection ansible.netcommon does not support Ansible version 2.11.2

and second, in an error.

AttributeError: 'NoneType' object has no attribute 'public_net'

Full traceback is below.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

hcloud_rdns

ANSIBLE VERSION
$ ansible --version
ansible [core 2.11.2] 
  config file = /home/m/git/osuv/ansible.cfg
  configured module search path = ['/home/m/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/m/.local/lib/python3.9/site-packages/ansible
  ansible collection location = /home/m/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/m/.local/bin/ansible
  python version = 3.9.6 (default, Jun 30 2021, 10:22:16) [GCC 11.1.0]
  jinja version = 3.0.1
  libyaml = True
COLLECTION VERSION
$ ansible-galaxy collection list

# /home/m/.local/lib/python3.9/site-packages/ansible_collections
Collection                    Version
----------------------------- -------
amazon.aws                    1.5.0  
ansible.netcommon             2.2.0  
ansible.posix                 1.2.0  
ansible.utils                 2.3.0  
ansible.windows               1.7.0  
arista.eos                    2.2.0  
awx.awx                       19.2.2 
azure.azcollection            1.7.0  
check_point.mgmt              2.0.0  
chocolatey.chocolatey         1.1.0  
cisco.aci                     2.0.0  
cisco.asa                     2.0.2  
cisco.intersight              1.0.15 
cisco.ios                     2.3.0  
cisco.iosxr                   2.3.0  
cisco.meraki                  2.4.2  
cisco.mso                     1.2.0  
cisco.nso                     1.0.3  
cisco.nxos                    2.4.0  
cisco.ucs                     1.6.0  
cloudscale_ch.cloud           2.2.0  
community.aws                 1.5.0  
community.azure               1.0.0  
community.crypto              1.7.1  
community.digitalocean        1.7.0  
community.docker              1.8.0  
community.fortios             1.0.0  
community.general             3.3.0  
community.google              1.0.0  
community.grafana             1.2.1  
community.hashi_vault         1.3.0  
community.hrobot              1.1.1  
community.kubernetes          1.2.1  
community.kubevirt            1.0.0  
community.libvirt             1.0.1  
community.mongodb             1.2.1  
community.mysql               2.1.0  
community.network             3.0.0  
community.okd                 1.1.2  
community.postgresql          1.3.0  
community.proxysql            1.0.0  
community.rabbitmq            1.0.3  
community.routeros            1.2.0  
community.skydive             1.0.0  
community.sops                1.1.0  
community.vmware              1.11.0 
community.windows             1.5.0  
community.zabbix              1.3.0  
containers.podman             1.6.1  
cyberark.conjur               1.1.0  
cyberark.pas                  1.0.7  
dellemc.enterprise_sonic      1.1.0  
dellemc.openmanage            3.5.0  
dellemc.os10                  1.1.1  
dellemc.os6                   1.0.7  
dellemc.os9                   1.0.4  
f5networks.f5_modules         1.10.1 
fortinet.fortimanager         2.1.2  
fortinet.fortios              2.1.1  
frr.frr                       1.0.3  
gluster.gluster               1.0.1  
google.cloud                  1.0.2  
hetzner.hcloud                1.4.3  
hpe.nimble                    1.1.3  
ibm.qradar                    1.0.3  
infinidat.infinibox           1.2.4  
inspur.sm                     1.2.0  
junipernetworks.junos         2.3.0  
kubernetes.core               1.2.1  
mellanox.onyx                 1.0.0  
netapp.aws                    21.2.0 
netapp.azure                  21.7.0 
netapp.cloudmanager           21.7.0 
netapp.elementsw              21.6.1 
netapp.ontap                  21.7.0 
netapp.um_info                21.6.0 
netapp_eseries.santricity     1.2.13 
netbox.netbox                 3.1.1  
ngine_io.cloudstack           2.1.0  
ngine_io.exoscale             1.0.0  
ngine_io.vultr                1.1.0  
openstack.cloud               1.5.0  
openvswitch.openvswitch       2.0.0  
ovirt.ovirt                   1.5.3  
purestorage.flasharray        1.8.0  
purestorage.flashblade        1.6.0  
sensu.sensu_go                1.11.1 
servicenow.servicenow         1.0.6  
splunk.es                     1.0.2  
t_systems_mms.icinga_director 1.18.0 
theforeman.foreman            2.1.1  
vyos.vyos                     2.3.1  
wti.remote                    1.0.1  

# /home/m/.ansible/collections/ansible_collections
Collection           Version 
-------------------- --------
amazon.aws           1.5.0   
ansible.netcommon    1.5.0   
community.aws        1.5.0   
community.crypto     1.6.1   
community.dns        2.0.0-a1
community.docker     1.4.0   
community.general    3.0.0   
community.libvirt    1.0.1   
community.proxysql   1.0.1   
devsec.hardening     7.5.0   
google.cloud         1.0.1   
hetzner.hcloud       1.4.4   
lekker.aws           0.0.3   
markuman.hetzner_dns 1.6.1   
markuman.nessus      0.0.4   
markuman.nextcloud   7.0.0   
CONFIGURATION
$ ansible-config dump --only-changed
INTERPRETER_PYTHON(/home/m/git/osuv/ansible.cfg) = /usr/bin/python3
OS / ENVIRONMENT

Linux 5.11.22

STEPS TO REPRODUCE
---
- name: infra
  hosts: localhost
  connection: local
  tags:
    - infra

  tasks:
    - name: Create a firewall 
      hetzner.hcloud.hcloud_firewall:
        name: home
        rules:
          - direction: in
            protocol: icmp
            source_ips:
              - 0.0.0.0/0
              - ::/0
          - direction: in
            protocol: tcp
            source_ips:
              - 0.0.0.0/0
              - ::/0
            port: "80"
          - direction: in
            protocol: tcp
            source_ips:
              - 0.0.0.0/0
              - ::/0
            port: "443"
          - direction: in
            protocol: tcp
            source_ips:
              - 0.0.0.0/0
              - ::/0
            port: "22"
          - direction: in
            protocol: tcp
            source_ips:
              - 0.0.0.0/0
              - ::/0
            port: "61800"
        state: present

    - name: create home.osuv.de
      hetzner.hcloud.hcloud_server:
        name: home.osuv.de
        server_type: cx41
        image: ubuntu-20.04
        location: fsn1
        ssh_keys:
          - m@rocket
        state: present
        rebuild_protection: yes
        delete_protection: yes
        backups: yes
        firewalls:
          - home
      register: HOME

    - name: Create a reverse DNS entry for a server
      hetzner.hcloud.hcloud_server.hcloud_rdns:
        server: home
        ip_address: "{{ HOME.hcloud_server.ipv4_address }}"
        dns_ptr: home.osuv.de
        state: present
EXPECTED RESULTS

rdns value is set without errors

ACTUAL RESULTS
The full traceback is:
Traceback (most recent call last):
  File "/home/m/.ansible/tmp/ansible-tmp-1626895780.912214-1142532-234375814091018/AnsiballZ_hcloud_rdns.py", line 100, in <module>
    _ansiballz_main()
  File "/home/m/.ansible/tmp/ansible-tmp-1626895780.912214-1142532-234375814091018/AnsiballZ_hcloud_rdns.py", line 92, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/m/.ansible/tmp/ansible-tmp-1626895780.912214-1142532-234375814091018/AnsiballZ_hcloud_rdns.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.hetzner.hcloud.plugins.modules.hcloud_rdns', init_globals=dict(_module_fqn='ansible_collections.hetzner.hcloud.plugins.modules.hcloud_rdns', _modlib_path=modlib_path),
  File "/usr/lib/python3.9/runpy.py", line 210, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_hetzner.hcloud.hcloud_server.hcloud_rdns_payload_n46crppb/ansible_hetzner.hcloud.hcloud_server.hcloud_rdns_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_rdns.py", line 280, in <module>
  File "/tmp/ansible_hetzner.hcloud.hcloud_server.hcloud_rdns_payload_n46crppb/ansible_hetzner.hcloud.hcloud_server.hcloud_rdns_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_rdns.py", line 274, in main
  File "/tmp/ansible_hetzner.hcloud.hcloud_server.hcloud_rdns_payload_n46crppb/ansible_hetzner.hcloud.hcloud_server.hcloud_rdns_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_rdns.py", line 228, in present_rdns
  File "/tmp/ansible_hetzner.hcloud.hcloud_server.hcloud_rdns_payload_n46crppb/ansible_hetzner.hcloud.hcloud_server.hcloud_rdns_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_rdns.py", line 157, in _get_rdns
AttributeError: 'NoneType' object has no attribute 'public_net'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/m/.ansible/tmp/ansible-tmp-1626895780.912214-1142532-234375814091018/AnsiballZ_hcloud_rdns.py\", line 100, in <module>\n    _ansiballz_main()\n  File \"/home/m/.ansible/tmp/ansible-tmp-1626895780.912214-1142532-234375814091018/AnsiballZ_hcloud_rdns.py\", line 92, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/m/.ansible/tmp/ansible-tmp-1626895780.912214-1142532-234375814091018/AnsiballZ_hcloud_rdns.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.hetzner.hcloud.plugins.modules.hcloud_rdns', init_globals=dict(_module_fqn='ansible_collections.hetzner.hcloud.plugins.modules.hcloud_rdns', _modlib_path=modlib_path),\n  File \"/usr/lib/python3.9/runpy.py\", line 210, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.9/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.9/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_hetzner.hcloud.hcloud_server.hcloud_rdns_payload_n46crppb/ansible_hetzner.hcloud.hcloud_server.hcloud_rdns_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_rdns.py\", line 280, in <module>\n  File \"/tmp/ansible_hetzner.hcloud.hcloud_server.hcloud_rdns_payload_n46crppb/ansible_hetzner.hcloud.hcloud_server.hcloud_rdns_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_rdns.py\", line 274, in main\n  File \"/tmp/ansible_hetzner.hcloud.hcloud_server.hcloud_rdns_payload_n46crppb/ansible_hetzner.hcloud.hcloud_server.hcloud_rdns_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_rdns.py\", line 228, in present_rdns\n  File \"/tmp/ansible_hetzner.hcloud.hcloud_server.hcloud_rdns_payload_n46crppb/ansible_hetzner.hcloud.hcloud_server.hcloud_rdns_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_rdns.py\", line 157, in _get_rdns\nAttributeError: 'NoneType' object has no attribute 'public_net'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

AttributeError: 'Server' object has no attribute 'placement_group'

SUMMARY

After upgrading the collection dependencies of my project, i was trying to deploy/upgrading via Ansible and ran into this issue

ISSUE TYPE
  • Bug Report
COMPONENT NAME

hcloud_server

ANSIBLE VERSION
ansible 2.10.5
  config file = /home/xxx/projects/yyy/ansible.cfg
  configured module search path = ['/home/xxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/xxx/.local/lib/python3.9/site-packages/ansible
  executable location = /home/xxx/.local/bin/ansible
  python version = 3.9.6 (default, Jul  6 2021, 18:29:50) [GCC 10.2.1 20201203]
COLLECTION VERSION
# /usr/lib/python3.9/site-packages/ansible_collections
Collection     Version
-------------- -------
hetzner.hcloud 1.2.0

# /home/xxx/.ansible/collections/ansible_collections
Collection     Version
-------------- -------
hetzner.hcloud 1.6.0

# /home/xxx/.local/lib/python3.9/site-packages/ansible_collections
Collection     Version
-------------- -------
hetzner.hcloud 1.2.1
CONFIGURATION
ANSIBLE_PIPELINING(/home/xxx/projects/yyy/ansible.cfg) = True
DEFAULT_REMOTE_USER(/home/xxx/projects/yyy/ansible.cfg) = root
INTERPRETER_PYTHON(/home/xxx/projects/yyy/ansible.cfg) = /usr/bin/python3
OS / ENVIRONMENT
STEPS TO REPRODUCE

Executing of the following yaml code

- name: Ensure yyy exists on Hetzner
  gather_facts: false
  connection: local
  hosts: localhost
  tasks:
    - name: Ensure yyy server is created
      hcloud_server:
        name: "{{ server_name }}"
        server_type: cx21
        image: ubuntu-20.04
        user_data: "#include https://get.docker.com"
        location: fsn1
        ssh_keys:
          - "zzz"
        labels:
          yyy: ""
          environment: "{{ env }}"
        state: started
        api_token: "{{ lookup('env','HCLOUD_TOKEN') }}"
      register: _create_server
EXPECTED RESULTS

In my case, i was was doing a upgrade, so the server should already be there and the module should return ok

ACTUAL RESULTS
TASK [Ensure yyy server is created] ****************************************************************************************************************************************************************************
task path: /home/xxx/projects/yyy/yyy.yml:7
redirecting (type: modules) ansible.builtin.hcloud_server to hetzner.hcloud.hcloud_server
Using module file /home/xxx/.ansible/collections/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py
Pipelining is enabled.
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: xxx
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_hcloud_server_payload_9uwj92gp/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 538, in _update_server
  File "/usr/lib/python3.9/site-packages/hcloud/core/client.py", line 103, in __getattr__
    value = getattr(self.data_model, name)
AttributeError: 'Server' object has no attribute 'placement_group'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 102, in <module>
  File "<stdin>", line 94, in _ansiballz_main
  File "<stdin>", line 40, in invoke_module
  File "/usr/lib/python3.9/runpy.py", line 210, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_hcloud_server_payload_9uwj92gp/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 739, in <module>
  File "/tmp/ansible_hcloud_server_payload_9uwj92gp/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 722, in main
  File "/tmp/ansible_hcloud_server_payload_9uwj92gp/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 662, in present_server
  File "/tmp/ansible_hcloud_server_payload_9uwj92gp/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 589, in _update_server
AttributeError: 'AttributeError' object has no attribute 'message'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_hcloud_server_payload_9uwj92gp/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 538, in _update_server\n  File \"/usr/lib/python3.9/site-packages/hcloud/core/client.py\", line 103, in __getattr__\n    value = getattr(self.data_model, name)\nAttributeError: 'Server' object has no attribute 'placement_group'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"<stdin>\", line 102, in <module>\n  File \"<stdin>\", line 94, in _ansiballz_main\n  File \"<stdin>\", line 40, in invoke_module\n  File \"/usr/lib/python3.9/runpy.py\", line 210, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.9/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.9/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_hcloud_server_payload_9uwj92gp/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 739, in <module>\n  File \"/tmp/ansible_hcloud_server_payload_9uwj92gp/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 722, in main\n  File \"/tmp/ansible_hcloud_server_payload_9uwj92gp/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 662, in present_server\n  File \"/tmp/ansible_hcloud_server_payload_9uwj92gp/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 589, in _update_server\nAttributeError: 'AttributeError' object has no attribute 'message'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

hcloud_volume does not delete volumes

SUMMARY

Volumes are not deleted when destroying servers.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

hcloud_volume

ANSIBLE VERSION
ansible 2.10.4
  config file = None
  configured module search path = ['.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = molecule-hetznercloud/.venv/lib/python3.9/site-packages/ansible
  executable location = molecule-hetznercloud/.venv/bin/ansible
  python version = 3.9.0 (default, Dec 11 2020, 22:49:05) [GCC 8.3.0]
CONFIGURATION
...empty...
OS / ENVIRONMENT

GNU/Linux Debian Buster

STEPS TO REPRODUCE
# create.yml
    - name: Create volume(s)
      hcloud_volume:
        name: "{{ item.1.name | default(item.0.name) }}"
        server: "{{ item.0.name }}"
        location: "{{ item.1.location | default(omit) }}"
        size: "{{ item.1.size | default(10) }}"
        api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
        state: "present"
      loop: "{{ molecule_yml.platforms|subelements('volumes', skip_missing=True)}}"
      register: volumes
      async: 7200
      poll: 0

    - name: Wait for volume(s) creation to complete
      async_status:
        jid: "{{ item.ansible_job_id }}"
      register: hetzner_volumes
      until: hetzner_volumes.finished
      retries: 300
      when:
        - volumes is defined
        - volumes.changed
      with_items: "{{ volumes.results }}"
# destroy.yml
    - name: Destroy volume(s)
      hcloud_volume:
        name: "{{ item.volumes.name | default(item.instance) }}"
        server: "{{ item.instance }}"
        api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
        state: absent
      register: volumes
      with_items: "{{ instance_conf }}"
      async: 7200
      poll: 0

    - name: Wait for volume(s) deletion to complete
      async_status:
        jid: "{{ item.ansible_job_id }}"
      register: hetzner_volumes
      until: hetzner_volumes.finished
      retries: 300
      when: volumes.changed
      with_items: "{{ volumes.results }}"

See more in https://github.com/ansible-community/molecule-hetznercloud.

EXPECTED RESULTS

Volumes are taken out of attachment and then deleted.

ACTUAL RESULTS

Volumes are detached but not deleted.

Release to Galaxy?

Hi,
Do you know what's left before we can get
A) a pre-release to Galaxy
B) a final release for Ansible 2.10?

If it's useful, I can add a Zuul-CI job which will do the build and publish to Galaxy

Broken Python 2.7 support

SUMMARY

Introduced super() calls in #41 breaks python 2.7 compatibility... I know python 2.7 is EOL but for CentOS 7 you are still have to use python 2.7 as it is the system default and OS level dependency for e.g. yum.

The main issue is that zero-argument super() calls were introduced in python 3. To fix it, we just need to add super(InventoryModule, self) as this is compatible for python2/3.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

inventory/hcloud.py

Support lookup() plugins for token retrieval

SUMMARY

It would be great if this inventory plugin supports lookup() plugins for retrieving the token when specified as follows:

plugin: hcloud
token: "{{ lookup('keepass', 'Hetzner API Token', 'password') }}"
ISSUE TYPE
  • Feature Idea
COMPONENT NAME

hcloud inventory_plugin

ADDITIONAL INFORMATION

The lookup provider doesn't care. It's just an example.

What needs to be implemented is that the token value is parsed with the Ansible template engine at https://github.com/ansible-collections/hetzner.hcloud/blob/master/plugins/inventory/hcloud.py#L114

hcloud_ssh_key: traceback similar key exists

SUMMARY

adding the same with different name results in a traceback

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: hcloud.hcloud.APIException: SSH key with the same fingerprint already exists
fatal: [mx1.ngine.ch]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 102, in <module>\n  File \"<stdin>\", line 94, in _ansiballz_main\n  File \"<stdin>\", line 40, in invoke_module\n  File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_hcloud_ssh_key_payload_fy3dr4cf/ansible_hcloud_ssh_key_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_ssh_key.py\", line 245, in <module>\n  File \"/tmp/ansible_hcloud_ssh_key_payload_fy3dr4cf/ansible_hcloud_ssh_key_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_ssh_key.py\", line 239, in main\n  File \"/tmp/ansible_hcloud_ssh_key_payload_fy3dr4cf/ansible_hcloud_ssh_key_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_ssh_key.py\", line 198, in present_ssh_key\n  File \"/tmp/ansible_hcloud_ssh_key_payload_fy3dr4cf/ansible_hcloud_ssh_key_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_ssh_key.py\", line 173, in _create_ssh_key\n  File \"/home/resmo/Projects/ngine/ansible-env-ngine/.venv/lib/python3.8/site-packages/hcloud/ssh_keys/client.py\", line 135, in create\n    response = self._client.request(url=\"/ssh_keys\", method=\"POST\", json=data)\n  File \"/home/resmo/Projects/ngine/ansible-env-ngine/.venv/lib/python3.8/site-packages/hcloud/hcloud.py\", line 212, in request\n    self._raise_exception_from_json_content(json_content)\n  File \"/home/resmo/Projects/ngine/ansible-env-ngine/.venv/lib/python3.8/site-packages/hcloud/hcloud.py\", line 173, in _raise_exception_from_json_content\n    raise APIException(\nhcloud.hcloud.APIException: SSH key with the same fingerprint already exists\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
ISSUE TYPE
  • Bug Report
COMPONENT NAME

hcloud_ssh_key

ANSIBLE VERSION
3.0.0
CONFIGURATION

OS / ENVIRONMENT
STEPS TO REPRODUCE

add the same key with different name

EXPECTED RESULTS

proper error message

ACTUAL RESULTS

traceback


Network parameter in dynamic inventory

SUMMARY

I can't set network parameter in dynamic inventory as Ansible variable or lookup.
Both network and token parameters are string, token works as lookup, but network doesn't.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

dynamic inventory

ANSIBLE VERSION
ansible [core 2.11.3]
  config file = /Users/user/.ansible.cfg
  configured module search path = ['/Users/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/Cellar/ansible/4.4.0/libexec/lib/python3.9/site-packages/ansible
  ansible collection location = /Users/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.9.6 (default, Jun 28 2021, 19:24:41) [Clang 12.0.5 (clang-1205.0.22.9)]
  jinja version = 3.0.1
  libyaml = True
COLLECTION VERSION
# /Users/user/.ansible/collections/ansible_collections
Collection     Version
-------------- -------
hetzner.hcloud 1.6.0
CONFIGURATION
no changes
OS / ENVIRONMENT

20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:27 PDT 2021; root:xnu-7195.141.2~5/RELEASE_ARM64_T8101 arm64

STEPS TO REPRODUCE

Here we can see there are 2 keys in credentials secret:

vault kv get -address=https://vault.example.com datacenters/hcloud/credentials
========= Data =========
Key               Value
---               -----
hcloud_network    1193455
hcloud_token      TOKEN_DATA

So we can use those values in dynamic inventory's lookups:

token: "{{ lookup('community.hashi_vault.hashi_vault', 'datacenters/data/hcloud/credentials:hcloud_token url=https://vault.example.com') }}"
network: "{{ lookup('community.hashi_vault.hashi_vault', 'datacenters/data/hcloud/credentials:hcloud_network url=https://vault.example.com') }}"

However, we got an error:

ansible-inventory -i inventories/hcloud --list
...
auto plugin: The given network is not found.

When we replace network with a fixed value (doesn't matter, network numeric ID or network name) and leave token as lookup - it works:

token: "{{ lookup('community.hashi_vault.hashi_vault', 'datacenters/data/hcloud/credentials:hcloud_token url=https://vault.example.com') }}"
network: 1193455

Also, I tried to define network parameter as Ansible variable or 'vars' lookup, the same error: The given network is not found

# network: "{{lookup('vars', 'hcloud_network')}}"
# network: "{{ hcloud_network }}"

ansible-inventory -i inventories/hcloud -e "hcloud_network=k8s-poc" --list
...
auto plugin: The given network is not found.

Inclusion of hetzner.hcloud in Ansible 2.10

This collection will be included in Ansible 2.10 because it contains modules and/or plugins that were included in Ansible 2.9. Please review:

DEADLINE: 2020-08-18

The latest version of the collection available on August 18 will be included in Ansible 2.10.0, except possibly newer versions which differ only in the patch level. (For details, see the roadmap). Please release version 1.0.0 of your collection by this date! If 1.0.0 does not exist, the same 0.x.y version will be used in all of Ansible 2.10 without updates, and your 1.x.y release will not be included until Ansible 2.11 (unless you request an exception at a community working group meeting and go through a demanding manual process to vouch for backwards compatibility . . . you want to avoid this!).

Follow semantic versioning rules

Your collection versioning must follow all semver rules. This means:

  • Patch level releases can only contain bugfixes;
  • Minor releases can contain new features, new modules and plugins, and bugfixes, but must not break backwards compatibility;
  • Major releases can break backwards compatibility.

Changelogs and Porting Guide

Your collection should provide data for the Ansible 2.10 changelog and porting guide. The changelog and porting guide are automatically generated from ansible-base, and from the changelogs of the included collections. All changes from the breaking_changes, major_changes, removed_features and deprecated_features sections will appear in both the changelog and the porting guide. You have two options for providing changelog fragments to include:

  1. If possible, use the antsibull-changelog tool, which uses the same changelog fragment as the ansible/ansible repository (see the documentation).
  2. If you cannot use antsibull-changelog, you can provide the changelog in a machine-readable format as changelogs/changelog.yaml inside your collection (see the documentation of changelogs/changelog.yaml format).

If you cannot contribute to the integrated Ansible changelog using one of these methods, please provide a link to your collection's changelog by creating an issue in https://github.com/ansible-community/ansible-build-data/. If you do not provide changelogs/changelog.yml or a link, users will not be able to find out what changed in your collection from the Ansible changelog and porting guide.

Make sure your collection passes the sanity tests

Run ansible-test sanity --docker -v in the collection with the latest ansible-base or stable-2.10 ansible/ansible checkout.

Keep informed

Be sure you're subscribed to:

Questions and Feedback

If you have questions or want to provide feedback, please see the Feedback section in the collection requirements.

(Internal link to keep track of issues: ansible-collections/overview#102)

ERROR! couldn't resolve module/action 'hcloud_firewall'

SUMMARY

Unable to use hcloud_firewall as play fails with

ERROR! couldn't resolve module/action 'hcloud_firewall'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/home/aedu/Workspaces/example.com/infrastructure/hetzner_firewall.yml': line 11, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  pre_tasks:
  - name: Ensure Firewall is setup
    ^ here

Latest collection is installed

# /home/aedu/.ansible/collections/ansible_collections
Collection            Version
--------------------- -------
ansible.netcommon     2.0.1  
ansible.utils         2.0.2  
community.general     2.4.0  
community.hrobot      1.1.1  
geerlingguy.php_roles 1.0.0  
hetzner.hcloud        1.4.1  
ISSUE TYPE
  • Bug Report
COMPONENT NAME

hetzner.hcloud

ANSIBLE VERSION
ansible 2.10.7
  config file = /home/aedu/ansible.cfg
  configured module search path = ['/home/aedu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.9.2 (default, Feb 20 2021, 18:40:11) [GCC 10.2.0]
CONFIGURATION
DEFAULT_HOST_LIST(/home/aedu/ansible.cfg) = ['/home/aedu/inventory.yml']
DEFAULT_REMOTE_USER(/home/aedu/ansible.cfg) = ansible
DEFAULT_ROLES_PATH(/home/aedu/ansible.cfg) = ['/home/aedu/roles']
DEFAULT_TIMEOUT(/home/aedu/ansible.cfg) = 10
DEFAULT_VAULT_PASSWORD_FILE(/home/aedu/ansible.cfg) = /home/aedu/.ssh/mykey
GALAXY_SERVER_LIST(/home/aedu/ansible.cfg) = ['release_galaxy']
RETRY_FILES_SAVE_PATH(/home/aedu/ansible.cfg) = /home/aedu/.ansible-retry
OS / ENVIRONMENT

Linux 5.11.10-1-MANJARO x86_64 GNU/Linux

STEPS TO REPRODUCE

Run ansible-playbook firewall.yml

---
- hosts: localhost
  become: no
  gather_facts: false
  vars:
    hcloud_server_image: "debian-10"
    hcloud_server_type: "cx11"
    hcloud_firewall_name: "firewall-ssh-only"

  pre_tasks:
  - name: Ensure Firewall is setup
    hcloud_firewall:
      api_token: "{{ hcloud_token }}"
      name: "{{ hcloud_firewall_name }}"
      public_key: "{{ item.value }}"
      state: present
      rules:
        - direction: "in"
          port: "22"
          protocol: "tcp"
          source_ips:
            - 0.0.0.0/0
            - ::/0
    delegate_to: localhost
EXPECTED RESULTS

Firewall instance is created

ACTUAL RESULTS
> ansible-playbook hetzner_firewall.yml -vvvv
ansible-playbook 2.10.7
  config file = /home/aedu/Workspaces/example.com/infrastructure/ansible.cfg
  configured module search path = ['/home/aedu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.9.2 (default, Feb 20 2021, 18:40:11) [GCC 10.2.0]
Using /home/aedu/Workspaces/example.com/infrastructure/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /home/aedu/Workspaces/example.com/infrastructure/inventory.yml as it did not pass its verify_file() method
script declined parsing /home/aedu/Workspaces/example.com/infrastructure/inventory.yml as it did not pass its verify_file() method
Parsed /home/aedu/Workspaces/example.com/infrastructure/inventory.yml inventory source with yaml plugin
setting up inventory plugins
host_list declined parsing /home/aedu/Workspaces/example.com/infrastructure/inventory.hcloud.yml as it did not pass its verify_file() method
script declined parsing /home/aedu/Workspaces/example.com/infrastructure/inventory.hcloud.yml as it did not pass its verify_file() method
redirecting (type: inventory) ansible.builtin.hcloud to hetzner.hcloud.hcloud
Loading collection hetzner.hcloud from /home/aedu/.ansible/collections/ansible_collections/hetzner/hcloud
Parsed /home/aedu/Workspaces/example.com/infrastructure/inventory.hcloud.yml inventory source with auto plugin
ERROR! couldn't resolve module/action 'hcloud_firewall'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/home/aedu/Workspaces/example.com/infrastructure/hetzner_firewall.yml': line 11, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  pre_tasks:
  - name: Ensure Firewall is setup
    ^ here

Adding health_check to a load balancer service throws `name 'LoadBalancerServiceHealthCheck' is not defined`

SUMMARY

I have this task to add a service to an existing Load Balancer:

- name: Add Load Balancer service
  hetzner.hcloud.hcloud_load_balancer_service:
    load_balancer: "lb.{{ domain_name }}"
    listen_port: 443
    destination_port: 8080
    protocol: https
    http:
      certificates: ["{{ cert_name }}"]
      redirect_http: yes
    health_check:
      http:
        path: "/health"
        status_codes: ["2??", "3??"]
      protocol: http
      port: 8080
      interval: 15
      timeout: 10
      retries: 3
    state: present

This works fine if I remove the health_check node. I tried several different configurations for the health check, but the error I'm getting is always the same:

NameError: name 'LoadBalancerServiceHealthCheck' is not defined

Now, if I check the corresponding file, it looks like it is indeed defined. Maybe it is some sort of import of definition error?

I'm not very good at reading python code, but I can't seem to spot any error and I've double checked my task configuration in accordance with the docs as well.

That's why I unfortunately can't provide any initial ideas of why and where this fails.

Full error output

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: NameError: name 'LoadBalancerServiceHealthCheck' is not defined
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1616688997.9039645-115-258734497133304/AnsiballZ_hcloud_load_balancer_service.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1616688997.9039645-115-258734497133304/AnsiballZ_hcloud_load_balancer_service.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1616688997.9039645-115-258734497133304/AnsiballZ_hcloud_load_balancer_service.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.hetzner.hcloud.plugins.modules.hcloud_load_balancer_service', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/local/lib/python3.8/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/local/lib/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/local/lib/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_hetzner.hcloud.hcloud_load_balancer_service_payload_33fmge0u/ansible_hetzner.hcloud.hcloud_load_balancer_service_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_load_balancer_service.py\", line 616, in <module>\n  File \"/tmp/ansible_hetzner.hcloud.hcloud_load_balancer_service_payload_33fmge0u/ansible_hetzner.hcloud.hcloud_load_balancer_service_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_load_balancer_service.py\", line 610, in main\n  File \"/tmp/ansible_hetzner.hcloud.hcloud_load_balancer_service_payload_33fmge0u/ansible_hetzner.hcloud.hcloud_load_balancer_service_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_load_balancer_service.py\", line 493, in present_load_balancer_service\n  File \"/tmp/ansible_hetzner.hcloud.hcloud_load_balancer_service_payload_33fmge0u/ansible_hetzner.hcloud.hcloud_load_balancer_service_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_load_balancer_service.py\", line 373, in _create_load_balancer_service\n  File \"/tmp/ansible_hetzner.hcloud.hcloud_load_balancer_service_payload_33fmge0u/ansible_hetzner.hcloud.hcloud_load_balancer_service_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_load_balancer_service.py\", line 417, in __get_service_health_checks\nNameError: name 'LoadBalancerServiceHealthCheck' is not defined\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
ISSUE TYPE
  • Bug Report
COMPONENT NAME

hetzner.hcloud.hcloud_load_balancer_service

ANSIBLE VERSION
ansible 2.9.10
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.8.3 (default, Jun  9 2020, 17:49:41) [GCC 8.3.0]
CONFIGURATION
empty
OS / ENVIRONMENT

Docker image python:3.8-slim

STEPS TO REPRODUCE

Use the task from summary section to reproduce the issue.

EXPECTED RESULTS

Load Balancer receives service with health check configured or existing service is updated with health check config.

ACTUAL RESULTS

See above error description

Inventory load fails with server recreated from snapshot

SUMMARY

Plugin fails to read inventory with vm created from image. Most likely due to the fact that source snapshot was deleted.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

hcloud

ANSIBLE VERSION
ansible 2.9.11
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/.local/lib/python3.8/site-packages/ansible
  executable location = /home/user/.local/bin/ansible
  python version = 3.8.2 (default, Jul 16 2020, 14:00:26) [GCC 9.3.0]
CONFIGURATION

No changes.

OS / ENVIRONMENT

N/A

STEPS TO REPRODUCE
  • Create VM on hetzner cloud
  • Create snapshot of VM
  • Remove VM
  • Recreate VM from snapshot
  • Remove snapshot
EXPECTED RESULTS

Ansible loads inventory.

ACTUAL RESULTS

The image propery is None for that specific server and causes load fail.

[WARNING]:  * Failed to parse /some/path/hcloud.yml with hcloud plugin: 'NoneType' object has no attribute 'name'
  File "/home/user/.local/lib/python3.8/site-packages/ansible/inventory/manager.py", line 280, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/home/user/.local/lib/python3.8/site-packages/ansible/plugins/inventory/hcloud.py", line 205, in parse
    self._set_server_attributes(server)
  File "/home/user/.local/lib/python3.8/site-packages/ansible/plugins/inventory/hcloud.py", line 171, in _set_server_attributes
    self.inventory.set_variable(server.name, "server_type", to_native(server.image.name))

hcloud_server_network alias_ips seems to ignore changes

SUMMARY

When adding an alias_ip to an existing private network connection the task seems to do nothing ('Unchanged').

ISSUE TYPE
  • Bug Report
ANSIBLE VERSION

STEPS TO REPRODUCE

First

- hcloud_server_network:
     network: example
     server: test
     ip: 172.17.0.1
     alias_ips: [172.17.0.2]

then rerun as:

- hcloud_server_network:
     network: example
     server: test
     ip: 172.17.0.1
     alias_ips: [172.17.0.2, 172.17.0.3]
EXPECTED RESULTS

172.17.0.3 set as alias

ACTUAL RESULTS

not set

Remove old facts modules

For the release of v2.0.0 we want to remove the "old" facts modules.

  • hcloud_datacenter_facts
  • hcloud_floating_ip_facts
  • hcloud_image_facts
  • hcloud_location_facts
  • hcloud_server_facts
  • hcloud_server_type_facts
  • hcloud_ssh_key_facts
  • hcloud_volume_facts

Cannot create floating ip

This is the error I receive when I try to create a floating IP.


The error appears to be in '/home/davide/Projects/K8s/ansible/floating_ip.yml': line 9, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  tasks:
    - name: Create a basic IPv4 Floating IP
      ^ here

The playbook looks like:

- name: Create Basic Server
  hosts: localhost
  connection: local
  gather_facts: False
  user: root
  vars:
    hcloud_token: xxxxxxxxxxxxxxxxx
  tasks:
    - name: Create a basic IPv4 Floating IP
      hcloud_floating_ip:
        api_token: "{{ hcloud_token }}"
        name: "my-floating-ip"
        home_location: "fsn1"
        type: ipv4
        state: present
      register: floatingIP 

Any suggestion?

How to use multiple projects?

SUMMARY

How to use the dynamic inventory for multiple projects? The only way seems to be to have multiple inventory files and add the token to every inventory file. But this makes it hard to add these inventory files into e.g. a git repo.

ISSUE TYPE
  • Documentation Report
COMPONENT NAME

inventory/hcloud

Can't group by network

SUMMARY

There's no way to add network names to keyed_groups. This should be possible since it's valid to group by them like any other parameters.

Documentation should include all the possible values that can be set in keyed_groups. Can you tell me what values are possible to group by?

It would be good be able to group by subnet names, which the API doesn't allow. Is there a reason for this? It's good to have named subnets because you would put servers in a subnet based on a common grouping.

hcloud doesn't parse inventory file using ansible 2.10rc2 and python 3.7

SUMMARY

I can't get the plugin to work. I'm probably doing something wrong but for the life of me can't figure out what.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

hetzner.hcloud - inventory

ANSIBLE VERSION
ansible 2.10.0rc2
  config file = /aaa/bbb/ansible-playbooks/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]
CONFIGURATION
ANSIBLE_PIPELINING(/aaa/bbb/ansible-playbooks/ansible.cfg) = True
DEFAULT_STDOUT_CALLBACK(/aaa/bbb/ansible-playbooks/ansible.cfg) = full_skip
DEFAULT_VAULT_PASSWORD_FILE(/aaa/bbb/ansible-playbooks/ansible.cfg) = /aaa/bbb/file
INTERPRETER_PYTHON(/aaa/bbb/ansible-playbooks/ansible.cfg) = auto_silent
INVENTORY_ENABLED(/aaa/bbb/ansible-playbooks/ansible.cfg) = ['hcloud']
OS / ENVIRONMENT

Debian 10, Python 3.7

STEPS TO REPRODUCE

I created a simple file called hzcloud.yml as below

plugin: hcloud
token: REDACTED
EXPECTED RESULTS

Get a list of existing hosts.

ACTUAL RESULTS
ansible-inventory -vvv -i hzcloud.yml --list

ansible-inventory 2.10.0rc2
  config file = /aaa/bbb/ansible-playbooks/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible-inventory
  python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]
Using /aaa/bbb/ansible-playbooks/ansible.cfg as config file
redirecting (type: inventory) ansible.builtin.hcloud to hetzner.hcloud.hcloud
ansible_collections.hetzner.hcloud.plugins.inventory.hcloud declined parsing /aaa/bbb/ansible-playbooks/hzcloud.yml as it did not pass its verify_file() method
[WARNING]: Unable to parse /aaa/bbb/ansible-playbooks/hzcloud.yml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{
    "_meta": {
        "hostvars": {}
    },
    "all": {
        "children": [
            "ungrouped"
        ]
    }
}

Could not resolve module/action hcloud_load_balancer

SUMMARY

I was following this https://docs.ansible.com/ansible/latest/collections/hetzner/hcloud/hcloud_load_balancer_module.html (First example) and I am getting this

ERROR! couldn't resolve module/action 'hcloud_load_balancer'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/home/user/projects/django-project/devops/roles/server-init/tasks/main.yml': line 45, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Create the Load Balancer
  ^ here
ISSUE TYPE
  • Bug Report
COMPONENT NAME

hcloud_load_balancer

ANSIBLE VERSION
ansible 2.10.3
  config file = /home/user/projects/django-project/devops/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/.local/lib/python3.7/site-packages/ansible
  executable location = /home/user/.local/bin/ansible
  python version = 3.7.5 (default, Apr 19 2020, 20:18:17) [GCC 9.2.1 20191008]

I have tried also with hetzner.hcloud.hcloud_load_balancer and hetzner.hcloud_load_balancer with no luck.

OS / ENVIRONMENT

Ubuntu 19.10

STEPS TO REPRODUCE
- name: Create the Load Balancer
  hcloud_load_balancer:
    name: 'lb-test'
    load_balancer_type: lb11
    location: fsn1
    state: present
EXPECTED RESULTS

Load balancer created.

ACTUAL RESULTS
ansible-playbook 2.10.3
  config file = /home/user/projects/django-project/devops/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/.local/lib/python3.7/site-packages/ansible
  executable location = /home/user/.local/bin/ansible-playbook
  python version = 3.7.5 (default, Apr 19 2020, 20:18:17) [GCC 9.2.1 20191008]
Using /home/user/projects/django-project/devops/ansible.cfg as config file
host_list declined parsing /home/user/projects/django-project/devops/hosts as it did not pass its verify_file() method
script declined parsing /home/user/projects/django-project/devops/hosts as it did not pass its verify_file() method
auto declined parsing /home/user/projects/django-project/devops/hosts as it did not pass its verify_file() method
Parsed /home/user/projects/django-project/devops/hosts inventory source with ini plugin
Read vars_file 'vars/main.yml'
Read vars_file 'vars/default.yml'
ERROR! couldn't resolve module/action 'hetzner.hcloud_server_network'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/home/user/projects/django-project/devops/roles/server-init/tasks/main.yml': line 39, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Create the private server network

dns module

SUMMARY

Add a module to use hetzner dns robot to set dns records.

ISSUE TYPE
  • Feature Idea

Composite variables can't access existing host variables in Hetzner inventory plugin

SUMMARY

When I'm trying to set a variable with the compose section of inventory plug-in config, other host variables, provided by the plugin, are undefined/ignored. This also causes an error in strict mode.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Hetzner Cloud inventory plugin

ANSIBLE VERSION
ansible 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/renerick/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.2 (default, Jul 16 2020, 14:00:26) [GCC 9.3.0]
CONFIGURATION
INVENTORY_ENABLED(/etc/ansible/ansible.cfg) = ['host_list', 'hcloud', 'virtualbox', 'yaml', 'constructed']
OS / ENVIRONMENT
            /////////////                @pop-os 
         /////////////////////            --------------- 
      ///////*767////////////////         OS: Pop!_OS 20.04 LTS x86_64 
    //////7676767676*//////////////       
   /////76767//7676767//////////////      Kernel: 5.4.0-7634-generic 
  /////767676///*76767///////////////     Uptime: 1 day, 4 hours, 23 mins 
 ///////767676///76767.///7676*///////    Packages: 2428 (dpkg) 
/////////767676//76767///767676////////   Shell: bash 5.0.17 
//////////76767676767////76767/////////   Resolution: 1920x1080 
///////////76767676//////7676//////////   DE: GNOME 
////////////,7676,///////767///////////   
/////////////*7676///////76////////////   
///////////////7676////////////////////   
 ///////////////7676///767////////////    
  //////////////////////'////////////     Terminal: gnome-terminal 
   //////.7676767676767676767,//////      CPU: Intel i7-8750H (12) @ 4.100GHz 
    /////767676767676767676767/////       GPU: Intel UHD Graphics 630 
      ///////////////////////////         
         /////////////////////            Memory: 5407MiB / 31958MiB 
             /////////////

STEPS TO REPRODUCE
  1. Create an instance on Hetzner cloud. In this case, I added some labels, but this behaviour applies to all other host variables
  2. Set up Hetzner Cloud inventory plugin
  3. Enable strict mode
  4. Add compose section, groups section and keyed groups in the config
...
strict: yes
keyed_groups:
  - key: labels.consul
    prefix: consul
    separator: "_"

groups:
  consul_instances: "labels.consul is string"

compose:
  consul_role: "labels.consul"
  1. Run ansible-inventory --list for created inventory
EXPECTED RESULTS

Hosts are assigned to matching groups and have all composed variables

ACTUAL RESULTS

With strict mode:

ansible-inventory -i inventory/hcloud.yml --list --ask-vault-pass -vvvv
ansible-inventory 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/renerick/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible-inventory
  python version = 3.8.2 (default, Jul 16 2020, 14:00:26) [GCC 9.3.0]
Using /etc/ansible/ansible.cfg as config file
Vault password: 
setting up inventory plugins
host_list declined parsing /home/renerick/Documents/Development/Cloud/ansible/inventory/hcloud.yml as it did not pass its verify_file() method
virtualbox declined parsing /home/renerick/Documents/Development/Cloud/ansible/inventory/hcloud.yml as it did not pass its verify_file() method
[WARNING]:  * Failed to parse /home/renerick/Documents/Development/Cloud/ansible/inventory/hcloud.yml with hcloud plugin: Could not set consul_role for host worker: 'labels' is
undefined
  File "/usr/lib/python3/dist-packages/ansible/inventory/manager.py", line 280, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/usr/lib/python3/dist-packages/ansible/plugins/inventory/hcloud.py", line 211, in parse
    self._set_composite_vars(self.get_option('compose'), {}, server.name, strict=strict)
  File "/usr/lib/python3/dist-packages/ansible/plugins/inventory/__init__.py", line 363, in _set_composite_vars
    raise AnsibleError("Could not set %s for host %s: %s" % (varname, host, to_native(e)))
[WARNING]:  * Failed to parse /home/renerick/Documents/Development/Cloud/ansible/inventory/hcloud.yml with yaml plugin: Plugin configuration YAML file, not YAML inventory
  File "/usr/lib/python3/dist-packages/ansible/inventory/manager.py", line 280, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/usr/lib/python3/dist-packages/ansible/plugins/inventory/yaml.py", line 112, in parse
    raise AnsibleParserError('Plugin configuration YAML file, not YAML inventory')
[WARNING]:  * Failed to parse /home/renerick/Documents/Development/Cloud/ansible/inventory/hcloud.yml with constructed plugin: Incorrect plugin name in file: hcloud
  File "/usr/lib/python3/dist-packages/ansible/inventory/manager.py", line 280, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/usr/lib/python3/dist-packages/ansible/plugins/inventory/constructed.py", line 109, in parse
    self._read_config_data(path)
  File "/usr/lib/python3/dist-packages/ansible/plugins/inventory/__init__.py", line 224, in _read_config_data
    raise AnsibleParserError("Incorrect plugin name in file: %s" % config.get('plugin', 'none found'))
[WARNING]: Unable to parse /home/renerick/Documents/Development/Cloud/ansible/inventory/hcloud.yml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{
    "_meta": {
        "hostvars": {}
    },
    "all": {
        "children": [
            "ungrouped"
        ]
    }
}

Without strict mode:

ansible-inventory -i inventory/hcloud.yml --list --ask-vault-pass -vvvv
ansible-inventory 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/renerick/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible-inventory
  python version = 3.8.2 (default, Jul 16 2020, 14:00:26) [GCC 9.3.0]
Using /etc/ansible/ansible.cfg as config file
Vault password: 
setting up inventory plugins
host_list declined parsing /home/renerick/Documents/Development/Cloud/ansible/inventory/hcloud.yml as it did not pass its verify_file() method
Parsed /home/renerick/Documents/Development/Cloud/ansible/inventory/hcloud.yml inventory source with hcloud plugin
Trying secret <ansible.parsing.vault.PromptVaultSecret object at 0x7fe78bd077f0> for vault_id=default
{
    "_meta": {
        "hostvars": {
            "gateway": {
                "ansible_host": "[REDACTED]",
                "ansible_ssh_common_args": "-o StrictHostKeyChecking=no",
                "ansible_user": "ansible",
                "datacenter": "[REDACTED]",
                "id": "[REDACTED]",
                "image_id": "[REDACTED]",
                "image_name": "debian-10",
                "image_os_flavor": "debian",
                "ipv4": "[REDACTED]",
                "ipv6_network": "[REDACTED]",
                "ipv6_network_mask": "64",
                "labels": {
                    "consul": "client"
                },
                "location": "[REDACTED]",
                "name": "gateway",
                "nomad_node_role": "client",
                "server_type": "debian-10",
                "status": "running",
                "type": "[REDACTED]",
            },
            "worker": {
                "ansible_host": "[REDACTED]",
                "ansible_ssh_common_args": "-o StrictHostKeyChecking=no",
                "ansible_user": "ansible",
                "datacenter": "[REDACTED]",
                "id": "[REDACTED]",
                "image_id": "[REDACTED]",
                "image_name": "debian-10",
                "image_os_flavor": "debian",
                "ipv4": "[REDACTED]",
                "ipv6_network": "[REDACTED]",
                "ipv6_network_mask": "64",
                "labels": {
                    "consul": "server"
                },
                "location": "[REDACTED]",
                "name": "worker",
                "nomad_node_role": "both",
                "server_type": "debian-10",
                "status": "running",
                "type": "[REDACTED]",
            }
        }
    },
    "all": {
        "children": [
            "consul_client",
            "consul_instances",
            "consul_server",
            "hcloud",
            "ungrouped"
        ]
    },
    "consul_client": {
        "hosts": [
            "gateway"
        ]
    },
    "consul_instances": {
        "hosts": [
            "gateway",
            "worker"
        ]
    },
    "consul_server": {
        "hosts": [
            "worker"
        ]
    },
    "hcloud": {
        "hosts": [
            "gateway",
            "worker"
        ]
    },
}

Instances are actually placed in the appropriate keyed groups (consul_client and consul_server) and conditional group (consul_instances). However the value of consul_role variable is nowhere to be seen, althouh all these parameters are based on labels property.

P.S. There is a workaround with keyed groups and group variables, but I feel that it is just a workaround, not a solution. Inventory host variables belong to inventory, not groups

Document installation process.

SUMMARY

I tried to use this collection but unfortunately I got no luck since ansible 2.9 has no support for collections from git, only from galaxy or tarball.
It would be nice if you will either document how to install this collection with ansible-2.9 and made at least one release to galaxy.

I get errors like this:

ERROR! couldn't resolve module/action 'hcloud_floating_ip'. This often indicates a misspelling, missing collection, or incorrect module path.

or this:

fatal: [hostname]: FAILED! => {"msg": "Could not find imported module support code for hcloud_floating_ip.  Looked for either Hcloud.py or hcloud.py
ISSUE TYPE
  • Documentation Report
COMPONENT NAME
ANSIBLE VERSION
ansible 2.9.9
  config file = /home/andor/work/ansible/ansible.cfg
  configured module search path = ['/home/andor/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]

hcloud dynamic inventory broken: 'NoneType' object has no attribute 'name'/hcloud declined parsing

SUMMARY

The Hetzner Cloud dynamic inventory does not function anymore for me: 'NoneType' object has no attribute 'name'/hcloud declined parsing hcloud.yml as it did not pass its verify_file() method

Used to work just fine and broke both within a CI pipeline and locally.

ansible/ansible#69533 sent me here

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Hetzner Cloud (hcloud) dynamic inventory

ANSIBLE VERSION
ansible 2.9.2
  config file = /home/runner/work/kubernetes/kubernetes/ansible/ansible.cfg
  configured module search path = [u'/home/runner/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/runner/.local/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.17 (default, Apr 15 2020, 17:20:14) [GCC 7.5.0]

ansible==2.9.2
hcloud==1.6.3

CONFIGURATION
ANSIBLE_SSH_ARGS(/home/runner/work/kubernetes/kubernetes/ansible/ansible.cfg) = -o ControlMaster=auto -o ControlPersist=60s -o UserKnownHostsFile=/dev/null
ANSIBLE_SSH_RETRIES(/home/runner/work/kubernetes/kubernetes/ansible/ansible.cfg) = 10
DEFAULT_HOST_LIST(/home/runner/work/kubernetes/kubernetes/ansible/ansible.cfg) = [u'/home/runner/work/kubernetes/kubernetes/ansible/hcloud.yml']
HOST_KEY_CHECKING(/home/runner/work/kubernetes/kubernetes/ansible/ansible.cfg) = False
INVENTORY_ENABLED(/home/runner/work/kubernetes/kubernetes/ansible/ansible.cfg) = [u'hcloud']
OS / ENVIRONMENT

Ceased to function both on a hosted ubuntu-latest GitHub Actions workflow and locally on OS X 10.14.6. The HCLOUD_TOKEN environment variable is set and contains a valid API token.

STEPS TO REPRODUCE

hcloud.yml:

plugin: hcloud
groups:
  masters: labels.master is defined
  workers: labels.worker is defined

ansible.cfg:

[defaults]
host_key_checking = False
inventory = hcloud.yml

[ssh_connection]
retries=10
ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o UserKnownHostsFile=/dev/null

[inventory]
enable_plugins = hcloud
EXPECTED RESULTS

Inventory discovers Hetzner Cloud hosts

ACTUAL RESULTS

Inventory does not discover Hetzner Cloud hosts

```yaml
ansible-inventory -vvv -i hcloud.yml --list
  env:
    GITHUB_TOKEN: ***
    DEPLOYMENT_SSH_PRIVATE_KEY_BASE64: ***
    HCLOUD_TOKEN: ***
    ANSIBLE_CONFIG: ansible/ansible.cfg
ansible-inventory 2.9.2
  config file = /home/runner/work/kubernetes/kubernetes/ansible/ansible.cfg
  configured module search path = [u'/home/runner/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/runner/.local/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible-inventory
  python version = 2.7.17 (default, Apr 15 2020, 17:20:14) [GCC 7.5.0]
Using /home/runner/work/kubernetes/kubernetes/ansible/ansible.cfg as config file
Skipping due to inventory source not existing or not being readable by the current user
hcloud declined parsing /home/runner/work/kubernetes/kubernetes/hcloud.yml as it did not pass its verify_file() method
[WARNING]: Unable to parse /home/runner/work/kubernetes/kubernetes/hcloud.yml
as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available

Inventory plugin does not work with full qualified name

SUMMARY

After upgrading to Ansible 4.0.0/ansible-base 2.11.0 the inventory plugin does not work with the full qualified name anymore:

---
plugin: hetzner.hcloud.hcloud
keyed_groups:
  - key: labels.os
    separator: ""

results in

[WARNING]:  * Failed to parse ./inventory/hcloud.yml with auto plugin: Invalid value "hetzner.hcloud.hcloud" for configuration option "plugin_type: inventory plugin:
ansible_collections.hetzner.hcloud.plugins.inventory.hcloud setting: plugin ", valid values are: ['hcloud']

The quick fix is to use plugin: hcloud in the inventory file, but it might be confusing while the Ansible docs recommend using the full qualified name for plugins coming from a collection https://docs.ansible.com/ansible/latest/plugins/inventory.html#using-inventory-plugins. I guess it's related to https://github.com/ansible-collections/hetzner.hcloud/blob/main/plugins/inventory/hcloud.py#L26 and some kind of stricter validation in Ansible 4.0.0

ISSUE TYPE
  • Bug Report
COMPONENT NAME

inventory hcloud

ANSIBLE VERSION
ansible [core 2.11.1] 
  config file = /home/ansibleremote/ansible-dc/ansible.cfg
  configured module search path = ['/home/ansibleremote/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/python38/ansible/lib64/python3.8/site-packages/ansible
  ansible collection location = /home/ansibleremote/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/python38/ansible/bin/ansible
  python version = 3.8.6 (default, Oct 27 2020, 09:13:12) [GCC 9.3.1 20200408 (Red Hat 9.3.1-2)]
  jinja version = 3.0.1
  libyaml = True

delete/rebuild_protection not working on server creation?

SUMMARY

delete_protection and rebuild_protection dont work.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

hcloud_server

ANSIBLE VERSION
ansible 2.10.1
  config file = /home/foo/ansible.cfg
  configured module search path = ['/home/foo/roles/dokku_bot.ansible_dokku/library']
  ansible python module location = /home/foo/.venv/lib/python3.8/site-packages/ansible
  executable location = /home/foo/.venv/bin/ansible
  python version = 3.8.0 (default, Jul 24 2020, 00:09:08) [GCC 6.3.0 20170516]
CONFIGURATION
ANSIBLE_PIPELINING(/home/foo/ansible.cfg) = True
ANSIBLE_SSH_CONTROL_PATH(/home/foo/ansible.cfg) = /tmp/ansible-ssh-%%h-%%p-%%r
DEFAULT_BECOME(/home/foo/ansible.cfg) = True
DEFAULT_BECOME_METHOD(/home/foo/ansible.cfg) = sudo
DEFAULT_HOST_LIST(/home/foo/ansible.cfg) = ['/home/foo/inventories']
DEFAULT_MODULE_PATH(/home/foo/ansible.cfg) = ['/home/foo/roles/dokku_bot.ansible_dokku/library']
DEFAULT_REMOTE_USER(/home/foo/ansible.cfg) = {{ansible_user}}
DEFAULT_ROLES_PATH(/home/foo/ansible.cfg) = ['/home/foo/roles']
DEFAULT_VAULT_PASSWORD_FILE(/home/foo/ansible.cfg) = /home/foo/scripts/vault.sh
RETRY_FILES_ENABLED(/home/foo/ansible.cfg) = False
OS / ENVIRONMENT

GNU/Linux Debian 9

STEPS TO REPRODUCE
- name: Create new hetzner cloud instance
  hcloud_server:
    api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
    image: "{{ new_hetzner_server_image }}"
    name: "{{ new_hetzner_server_name }}"
    server_type: "{{ new_hetzner_server_type }}"
    ssh_keys: "{{ members | map(attribute='email') | list }}"
    labels:
      managed: ansible
    backups: true
    delete_protection: true
    rebuild_protection: true
    state: present
  register: new_instance
  async: 7200
  poll: 0

- name: Wait for instance creation to complete
  async_status:
    jid: "{{ new_instance.ansible_job_id }}"
  register: hetzner_job
  until: hetzner_job.finished
  retries: 300
EXPECTED RESULTS

I have rebuild/delete protection enabled.

ACTUAL RESULTS

I have rebuild/delete protection not enabled.

Would it make sense to document the precise format of `not_valid_after` in `hcloud_certificate_info`?

SUMMARY

The docs state that not_valid_after is ISO-8601 formatted, which I think is true.

Point in time when the Certificate stops being valid (in ISO-8601 format)

It seems to be %Y-%m-%d %H:%M:%S%z (example: 2021-06-15 13:37:08+00:00)?

However, I ran into issues, because I was comparing to ansible_date_time.iso8601, which is something like %Y-%m-%dT%H:%M:%SZ (example: 2021-06-15T13:37:08Z).

Note the T is a space in Hetzner Cloud's API response and the timezone notation is different.

Would it make sense to document an example of the precise date format? Or is that just common knowledge that ISO-8601 can have slightly different representations?

ISSUE TYPE
  • Documentation Report
COMPONENT NAME

hcloud_certificate_info

ANSIBLE VERSION
ansible 2.10.9
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.8.10 (default, May  4 2021, 18:59:47) [GCC 8.3.0]

Error when calling "hcloud_server": TypeError: 'NoneType' object is not callable

SUMMARY

While I run hcloud_server I get an TypeError: 'NoneType' object is not callable even so everything seems set.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

hetzner.hcloud

Versions of collections:

  • community.hrobot:1.1.1
  • community.general:2.4.0
ANSIBLE VERSION
ansible 2.10.7
  config file = /home/aedu/ansible.cfg
  configured module search path = ['/home/aedu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.9.2 (default, Feb 20 2021, 18:40:11) [GCC 10.2.0]
CONFIGURATION
DEFAULT_HOST_LIST(/home/aedu/ansible.cfg) = ['/home/aedu/inventory.yml']
DEFAULT_REMOTE_USER(/home/aedu/ansible.cfg) = ansible
DEFAULT_ROLES_PATH(/home/aedu/ansible.cfg) = ['/home/aedu/roles']
DEFAULT_TIMEOUT(/home/aedu/ansible.cfg) = 10
DEFAULT_VAULT_PASSWORD_FILE(/home/aedu/ansible.cfg) = /home/aedu/.ssh/mykey
GALAXY_SERVER_LIST(/home/aedu/ansible.cfg) = ['release_galaxy']
RETRY_FILES_SAVE_PATH(/home/aedu/ansible.cfg) = /home/aedu/.ansible-retry
OS / ENVIRONMENT

Linux 5.11.10-1-MANJARO x86_64 GNU/Linux

STEPS TO REPRODUCE

Run ansible-playbook demo.yml --ask-become-pass --check -vvvv

- hosts: localhost
  gather_facts: no

  pre_tasks:
  - name: Create a basic server
    hcloud_server:
      api_token: "{{ hcloud_token }}"
      name: demo
      server_type: cx11
      image: debian-10
      state: present
      ssh_keys: 
        - ansible-user
        - aedu-clawfinger
    delegate_to: localhost
    register: result
EXPECTED RESULTS

Server instance is created in Hetzner Cloud

ACTUAL RESULTS
> ansible-playbook demo.yml  --ask-become-pass  -vvvv --check
ansible-playbook 2.10.7
  config file = /home/aedu/Workspaces/wyssmann.com/infrastructure/ansible.cfg
  configured module search path = ['/home/aedu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.9.2 (default, Feb 20 2021, 18:40:11) [GCC 10.2.0]
Using /home/aedu/Workspaces/wyssmann.com/infrastructure/ansible.cfg as config file
BECOME password: 
setting up inventory plugins
host_list declined parsing /home/aedu/Workspaces/wyssmann.com/infrastructure/inventory.yml as it did not pass its verify_file() method
script declined parsing /home/aedu/Workspaces/wyssmann.com/infrastructure/inventory.yml as it did not pass its verify_file() method
Parsed /home/aedu/Workspaces/wyssmann.com/infrastructure/inventory.yml inventory source with yaml plugin
setting up inventory plugins
host_list declined parsing /home/aedu/Workspaces/wyssmann.com/infrastructure/inventory.hcloud.yml as it did not pass its verify_file() method
script declined parsing /home/aedu/Workspaces/wyssmann.com/infrastructure/inventory.hcloud.yml as it did not pass its verify_file() method
redirecting (type: inventory) ansible.builtin.hcloud to hetzner.hcloud.hcloud
Loading collection hetzner.hcloud from /home/aedu/.ansible/collections/ansible_collections/hetzner/hcloud
/home/aedu/.local/lib/python3.9/site-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.25.11) or chardet (4.0.0) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Parsed /home/aedu/Workspaces/wyssmann.com/infrastructure/inventory.hcloud.yml inventory source with auto plugin
redirecting (type: modules) ansible.builtin.hcloud_server to hetzner.hcloud.hcloud_server
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python3.9/site-packages/ansible/plugins/callback/default.py
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: demo.yml **********************************************************************************************************************************************************************************************
Positional arguments: demo.yml
verbosity: 4
remote_user: ansible
connection: smart
timeout: 10
become_method: sudo
become_ask_pass: True
tags: ('all',)
check: True
diff: True
inventory: ('/home/aedu/Workspaces/wyssmann.com/infrastructure/inventory.yml', '/home/aedu/Workspaces/wyssmann.com/infrastructure/inventory.hcloud.yml')
forks: 5
1 plays in demo.yml

PLAY [localhost] ************************************************************************************************************************************************************************************************

TASK [Create a basic server] ************************************************************************************************************************************************************************************
task path: /home/aedu/Workspaces/wyssmann.com/infrastructure/demo.yml:5
Trying secret FileVaultSecret(filename='/home/aedu/.ssh/wyssmann') for vault_id=default
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: aedu
<localhost> EXEC /bin/sh -c 'echo ~aedu && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/aedu/.ansible/tmp `"&& mkdir "` echo /home/aedu/.ansible/tmp/ansible-tmp-1617739488.1029868-1196900-212474867712925 `" && echo ansible-tmp-1617739488.1029868-1196900-212474867712925="` echo /home/aedu/.ansible/tmp/ansible-tmp-1617739488.1029868-1196900-212474867712925 `" ) && sleep 0'
redirecting (type: modules) ansible.builtin.hcloud_server to hetzner.hcloud.hcloud_server
Using module file /home/aedu/.ansible/collections/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py
<localhost> PUT /home/aedu/.ansible/tmp/ansible-local-11967809agsx6h7/tmpy_ffby82 TO /home/aedu/.ansible/tmp/ansible-tmp-1617739488.1029868-1196900-212474867712925/AnsiballZ_hcloud_server.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/aedu/.ansible/tmp/ansible-tmp-1617739488.1029868-1196900-212474867712925/ /home/aedu/.ansible/tmp/ansible-tmp-1617739488.1029868-1196900-212474867712925/AnsiballZ_hcloud_server.py && sleep 0'
<localhost> EXEC /bin/sh -c 'sudo -H -S  -p "[sudo via ansible, key=cihudlxmuqytobocpmmbmtdwjbpfigpx] password:" -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-cihudlxmuqytobocpmmbmtdwjbpfigpx ; /usr/bin/python /home/aedu/.ansible/tmp/ansible-tmp-1617739488.1029868-1196900-212474867712925/AnsiballZ_hcloud_server.py'"'"' && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/aedu/.ansible/tmp/ansible-tmp-1617739488.1029868-1196900-212474867712925/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/home/aedu/.ansible/tmp/ansible-tmp-1617739488.1029868-1196900-212474867712925/AnsiballZ_hcloud_server.py", line 102, in <module>
    _ansiballz_main()
  File "/home/aedu/.ansible/tmp/ansible-tmp-1617739488.1029868-1196900-212474867712925/AnsiballZ_hcloud_server.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/aedu/.ansible/tmp/ansible-tmp-1617739488.1029868-1196900-212474867712925/AnsiballZ_hcloud_server.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.hetzner.hcloud.plugins.modules.hcloud_server', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib/python3.9/runpy.py", line 210, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_hcloud_server_payload_r5b303kq/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 616, in <module>
  File "/tmp/ansible_hcloud_server_payload_r5b303kq/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 597, in main
  File "/tmp/ansible_hcloud_server_payload_r5b303kq/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 540, in present_server
  File "/tmp/ansible_hcloud_server_payload_r5b303kq/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 333, in _create_server
  File "/tmp/ansible_hcloud_server_payload_r5b303kq/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 334, in <listcomp>
TypeError: 'NoneType' object is not callable
fatal: [localhost]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/aedu/.ansible/tmp/ansible-tmp-1617739488.1029868-1196900-212474867712925/AnsiballZ_hcloud_server.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/home/aedu/.ansible/tmp/ansible-tmp-1617739488.1029868-1196900-212474867712925/AnsiballZ_hcloud_server.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/aedu/.ansible/tmp/ansible-tmp-1617739488.1029868-1196900-212474867712925/AnsiballZ_hcloud_server.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.hetzner.hcloud.plugins.modules.hcloud_server', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib/python3.9/runpy.py\", line 210, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.9/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.9/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_hcloud_server_payload_r5b303kq/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 616, in <module>\n  File \"/tmp/ansible_hcloud_server_payload_r5b303kq/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 597, in main\n  File \"/tmp/ansible_hcloud_server_payload_r5b303kq/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 540, in present_server\n  File \"/tmp/ansible_hcloud_server_payload_r5b303kq/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 333, in _create_server\n  File \"/tmp/ansible_hcloud_server_payload_r5b303kq/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 334, in <listcomp>\nTypeError: 'NoneType' object is not callable\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

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

Cant set ssh_keys list in hcloud_server

SUMMARY

The module hcloud_server works like a charm for me, but when i add

    ssh_keys:
      - foo@bar

to my playbook ansible fails like shown at the end.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

hcloud_server

ANSIBLE VERSION
  config file = /home/ixyd/dev/videobridge-deployment/ansible.cfg
  configured module search path = ['/home/ixyd/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.9.1+ (default, Feb  5 2021, 13:46:56) [GCC 10.2.1 20210110]
CONFIGURATION
ANSIBLE_PIPELINING(/home/ixyd/dev/videobridge-deployment/ansible.cfg) = True
CACHE_PLUGIN(/home/ixyd/dev/videobridge-deployment/ansible.cfg) = yaml
CACHE_PLUGIN_CONNECTION(/home/ixyd/dev/videobridge-deployment/ansible.cfg) = tmp
COLLECTIONS_PATHS(/home/ixyd/dev/videobridge-deployment/ansible.cfg) = ['/home/ixyd/dev/videobridge-deployment/collections']
DEFAULT_HOST_LIST(/home/ixyd/dev/videobridge-deployment/ansible.cfg) = ['/home/ixyd/dev/videobridge-deployment/inventories/dev']
INTERPRETER_PYTHON(/home/ixyd/dev/videobridge-deployment/ansible.cfg) = /usr/bin/python3
OS / ENVIRONMENT

Debian testing/unstable ;)

STEPS TO REPRODUCE
- name: create nodes
  hcloud_server:
    api_token: ******
    name: "{{ item }}"
    server_type: "{{ shard.machine_type }}"
    image: ubuntu-20.04
    location: "{{ shard.location }}"
    ssh_keys:
      - foo@bar
    labels:
      env: dev
      shard: "{{ shard.desc }}"
    state: present
  with_sequence: start=1 count={{ shard.machines }} format={{ env }}.{{ shard.desc }}.jvb%d
  register: server

SSH-Key is uploaded and api_token is replaced by correct value of course.
When the two lines regarding ssh are removed, it works perfect.

EXPECTED RESULTS

No python failures and ssh key gets deployed successfully.

ACTUAL RESULTS
TASK [create node] *********************************************************************************************************************************************************************************************************************************
task path: /home/ixyd/dev/videobridge-deployment/nested_loop.yml:2
redirecting (type: modules) ansible.builtin.hcloud_server to hetzner.hcloud.hcloud_server
Including module_utils file ansible/__init__.py
Including module_utils file ansible/module_utils/__init__.py
Including module_utils file ansible/module_utils/_text.py
Including module_utils file ansible/module_utils/basic.py
Including module_utils file ansible/module_utils/common/_collections_compat.py
Including module_utils file ansible/module_utils/common/__init__.py
Including module_utils file ansible/module_utils/common/_json_compat.py
Including module_utils file ansible/module_utils/common/_utils.py
Including module_utils file ansible/module_utils/common/file.py
Including module_utils file ansible/module_utils/common/parameters.py
Including module_utils file ansible/module_utils/common/collections.py
Including module_utils file ansible/module_utils/common/process.py
Including module_utils file ansible/module_utils/common/sys_info.py
Including module_utils file ansible/module_utils/common/text/converters.py
Including module_utils file ansible/module_utils/common/text/__init__.py
Including module_utils file ansible/module_utils/common/text/formatters.py
Including module_utils file ansible/module_utils/common/validation.py
Including module_utils file ansible/module_utils/common/warnings.py
Including module_utils file ansible/module_utils/compat/selectors.py
Including module_utils file ansible/module_utils/compat/__init__.py
Including module_utils file ansible/module_utils/compat/_selectors2.py
Including module_utils file ansible/module_utils/distro/__init__.py
Including module_utils file ansible/module_utils/distro/_distro.py
Including module_utils file ansible/module_utils/parsing/convert_bool.py
Including module_utils file ansible/module_utils/parsing/__init__.py
Including module_utils file ansible/module_utils/pycompat24.py
Including module_utils file ansible/module_utils/six/__init__.py
Including module_utils file ansible_collections/hetzner/hcloud/plugins/module_utils/hcloud.py
Including module_utils file ansible/module_utils/ansible_release.py
Including module_utils file ansible_collections/__init__.py
Including module_utils file ansible_collections/hetzner/__init__.py
Including module_utils file ansible_collections/hetzner/hcloud/__init__.py
Including module_utils file ansible_collections/hetzner/hcloud/plugins/__init__.py
Including module_utils file ansible_collections/hetzner/hcloud/plugins/module_utils/__init__.py
Using module file /home/ixyd/dev/videobridge-deployment/collections/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py
Pipelining is enabled.
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: ixyd
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "<stdin>", line 102, in <module>
  File "<stdin>", line 94, in _ansiballz_main
  File "<stdin>", line 40, in invoke_module
  File "/usr/lib/python3.9/runpy.py", line 210, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_hcloud_server_payload_i8nc04ea/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 616, in <module>
  File "/tmp/ansible_hcloud_server_payload_i8nc04ea/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 597, in main
  File "/tmp/ansible_hcloud_server_payload_i8nc04ea/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 540, in present_server
  File "/tmp/ansible_hcloud_server_payload_i8nc04ea/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 333, in _create_server
  File "/tmp/ansible_hcloud_server_payload_i8nc04ea/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 334, in <listcomp>
TypeError: 'NoneType' object is not callable
failed: [localhost] (item=dev.shard1.jvb1) => {
    "ansible_loop_var": "item",
    "changed": false,
    "item": "dev.shard1.jvb1",
    "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 102, in <module>\n  File \"<stdin>\", line 94, in _ansiballz_main\n  File \"<stdin>\", line 40, in invoke_module\n  File \"/usr/lib/python3.9/runpy.py\", line 210, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.9/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.9/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_hcloud_server_payload_i8nc04ea/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 616, in <module>\n  File \"/tmp/ansible_hcloud_server_payload_i8nc04ea/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 597, in main\n  File \"/tmp/ansible_hcloud_server_payload_i8nc04ea/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 540, in present_server\n  File \"/tmp/ansible_hcloud_server_payload_i8nc04ea/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 333, in _create_server\n  File \"/tmp/ansible_hcloud_server_payload_i8nc04ea/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 334, in <listcomp>\nTypeError: 'NoneType' object is not callable\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

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

If there is anything i can do to help with further debugging just let me know!

Ansible Contributor Summit 09.21 registration is open

SUMMARY

I'm happy to announce that the registration (free) for the Ansible Contributor Summit is open.

Which day should you attend?

  • If you are wondering what it means to "contribute" to Ansible, or if you have been using Ansible for a while and are thinking of ways to get more involved with the project and community, then Day 1 (September 28, Tuesday) is for you! We will have hands-on labs and demos + a hackathon.
  • If you have already been contributing or participating in our previous Contributor Summits, you are still welcome to attend Day 1, however we think that Day 2 (October 1, Friday) will be more interesting for you.

Refer to the registration page for details.

See you at the summit!

Would it be possible to expose private networks to server facts and inventory plugin?

SUMMARY

For my workflow it would be very useful to have the private network IPs exposed to the inventory plugin and/or server_facts. I know the hcloud cli already implements it (and I'm using it). Also having it as an option for connect_with would be icing on the cacke.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

hcloud
hcloud_server_facts

ADDITIONAL INFORMATION

Most of my cloud instances are actually behind a gateway and I reach them over private networking / vpn links. I know I can get away with connect_with and split dns but still having access to private IPs could be beneficial.

hcloud volume detach

SUMMARY

Currently there is no way to deatch a volume from a server. Only via API Call https://docs.hetzner.cloud/#volume-actions-detach-volume

COMPONENT NAME

hcloud_volume

ADDITIONAL INFORMATION

I found this line "Create, update and attach/detach block volumes on the Hetzner Cloud." here hetzner.hcloud.hcloud_volume โ€“ Create and manage block Volume on the Hetzner Cloud. but there is no option to deatch the volume.

Also the Example block got a Duplicated entry : Mount a existing Volume and automount

HCLOUD_TOKEN env is undocumented

SUMMARY

api_token is a required parameter for most hcloud modules. Apparently one can user HCLOUD_TOKEN env for that.

It would be nice to have it in the docs / Readme

ISSUE TYPE
  • Documentation Report
COMPONENT NAME

all

ANSIBLE VERSION
3.2

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.