Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR! 'ntc_show_command' is not a valid attribute for a Play #94

Closed
spirrello opened this issue Jan 14, 2016 · 14 comments
Closed

ERROR! 'ntc_show_command' is not a valid attribute for a Play #94

spirrello opened this issue Jan 14, 2016 · 14 comments

Comments

@spirrello
Copy link

Hi,

After cloning ntc-ansible, i tried to launch the following playbook using the example provided but I'm getting the following error. Can you help?

$ ansible-playbook get_vlan.yml
[WARNING]: provided hosts list is empty, only localhost is available

ERROR! 'ntc_show_command' is not a valid attribute for a Play

The error appears to have been in '/Users/SPirrello/Google Drive/Work/scripts/ntc-ansible/get_vlan.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  • ntc_show_command:
    ^ here

$ cat get_vlan.yml

  • ntc_show_command:
    connection=ssh
    platform=cisco_nxos
    command='show vlan'
    host={{ 10.192.1.1 }}
    username={{ my_login }}
    password={{ my_password }}
@jedelman8
Copy link
Member

Hi @spirrello

Your get_vlan.yml needs more than the task.

It needs to look like this (using a different format for readability):

---

- name: GET STRUCTURED DATA BACK FROM CLI DEVICES
  hosts: all
  connection: local
  gather_facts: False

  tasks:

    - name: GET VLANS IN REAL TIME
      ntc_show_command:
         connection: ssh
         platform: cisco_nxos
         command: show vlan
         host: "{{ inventory_hostname }}"  
         username: "{{ my_login }}"
         password: "{{ my_password }}"
      register: result

    - debug: var=result

Don't have the IP address in curly braces...curly braces mean it's a variable.

You also need an inventory file with at least one host in. Given your example it could look like this:

[all:vars]
my_login=XXX
my_password=ABC

[nexus]
10.192.1.1 

And if you didn't set your env variable for the inventory file, when you run it, it should be:

ansible-playbook -i inventory_file get_vlan.yml

@spirrello
Copy link
Author

I'll try this out today. Thanks for the quick response!

On Thu, Jan 14, 2016 at 5:43 PM, Jason Edelman notifications@github.com
wrote:

Hi @spirrello https://github.com/spirrello

Your get_vlan.yml needs more than the task.

It needs to look like this (using a different format for readability):


  • name: GET STRUCTURED DATA BACK FROM CLI DEVICES
    hosts: all
    connection: local
    gather_facts: False

    tasks:

    • name: GET VLANS IN REAL TIME
      ntc_show_command:
      connection: ssh
      platform: cisco_nxos
      command: show vlan
      host: "{{ inventory_hostname }}"
      username: "{{ my_login }}"
      password: "{{ my_password }}"
      register: result
    • debug: var=result

Don't have the IP address in curly braces...curly braces mean it's a
variable.

You also need an inventory file with at least one host in. Given your
example it could look like this:

[all:vars]
my_login=XXX
my_password=ABC

[nexus]
10.192.1.1

And if you didn't set your env variable for the inventory file, when you
run it, it should be:

ansible-playbook -i inventory_file get_vlan.yml


Reply to this email directly or view it on GitHub
#94 (comment)
.

@spirrello
Copy link
Author

Here's the error I'm getting now and I've copied the textfsm.py script in
the directory of where the ntc_templates live. I also copied the
textfsm.py script where the get_vlan.yml file is.

Am I do something else wrong?

damac:ntc-ansible SPirrello$ ansible-playbook -i inventory_hostname
get_vlan.yml

PLAY [GET STRUCTURED DATA BACK FROM CLI DEVICES]


TASK [GET VLANS IN REAL TIME]


fatal: [10.159.129.2]: FAILED! => {"changed": false, "failed": true, "msg":
"This module requires TextFSM"}

PLAY RECAP


10.159.129.2 : ok=0 changed=0 unreachable=0 failed=1

damac:ntc-ansible SPirrello$ cat get_vlan.yml

  • name: GET STRUCTURED DATA BACK FROM CLI DEVICES
    hosts: all
    connection: local
    gather_facts: False

    tasks:

    • name: GET VLANS IN REAL TIME
      ntc_show_command:
      connection: ssh
      platform: cisco_nxos
      command: show vlan
      host: "{{ inventory_hostname }}"
      username: "{{ my_login }}"
      password: "{{ my_password }}"
      register: result
    • debug: var=resultdamac:ntc-ansible SPirrello$

damac:ntc-ansible SPirrello$ cat inventory_hostname
[all:vars]
my_login=login
my_password=password

[nexus]
10.192.1.1

On Thu, Jan 14, 2016 at 5:43 PM, Jason Edelman notifications@github.com
wrote:

Hi @spirrello https://github.com/spirrello

Your get_vlan.yml needs more than the task.

