purestorage sdk missing

Hi guys.

When calling a playbook I get the following error:

FAILED! => {“changed”: false, “msg”: “purestorage sdk is required for this module in volume”}

Purestorage sdk is installed in my laptop (i’m running that locally):
purestorage (1.16.0)

ansible 2.7.9
config file = /etc/ansible/ansible.cfg
configured module search path = [u’/home/lucas/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /home/lucas/.local/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.15+ (default, Oct 2 2018, 22:12:08) [GCC 8.2.0]

What could that error be for?
Thanks!

Make sure you have the respective purestorage python library.

Also, set PUREFA_URL and PUREFA_API environment variables if url and api_token arguments are not passed to the module directly.

-R.Rao

Make sure you have the respective purestorage python library.

I already have it.

[lucas@thanos ~]$ pip list | grep ‘purestorage’
purestorage (1.16.0)

Also, set PUREFA_URL and PUREFA_API environment variables if url and api_token arguments are not passed to the module directly.

url and api_token are passed to the module:

Maybe forgot a delegate_to and you execure the module on remote host?

Maybe forgot a delegate_to and you execure the module on remote host?

I am not executing the module on remote host. It is locally.

This is the yaml file:

This code doesn't prove that's running locally.

modules will only run on localhost if the playbook have "hosts: localhost" or "connection: local".
If not, the module will run on remote host(s) unless you have "delegate_to: localhost" on the task(s).

OKay… so…
As you can see in the task and in the link I’ve provided, I’m using the Pure Storage ansible module, which will connect to the SAN Storage array via a REST API and will execute the commands I want.
So, I am running the Task locally and then it will connect to the Array and to its thing.

However, note that the task doesn’t even get connected to the array as it fails before that. I do not see connection attempts in the Array.

What I know so far:

  1. I am running Ansible 2.7
  2. I have Python 2.7 installed
  3. I have pip 2.7 installed
  4. I have the purestorage python module (purestorage==1.16.0) installed
  5. I am running the task locally.
    Still trying to figure out why I’m getting the error: “msg”: “purestorage sdk is required for this module in volume”

how did you install the python library purestorage ?

pip install purestorage

did you use a virtualenv? did you u do it as root? did you do it as your user? did you do pip install --user ?

No. All I did was to run, as my user (not root), pip install purestorage. Nothing else.

did you use a virtualenv? did you u do it as root? did you do it as your user? did you do pip install --user ?

No. All I did was to run, as my user (not root), pip install purestorage. Nothing else.

So… doing some tests.

Playbook is as follow:


  • name: Oracle Database Snapshots

hosts: dbservers

remote_user: oracle

sudo: true

sudo_user: root

vars_files:

  • vars/arrays.yaml

  • vars/database.yaml

tasks:

Take Snapshot of database volumes

  • include: tasks/take_snapshot.yaml

run_once: yes

tasks/take_snapshot.yaml:


Perform PURE Flasharray Database snapshots

  • name: perform PURE volume snapshot

purefa_snap:

name: db2-prod-oracledb

suffix: snap

fa_url: “{{ fa_url }}”

api_token: “{{ apiToken }}”

Now, if I replace “hosts: dbservers” for “hosts: localhost”, it works. So that means it was indeed trying to connect to “dbservers” and then running the commands.
I did check the dbservers host and I can see purestorage sdk is also installed there.

oracle[DR]@db2:~$pip freeze |grep purestorage

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.

purestorage==1.16.0

How can I fix the missing purestorage sdk error? It is an RHEL 6.7.
Thanks!

So.. doing some tests.

Playbook is as follow:

---
- name: Oracle Database Snapshots
  hosts: dbservers
  remote_user: oracle
  sudo: true
  sudo_user: root
  vars_files:
    - vars/arrays.yaml
    - vars/database.yaml

  tasks:

# Take Snapshot of database volumes
    - include: tasks/take_snapshot.yaml
      run_once: yes

tasks/take_snapshot.yaml:

---
# Perform PURE Flasharray Database snapshots
- name: perform PURE volume snapshot
  purefa_snap:
    name: db2-prod-oracledb
    suffix: snap
    fa_url: "{{ fa_url }}"
    api_token: "{{ apiToken }}"

Now, if I replace "*hosts: dbservers*" for "*hosts: localhost*", it works.
So that means it was indeed trying to connect to "*dbservers*" and then
running the commands.

As I explained to you in a previous mail :slight_smile:
This is how must modules work, they run on remote host unless hosts: localhost, connection: local or delegate_to: localhost is set somewhere.

I did check the dbservers host and I can see purestorage sdk is also
installed there.

oracle[DR]@db2:~$pip freeze |grep purestorage
DEPRECATION: Python 2.7 will reach the end of its life on January 1st,
2020. Please upgrade your Python as Python 2.7 won't be maintained after
that date. A future version of pip will drop support for Python 2.7.
purestorage==1.16.0

How can I fix the missing purestorage sdk error? It is an RHEL 6.7.

Or just keep "hosts: dbservers" and add "delegate_to: localhost" on the purefa_snap task.
Then you don't have to deal the SDK on the remote machine since the module Python code is run on localhost.

Or just keep “hosts: dbservers” and add “delegate_to: localhost” on the
purefa_snap task.
Then you don’t have to deal the SDK on the remote machine since the
module Python code is run on localhost.

The thing is… I want the playbook to be executed on the host (not locally). Testing it locally was only really a test to see where the problem is. So I need to fix the missing SDK error.

Lucas

It's more a Python problem than Ansible.
Ansible is running /usr/bin/python so your module need to be install in one of it's search path.

To check the path you can run
/usr/bin/python -c 'import sys; print sys.path'

If the path listed is one of the paths that purestorage is this command should work.

To check if you can import purestorage
/usr/bin/python -c 'import purestorage'

You should also check from you Ansible control machine to rule out environment variables not set by running
ssh <user>@<dbserver> "/usr/bin/python -c 'import sys; print sys.path; import purestorage'"

Or just keep “hosts: dbservers” and add “delegate_to: localhost” on
the
purefa_snap task.
Then you don’t have to deal the SDK on the remote machine since the
module Python code is run on localhost.

The thing is… I want the playbook to be executed on the host (not
locally). Testing it locally was only really a test to see where the
problem is. So I need to fix the missing SDK error.

It’s more a Python problem than Ansible.
Ansible is running /usr/bin/python so your module need to be install in
one of it’s search path.

To check the path you can run
/usr/bin/python -c ‘import sys; print sys.path’

If the path listed is one of the paths that purestorage is this command
should work.

To check if you can import purestorage
/usr/bin/python -c ‘import purestorage’

You should also check from you Ansible control machine to rule out
environment variables not set by running
ssh @ “/usr/bin/python -c ‘import sys; print sys.path;
import purestorage’”

It is definitely a Python problem than Ansible.

[root@db2 ~]# /usr/bin/python -c 'import sys; print sys.path;

import purestorage’

[‘’, ‘/usr/lib64/python26.zip’, ‘/usr/lib64/python2.6’, ‘/usr/lib64/python2.6/plat-linux2’, ‘/usr/lib64/python2.6/lib-tk’, ‘/usr/lib64/python2.6/lib-old’, ‘/usr/lib64/python2.6/lib-dynload’, ‘/usr/lib64/python2.6/site-packages’, ‘/usr/lib64/python2.6/site-packages/gtk-2.0’, ‘/usr/lib/python2.6/site-packages’]

Traceback (most recent call last):

File “”, line 2, in

ImportError: No module named purestorage

Thanks for your help. Will try to get this python issue fixed.
Thanks!

Looks like you have Python 2.6 and 2.7 installed and that /usr/bin/python is 2.6 but purestorage is installed in 2.7.
To make Ansible use another Python than /usr/bin/python check out ansible_python_interpreter
https://docs.ansible.com/ansible/latest/reference_appendices/faq.html#how-do-i-handle-python-not-having-a-python-interpreter-at-usr-bin-python-on-a-remote-machine