avnshrai
avnshrai

Reputation: 73

While running Ansible playbook getting error install request library

I am trying to create a vm on gcp using ansible playbook on my ansible master machine my ansible master is on ubuntu-desktop(WSL) I have installed requests and google-auth but while running playbook, I am getting error

"FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "changed": false, "msg": "Please install the requests library"}"

and while running "pip3 install requests". It is prompting it's already present "Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: requests in /usr/lib/python3/dist-packages (2.22.0)"

Upvotes: 1

Views: 2039

Answers (3)

Antoine
Antoine

Reputation: 4734

I had a requirements.yaml playbook file with package to install :

---
- hosts: localhost
  connection: local
  gather_facts: no
  vars:
    pip_package_requirements:
      - "requests"
      - "google-auth"
      - "google-auth-httplib2"
      - "google-auth-oauthlib"
      - "google-cloud"
      -
  tasks:
    - name: Install pip requests library
      pip:
        name: "{{ item }}"
        state: present
      with_items: "{{ pip_package_requirements }}"

And I import this playbook

- import_playbook: requirements.yaml

Upvotes: 1

Farkhod Sadykov
Farkhod Sadykov

Reputation: 75

You just will need to make sure you have requests library in your local host

Just install requests

pip install requests

Upvotes: 0

avnshrai
avnshrai

Reputation: 73

I have solved the problem, I was getting "please install the requests library" because I was not installing requests on host server, requests module needs to be installed on slave machine as well.

Upvotes: 2

Related Questions