2017年7月17日 星期一

Cisco ASA - paramiko is required but does not appear to be installed

最近在試 Cisco ASA 5512X 這個型號,就想說能不能用 Ansible 來管設定,所以就先從簡單的 show version 的指令開始測試。
OS / ENVIRONMENT
macOS Sierra
Version 10.12.5
ANSIBLE VERSION
ansible 2.3.1.0
  config file =
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, Apr  4 2017, 08:46:44) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
ANSIBLE CONFIGURATION
ansible inventory - hosts
asa           ansible_host=192.168.1.1   
---
- hosts: asa
  connection: local
  gather_facts: yes
  tasks:
    - name: run show version on remoter devices
      asa_command:
        provider:
          host: IP
          username: USERNAME
          password: PASSWORD
          authorize: yes
          auth_pass: PASSWORD
          timeout: 30
        commands:
          - show version
      register: version
    - name: show version
      debug:
        var: version.stdout_lines
      with_items: version.results

STEPS TO REPRODUCE

ansible-playbook -i hosts asa.yml -vvv
No config file found; using defaults

PLAYBOOK: asa.yml *************************************************************************************************
1 plays in asa.yml

PLAY [cisco] ******************************************************************************************************
META: ran handlers

TASK [Show Version] ***********************************************************************************************
task path: /Users/daniel/work/tenmax/lab/asa.yml:6
Using module file /usr/local/lib/python2.7/site-packages/ansible/modules/network/asa/asa_command.py
 ESTABLISH LOCAL CONNECTION FOR USER: daniel
 EXEC /bin/sh -c 'echo ~ && sleep 0'
 EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/daniel/.ansible/tmp/ansible-tmp-1500340664.8-207253128376700 `" && echo ansible-tmp-1500340664.8-207253128376700="` echo /Users/daniel/.ansible/tmp/ansible-tmp-1500340664.8-207253128376700 `" ) && sleep 0'
 PUT /var/folders/5w/tkr8l6gn7zs76_8n1z6jg_r80000gn/T/tmpMpIKV3 TO /Users/daniel/.ansible/tmp/ansible-tmp-1500340664.8-207253128376700/asa_command.py
 EXEC /bin/sh -c 'chmod u+x /Users/daniel/.ansible/tmp/ansible-tmp-1500340664.8-207253128376700/ /Users/daniel/.ansible/tmp/ansible-tmp-1500340664.8-207253128376700/asa_command.py && sleep 0'
 EXEC /bin/sh -c '/usr/bin/python /Users/daniel/.ansible/tmp/ansible-tmp-1500340664.8-207253128376700/asa_command.py; rm -rf "/Users/daniel/.ansible/tmp/ansible-tmp-1500340664.8-207253128376700/" > /dev/null 2>&1 && sleep 0'
fatal: [cisco]: FAILED! => {
    "changed": false,
    "failed": true,
    "invocation": {
        "module_args": {
            "auth_pass": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "authorize": true,
            "commands": [
                "show version"
            ],
            "context": null,
            "host": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "interval": 1,
            "match": "all",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": null,
            "provider": {
                "auth_pass": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "authorize": true,
                "host": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
            },
            "retries": 10,
            "ssh_keyfile": null,
            "timeout": 10,
            "transport": null,
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "wait_for": null
        }
    },
    "msg": "paramiko is required but does not appear to be installed.  It can be installed using  `pip install paramiko`"
}
    to retry, use: --limit @/Users/daniel/work/tenmax/lab/asa.retry

PLAY RECAP ********************************************************************************************************
cisco                      : ok=0    changed=0    unreachable=0    failed=1
執行後,會看到有錯誤 
"msg": "paramiko is required but does not appear to be installed.  It can be installed using  `pip install paramiko`"
實際上,我已經裝了,後來詢問谷歌大神後,發現會出現這樣的問題原因是,有可能你的作業系統裡,有安裝多個不同的版本的 Python ,所以要解決這個問題的話,就是去指定你的Pythonn解釋器,目前ansible都還是以Python2.X版的為主,接下來在 inventory file裡面去新增 ansible_python_interpreter,這樣就解決了。
asa           ansible_host=192.168.1.1     ansible_python_interpreter=/usr/bin/python 
Reference:

沒有留言:

張貼留言