关于 python:ansible with solidfire for netapp

ansible with solidfire for netapp

我有一个示例 netapp playbook

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 —
    – 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

还有这个库存文件

1
2
3
4
5
 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

当我运行剧本时,我得到

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

但是我确实通过 pip

安装了solidfire

1
2
3
4
5
6
7
8
9
 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 找不到solidfire。我可以打开一个 python cli 并执行”import solidfire.common”,这很有效。

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

感谢您的帮助。


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

1
2
3
4
– name: NetApp Element Software Snapshot-to-Volume
  hosts: localsf
  gather_facts: no
  connection: local

接下来,account_id: ansible-1:没有这样的帐户 ID。
ID 是整数,而不是字符串。你的意思可能是 account_id: 1.

最后但同样重要的是,空密码值。


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

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

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

if HAS_SF_SDK and hostname and username and password:

因此,如果您的 password 字段为空(Python 认为 “” 为假),您将收到此错误。


原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/python/267917.html

(0)
上一篇 2022年6月19日 03:03
下一篇 2022年6月19日 03:04

相关推荐

发表回复

登录后才能评论