ansible-network / network-engine

This role provides the foundation for building network roles by providing modules and plugins that are common to all Ansible Network roles.
GNU General Public License v3.0
112 stars 52 forks source link

No example how to use textfsm with network-engine. #200

Closed jwoogee closed 5 years ago

jwoogee commented 5 years ago

ISSUE TYPE

ANSIBLE VERSION

ansible --version
ansible 2.7.0
  config file = /Users/z003gn3/ansible_config/ansible.cfg
  configured module search path = [u'/Users/z003gn3/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/z003gn3/virtualenvs/venv_lan_ansible/lib/python2.7/site-packages/ansible
  executable location = /Users/z003gn3/virtualenvs/venv_lan_ansible/bin/ansible
  python version = 2.7.10 (default, Oct  6 2017, 22:29:07) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]

ansible-galaxy list | grep ansible.network

- ansible-network.network-engine, v2.7.0
- ansible-network.cisco_ios, v2.6.2

Network OS

SUMMARY

I'm trying to use a textfsm template with network-engine to populate ansible_facts. I cannot find documentation how to supply the fact name to supply, and the facts are not showing in ansible_facts.

I added show_interfaces_status.template to parser_templates/cli folder. I'm just not sure how to register that json dictionary now.

STEPS TO REPRODUCE


# I added this to vars/get_facts_command_map.yaml
- command: show interfaces status
  parser: show_interfaces_status.template
  groups:
    - all
    - default
  engine: textfsm_parser

EXPECTED RESULTS

I expect ansible facts to be populated.

ACTUAL RESULTS

command runs without issue, but ansible_facts aren't updated. It's pretty clear I'm not setting the facts through the course of this, but I don't know how I'm supposed to using textfsm vs command_parser.

trishnaguha commented 5 years ago

@jwoogee Hi, your playbook is not explicit enough to understand what module you are using. Will you please add the information? We do have docs how to use the parsers https://github.com/ansible-network/network-engine/tree/devel/docs/user_guide

textfsm_parser needs an argument called name to have ansible_facts generated https://github.com/ansible-network/network-engine/blob/devel/docs/user_guide/textfsm_parser.md#sample-playbooks

jwoogee commented 5 years ago

sorry, I’m using the ansible-network.cisco-ios role to attempt this. Maybe this needs to be posed on a different github page? I do understand how to call textfsm directly, but with the get_fact section of the Cisco iOS role it gives the option to use different parser templates to fine tune what facts you get, but it doesn’t explain how to use textfsm in this way, although they say you can.

Thank you,

On Wed, Nov 21, 2018 at 10:02 PM Trishna Guha notifications@github.com wrote:

@jwoogee https://github.com/jwoogee what module are you using? textfsm_parser needs an argument called name to have ansible_facts generated https://github.com/ansible-network/network-engine/blob/devel/docs/user_guide/textfsm_parser.md#sample-playbooks

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ansible-network/network-engine/issues/200#issuecomment-440906244, or mute the thread https://github.com/notifications/unsubscribe-auth/AZrdK-z-3FS7YGqtoLigRP1vEV4m6IyLks5uxiHGgaJpZM4Ytr2Q .

-- Jonathon Woods

jwoogee commented 5 years ago

I found the issue, the ansible-network.cisco_ios role doesn't have a spot to use name for textfsm templates, and the cli module in ansible-network.network-engine doesn't take name and use it either, so as far as I can see you can't use textfsm in the way the ciso_ios role expects. I can submit a PR with my changes that made it work for me.

trishnaguha commented 5 years ago

Thanks for the details. This needs to be fixed in cli action plugin instead. I will open a PR when the fix is ready.

jwoogee commented 5 years ago

Thanks! I created a PR for what works for me, and in Network-engine, that was editing the cli action plugin. It’s PR #202.

On Fri, Nov 23, 2018 at 11:05 PM Trishna Guha notifications@github.com wrote:

Thanks for the details. This needs to be fixed in cli action plugin instead. I will open a PR when the fix is ready.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ansible-network/network-engine/issues/200#issuecomment-441344112, or mute the thread https://github.com/notifications/unsubscribe-auth/AZrdK1KMdQ7QXrKOvXvcc0vO4Qj64-x8ks5uyNN9gaJpZM4Ytr2Q .

-- Jonathon Woods

trishnaguha commented 5 years ago

resolved by pr https://github.com/ansible-network/network-engine/pull/202 and https://github.com/ansible-network/network-engine/pull/205