It needs to look like this (using a different format for readability):


  • name: GET STRUCTURED DATA BACK FROM CLI DEVICES
    hosts: all
    connection: local
    gather_facts: False

    tasks:

    • name: GET VLANS IN REAL TIME
      ntc_show_command:
      connection: ssh
      platform: cisco_nxos
      command: show vlan
      host: "{{ inventory_hostname }}"
      username: "{{ my_login }}"
      password: "{{ my_password }}"
      register: result
    • debug: var=result

Don't have the IP address in curly braces...curly braces mean it's a
variable.

You also need an inventory file with at least one host in. Given your
example it could look like this:

[all:vars]
my_login=XXX
my_password=ABC

[nexus]
10.192.1.1

And if you didn't set your env variable for the inventory file, when you
run it, it should be:

ansible-playbook -i inventory_file get_vlan.yml


Reply to this email directly or view it on GitHub
#94 (comment)
.

@jedelman8
Copy link
Member

This module requiresTextFSM. You can install with pip pip install gtextfsm (sudo if you need to)

If you don't have pip, you can run these 4 commands first.

wget https://pypi.python.org/packages/source/g/gtextfsm/gtextfsm-0.2.1.tar.gz
tar -xzvf gtextfsm-0.2.1.tar.gz
cd gtextfsm-0.2.1
python setup.py install

@spirrello
Copy link
Author

Finally got it working. For some reason when I did the pip instsall for
textfsm, it was missing some of the modules in the following directory.

/usr/lib/python2.6/site-packages/textfsm-0.2.2-py2.6.egg/

I appreciate your responses and keep the network automation movement going!

On Sun, Jan 17, 2016 at 10:22 AM, Jason Edelman notifications@github.com
wrote:

This module requiresTextFSM. You can install with pip pip install gtextfsm
(sudo if you need to)

If you don't have pip, you can run these 4 commands first.

wget https://pypi.python.org/packages/source/g/gtextfsm/gtextfsm-0.2.1.tar.gz
tar -xzvf gtextfsm-0.2.1.tar.gz
cd gtextfsm-0.2.1
python setup.py install


Reply to this email directly or view it on GitHub
#94 (comment)
.

@jedelman8
Copy link
Member

Awesome.

@JackFyq
Copy link

JackFyq commented Feb 15, 2016

I also find that after pip install gtextfsm there is below error:

root@fa1390b85b25:/opt/ansible/ansible/ntc-ansible# ansible-playbook -i hosts myTest.yml

PLAY [GET STRUCTURED DATA BACK FROM CLI DEVICES] *******************************

TASK [GET VLANS IN REAL TIME] **************************************************
fatal: [10.170.81.82]: FAILED! => {"changed": false, "failed": true, "msg": "This module requires TextFSM"}

PLAY RECAP *********************************************************************
10.170.81.82 : ok=0 changed=0 unreachable=0 failed=1

root@fa1390b85b25:/opt/ansible/ansible/ntc-ansible# pip list
ansible (2.0.0)
argparse (1.2.1)
chardet (2.0.1)
colorama (0.2.5)
ecdsa (0.13)
gtextfsm (0.2.1)
html5lib (0.999)
httplib2 (0.8)
Jinja2 (2.7.2)
MarkupSafe (0.18)
nelsnmp (0.2.4)
netmiko (0.2.8)
paramiko (1.16.0)
pexpect (4.0.1)
pip (1.5.4)
ply (3.8)
ptyprocess (0.5.1)
py (1.4.31)
pyasn1 (0.1.9)
pycrypto (2.6.1)
pysmi (0.0.6)
pysnmp (4.3.1)
pytest (2.8.5)
python-keyczar (0.6b)
PyYAML (3.10)
requests (2.2.1)
scp (0.10.2)
setuptools (3.3)
six (1.5.2)
ssh-import-id (3.21)
textfsm (0.2.1)
urllib3 (1.7.1)
wheel (0.24.0)
wsgiref (0.1.2)

the textfsm(0.2.1) has been installed but ntc_show_command can't find textfsm ?

this is myTest.yml

  • name: GET STRUCTURED DATA BACK FROM CLI DEVICES
    hosts: cisco_ios
    connection: local
    gather_facts: False

    tasks:

    • name: GET VLANS IN REAL TIME
      ntc_show_command:
      connection: ssh
      platform: cisco_ios
      command: "show ip bgp summary"
      host: "{{ inventory_hostname }}"
      username: "{{ username }}"
      password: "{{ password }}"
      register: result
    • debug: var=result.response

@jedelman8
Copy link
Member

Can you give more background on the machine? OS, version of Python, etc.

Also, are you using the pre-built container or your own image?

Can you also go into a Python shell and try to import textfsm?

On Feb 15, 2016, at 12:54 AM, JackFusd notifications@github.com wrote:

I also find that after pip install gtextfsm there is below error:

root@fa1390b:/opt/ansible/ansible/ntc-ansible# ansible-playbook -i hosts myTest.yml

PLAY [GET STRUCTURED DATA BACK FROM CLI DEVICES] *******************************

