0

While trying to create a hetzner server using ansible and following the below documentation; https://community.hetzner.com/tutorials/howto-hcloud-ansible

The playbook gets stuck for some reason and no server is created. Any ideas why this is happening?

Using /home/melvmagr/repos/ansible/ansible.cfg as config file
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
redirecting (type: modules) ansible.builtin.hcloud_server to hetzner.hcloud.hcloud_server
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: server.yml ************************************************************************************
1 plays in playground/server.yml

PLAY [Create Basic Server] ******************************************************************************

TASK [Gathering Facts] **********************************************************************************
task path: /home/melvmagr/repos/ansible/playground/server.yml:3
ok: [localhost]
META: ran handlers

TASK [Create a basic server] ****************************************************************************
task path: /home/melvmagr/repos/ansible/playground/server.yml:11
redirecting (type: modules) ansible.builtin.hcloud_server to hetzner.hcloud.hcloud_server

Playbook is as follows;

# server.yml
---
- name: Create Basic Server
  hosts: localhost
  connection: local
  #gather_facts: False
  user: root
  vars:
    hcloud_token: "my_hetzner_API_token"
  tasks:
    - name: Create a basic server
      hcloud_server:
          api_token: "my_hetzner_API_token"
          name: test-server
          server_type: cx11
          #image: master-template-update-09-06-2022
          image: ubuntu-18.04
          state: present
      register: server
  • Because of Ansible Issue #[77818](https://github.com/ansible/ansible/issues/77818), can you provide more information regarding your used versions (Ansible, Python, Collections, Modules, etc.) as well installation paths? – U880D Jun 16 '22 at 15:40
  • great! how do I use this new hcloud server with my other playbooks.yml? normally the IP addresses of the servers are stored in hosts. I assume if I run the server.yml playbook a 2nd time I get another server. how do I use this to manage multiple servers but avoid having extra ones I don't need? I don't want to use Ansible tower. – moin moin Aug 02 '22 at 12:55

1 Answers1

1

The comment by U880D actually got me thinking about python version and modules I had installed.

I ran the following so that I had everything up-to-date:

apt-get install python
apt-get install python3 python3-pip python3-venv

And saw that I was also missing the hcloud module when running pip3 list so I installed it using;

pip3 install hcloud

And everything worked like a charm. Hetzner server was created using ansible playbook.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83