与netfire的solidfire一起使用

时间:2019-06-14 14:43:58

标签: python ansible netapp

我有一个样本netapp剧本

 ---
    - hosts: all
      gather_facts: False
      become: yes
      become_user: root
      become_method: sudo

      tasks:
        - name: Start restore
          na_elementsw_snapshot_restore:
            hostname: "{{ip_adr}}"
            username: "{{username}}"
            password: ""
            account_id: ansible-1
            src_snapshot_id: snapshot_20171021
            src_volume_id: volume-playarea
            dest_volume_name: dest-volume-area

和此清单文件

 snaptest ansible_host=192.168.1.10 ansible_connection=ssh ansible_user=centos ansible_ssh_private_key_file=/home/slenz/.ssh/id_vm_sync ansible_python_interpreter=/usr/bin/python2.7


[snap]
snaptest

我运行剧本时得到

 fatal: [snaptest]: FAILED! => {"changed": false, "msg": "the python SolidFire SDK module is required"}

但是我确实通过pip安装了solidfire

 Requirement already satisfied: solidfire-sdk-python in /usr/lib/python2.7/site-packages (1.5.0.87)
 Requirement already satisfied: setuptools>=19.2 in /usr/lib/python2.7/site-packages (from solidfire-sdk-python) (41.0.1)
 Requirement already satisfied: future>=0.15.2 in /usr/lib/python2.7/site-packages (from solidfire-sdk-python) (0.17.1)
 Requirement already satisfied: enum34>=1.1.6 in /usr/lib/python2.7/site-packages (from solidfire-sdk-python) (1.1.6)
 Requirement already satisfied: requests>=2.9.1 in /usr/lib/python2.7/site-packages (from solidfire-sdk-python) (2.22.0)
 Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/lib/python2.7/site-packages (from requests>=2.9.1->solidfire-sdk-python) (3.0.4)
 Requirement already satisfied: idna<2.9,>=2.5 in /usr/lib/python2.7/site-packages (from requests>=2.9.1->solidfire-sdk-python) (2.8)
 Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/lib/python2.7/site-packages (from requests>=2.9.1->solidfire-sdk-python) (1.25.3)
 Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python2.7/site-packages (from requests>=2.9.1->solidfire-sdk-python) (2019.3.9)

现在我的问题是为什么ansible找不到固体火。我可以打开python cli并执行“ import solidfire.common”,该方法可以正常工作。

我正在使用ansible 2.8.0,centos7和python 2.7.5

谢谢您的帮助。

2 个答案:

答案 0 :(得分:0)

只有一个模块返回the python SolidFire SDK module is required消息。

这是ansible/module_utils/netapp.py模块。

返回此错误消息(如果为false)的条件是:

if HAS_SF_SDK and hostname and username and password:

因此,如果您的password字段为空(Python认为""为假),则会出现此错误。

答案 1 :(得分:0)

您需要修复tasks之前的部分。 localsf是我在/ etc / ansible / hosts中的本地SolidFire MVIP。您不需要sudo即可使用SolidFire Python SDK并连接到MVIP。

- name: NetApp Element Software Snapshot-to-Volume 
  hosts: localsf
  gather_facts: no
  connection: local

接下来,account_id: ansible-1:没有这样的帐户ID。 ID是整数,不是字符串。您可能是说account_id: 1

最后但并非最不重要的是,空密码值。