TASK [GET VLANS IN REAL TIME] **************************************************
fatal: [10.170.81.82]: FAILED! => {"changed": false, "failed": true, "msg": "This module requires TextFSM"}

PLAY RECAP *********************************************************************
10.170.81.82 : ok=0 changed=0 unreachable=0 failed=1

root@fa1390b:/opt/ansible/ansible/ntc-ansible# pip list

ansible (2.0.0)
argparse (1.2.1)
chardet (2.0.1)
colorama (0.2.5)
ecdsa (0.13)
gtextfsm (0.2.1)
html5lib (0.999)
httplib2 (0.8)
Jinja2 (2.7.2)
MarkupSafe (0.18)
nelsnmp (0.2.4)
netmiko (0.2.8)
paramiko (1.16.0)
pexpect (4.0.1)
pip (1.5.4)
ply (3.8)
ptyprocess (0.5.1)
py (1.4.31)
pyasn1 (0.1.9)
pycrypto (2.6.1)
pysmi (0.0.6)
pysnmp (4.3.1)
pytest (2.8.5)
python-keyczar (0.6b)
PyYAML (3.10)
requests (2.2.1)
scp (0.10.2)
setuptools (3.3)
six (1.5.2)
ssh-import-id (3.21)
textfsm (0.2.1)
urllib3 (1.7.1)
wheel (0.24.0)
wsgiref (0.1.2)

the textfsm(0.2.1) has been installed but ntc_show_command can't find textfsm ?

this is myTest.yml

name: GET STRUCTURED DATA BACK FROM CLI DEVICES
hosts: cisco_ios
connection: local
gather_facts: False

tasks:

name: GET VLANS IN REAL TIME
ntc_show_command:
connection: ssh
platform: cisco_ios
command: "show ip bgp summary"
host: "{{ inventory_hostname }}"
username: "{{ username }}"
password: "{{ password }}"
register: result

debug: var=result.response


Reply to this email directly or view it on GitHub.

@JackFyq
Copy link

JackFyq commented Feb 16, 2016

I have found the root cause : in my environment , it's lost terminal module
so , it work fine now after pip install terminal

Thank a lot.

@iamteedoh
Copy link

I know this is old but I tried installing gtextfsm and terminal using pip. Both are already there but I still get the error:

{"changed": false, "failed": true, "msg": "This module requires TextFSM"}

Here is my pip list:

pip list
Babel (0.9.6)
cffi (1.7.0)
coverage (4.2)
cryptography (1.5)
docutils (0.11)
enum34 (1.1.6)
funcsigs (1.0.2)
functools32 (3.2.3-2)
future (0.15.2)
gtextfsm (0.2.1)
idna (2.1)
ipaddress (1.0.16)
Jinja2 (2.8)
jsonschema (2.5.1)
junos-eznc (1.3.1)
lxml (3.6.4)
MarkupSafe (0.11)
mock (2.0.0)
ncclient (0.5.2)
netaddr (0.7.18)
netmiko (0.5.6)
nose (1.3.0)
ntc-ansible (0.1.0)
paramiko (2.0.2)
pbr (1.10.0)
pip (8.1.2)
pyasn1 (0.1.9)
pycparser (2.14)
pyeapi (0.6.1)
Pygments (1.5)
pyntc (0.0.3)
pynxos (0.0.3)
PyYAML (3.12)
requests (2.11.1)
scp (0.10.2)
setuptools (26.1.1)
simplejson (3.2.0)
six (1.10.0)
Sphinx (1.1.3)
SQLAlchemy (0.7.9)
terminal (0.4.0)
textfsm (0.2.1)
virtualenv (13.1.0)
Werkzeug (0.8.3)
wheel (0.24.0)

My playbook looks like this:

---
- name: TEST2
  hosts: cisco_group
  connection: local
  gather_facts: false

  tasks:
    - name: GET SH IP INT BRIEF
      ntc_show_command:
        connection: ssh
        template_dir: /home/user/ntc-ansible/ntc-templates/templates/
        platform: cisco_ios
        command: show ip interface brief
        host: "{{ inventory_hostname }}"
        username: account
        password: passwd

I am running RHEL 6 with Python 2.7.8. I am invoking my playbook as normal like this:

ansible-playbook cisco.yml -u user -k -v

My inventory file is being derived from .ansible.cfg

@iamteedoh
Copy link

Just checking in to see if anyone has ran into the same issue I am having based on the playbook I have defined.

@haind13
Copy link

haind13 commented Jan 16, 2017

Error the same as unix4linux
I was installed gtextfsm. How to fix it?

@dirkvdplas
Copy link

i am having same error as well, while all above packages are installed. I am using RHEL 7.3 and python 2.7.12, hopefully this will be fixed soon

@tobymccann
Copy link

I am having the same issue. RHEL 7.3 and Python 2.7.13. Running in a virtualenv.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants