Comments (11)
not a bug
I assume you installed ansible with python2 pip. But hcloud is python3 only. You should consider to use python3 venv anyway to be independend of systems python and OS.
apt-get install python3 python3-pip python3-venv
cd to-your-playbooks
python3 -m venv venv
source venv/bin/activate
# you are now in a venv, install python deps
pip install ansible hcloud-python
# to get your PATH updated, leave venv with deactivate and activate again
deactivate
source venv/bin/activate
ansible --version
from hcloud-python.
Same here on arch-linux
Ansible reports Python /usr/bin/python
$ /usr/bin/python --version
Python 3.9.7
$ pip --version
pip 20.3.4 from /usr/lib/python3.9/site-packages/pip (python 3.9)
$ pip install hcloud-python
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement hcloud-python
ERROR: No matching distribution found for hcloud-python
$ pip install hcloud
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: hcloud in /home/user/.local/lib/python3.9/site-packages (1.16.0)
SOLVED:
The playbook uses become
(root) and the hcloud-pkg was installed for the user.
So become: false
in the task solves it. :)
from hcloud-python.
Debian packages for ansible used to rely on python2 and that is why it will not use python3 libraries. Install ansible in a venv for python3 as I posted.
from hcloud-python.
Having the same issue here, on Mac OS Monterey with Python/Pip 3.10
EDIT: For anyone encountering this error, while the error message calls the package hcloud-python
, when installing it via pip, you do in fact want just want hcloud
pip install hcloud
from hcloud-python.
Hi resmo,
I didn't install Ansible with pip 2, but directly with Ubuntu's apt manager. I installed hcloud with pip3 (pip3 install hcloud
).
I tried once again with 2 differents Ubuntu versions, 20.04 (with Python 3.8) and 21.10 (Python 3.9) but both are throwing the same error: Failed to import the required Python library (hcloud-python) on computer's Python /usr/bin/python3
The only laptop where this is working is on a MacBook Pro (Python 3.9 and hcloud 1.12).
Comparing a bit both installations (Mac and Ubuntu) I noticed something that maybe could be relevant...
running the command which hcloud
shows /usr/local/bin/hcloud
(in Mac laptop) but nothing shows up in the Ubuntu laptop....
from hcloud-python.
Bonjour @resmo
Now the problem with hcloud is gone, but now a SSH key not found error shows up... ;-)
In my Ansible's hosts file I have this directive: ansible_ssh_private_key_file=~/.ssh/id_rsa
When running Ansible in a virtual environment, does it lookup for files outside the virtual env? or is limited only to it?
from hcloud-python.
@jobetinfosec lookup is not limited to the venv, the venv is only for python dependency it is not a "container" or a "secured environment"
Nevertheless, I tested it and confirm this worked.
- hosts: localhost
tasks:
- debug:
msg: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
from hcloud-python.
I have the same issue ansible-playbook -vvv server-create-init.yml
my playbook
---
- hosts: localhost
gather_facts: false
become: false
vars_files:
- /etc/ansible/roles/server-create/defaults/main.yml
- /etc/ansible/roles/server-create/vars/main.yml
roles:
- role: "/etc/ansible/roles/server-create"
Task:
---
- name: Create a basic server
hcloud_server:
api_token: "{{ token }}"
name: "{{ item.name }}"
server_type: "{{ item.server_type }}"
image: "{{ item.os_image }}"
state: present
register: server
with_items: "{{ server }}"
Can not find any solves of this issue (hcloud-python) . Could you please help with solution?
root@ip-172-31-27-151:/usr/bin# pip install ansible hcloud-python
Requirement already satisfied: ansible in /usr/lib/python3/dist-packages (5.4.0)
ERROR: Could not find a version that satisfies the requirement hcloud-python (from versions: none)
ERROR: No matching distribution found for hcloud-python
root@ip-172-31-27-151:/usr/bin# python3 --version
Python 3.8.10
/etc/ansible/hosts
[Server_hetzner]
localhost ansible_connection=local
[all:vars]
ansible_python_interpreter=/usr/bin/python3
root@ip-172-31-27-151:/usr/bin# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
from hcloud-python.
I have the same issue ansible-playbook -vvv server-create-init.yml
my playbook
--- - hosts: localhost gather_facts: false become: false vars_files: - /etc/ansible/roles/server-create/defaults/main.yml - /etc/ansible/roles/server-create/vars/main.yml roles: - role: "/etc/ansible/roles/server-create"
Task:
--- - name: Create a basic server hcloud_server: api_token: "{{ token }}" name: "{{ item.name }}" server_type: "{{ item.server_type }}" image: "{{ item.os_image }}" state: present register: server with_items: "{{ server }}"
Can not find any solves of this issue (hcloud-python) . Could you please help with solution?
root@ip-172-31-27-151:/usr/bin# pip install ansible hcloud-python
Requirement already satisfied: ansible in /usr/lib/python3/dist-packages (5.4.0) ERROR: Could not find a version that satisfies the requirement hcloud-python (from versions: none) ERROR: No matching distribution found for hcloud-python
root@ip-172-31-27-151:/usr/bin# python3 --version
Python 3.8.10
/etc/ansible/hosts
[Server_hetzner] localhost ansible_connection=local [all:vars] ansible_python_interpreter=/usr/bin/python3
root@ip-172-31-27-151:/usr/bin# cat /etc/os-release
NAME="Ubuntu" VERSION="20.04.4 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.4 LTS" VERSION_ID="20.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=focal UBUNTU_CODENAME=focal
I just wanted to check in and say the same thing started happening to me about 4 days ago as well. I was out of office for the weekend and only noticed today(monday)
from hcloud-python.
This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs.
from hcloud-python.
Maybe this can help someone in the future:
We had the same issue on ubuntu 22.04. We were moving from an installation without virtual env to an installation with virtual env. The tasks originally executed on an "ansible" group:
# hosts.yml
---
all:
hosts:
ansible:
ansible_host: localhost
ansible_connection: local
# TestPlaybook.yml
---
- name: Get some infos
hosts: ansible
gather_facts: false
tasks:
- name: Gather facts about the cloud # <-- Fails
hetzner.hcloud.hcloud_server_info:
name: "testhost"
api_token: "{{ hetzner_cloud_api_token }}"
Therefore ansible set the python3 interpreter to usr/bin/python3
but the python interpreter was in the virtual enviroment ~/venv/bin/python3
. Setting the hosts to just localhost
fixed it for us.
# TestPlaybook.yml
---
- name: Get some infos
hosts: localhost
gather_facts: false
tasks:
- name: Gather facts about the cloud # <-- Fails
hetzner.hcloud.hcloud_server_info:
name: "testhost"
api_token: "{{ hetzner_cloud_api_token }}"
Were are wondering about why the python interpreter in the venv does import the library without errors because it is just a symbolic link to /usr/bin/python3
but we did not investigate it further.
from hcloud-python.
Related Issues (20)
- doc: mention "python -m venv " because mkvirtualenv is not always installed
- Bug in hcloud-inventory: one server without public ip4v crashes the complete plugin HOT 1
- Transfer resources HOT 1
- Dependency Dashboard
- Move hcloud.hcloud module to hcloud._client HOT 2
- Ensure some keyword arguments are passed as such HOT 2
- Incompatible ISO8601 format returned by the API HOT 1
- Move package version from `hcloud.__version__.VERSION` to `hcloud.__version__` HOT 2
- Drop python 3.7 support
- Howto use wss link to open a console HOT 7
- Use timeouts on API requests HOT 2
- cannot import name 'Image' from 'hcloud.images' HOT 1
- Mirror the API responses in the returned values HOT 1
- Hang and failure when accessing attributes like Server and Images HOT 1
- Wrong filters combination in client.servers.get_all HOT 5
- Filter multiple machines with the similar name HOT 1
- Failed to update the labels for BoundImage HOT 1
- Client, APIException and HCloudException not properly exported
- v1.33.1 not uploaded to PyPI HOT 2
- Is there any way to link server_types with locations? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hcloud-python.