Melvin Magro
Melvin Magro

Reputation: 19

How-to: Hetzner Cloud Ansible - setting up hetzner server using ansible

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

Upvotes: 0

Views: 1420

Answers (1)

Melvin Magro
Melvin Magro

Reputation: 19

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.

Upvotes: 2

Related Questions