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

add # of successful matches to verbose output of textfsm and text_parser #60

Open
2 tasks
acozine opened this issue May 1, 2018 · 0 comments
Open
2 tasks

Comments

@acozine
Copy link
Contributor

acozine commented May 1, 2018

As a user, If I make a mistake in a matching directive or in the content: parameter, I may end up with one or more null values in the final variable output. For example, this playbook:

---
- hosts: ios
  connection: network_cli
  gather_facts: no

  tasks:
  - name: Collect version information from device
    ios_command:
      commands: "show version"
    register: ios_version_output

  - import_role:
      name: ansible-network.network-engine

  - name: Generate version facts as JSON
    text_parser:
      file: "my_parsers/ios_show_version.yaml"
      content: ios_version_output['stdout_lines'][0]
#  in case anyone find this while looking for a *correct* example
#  the correct formulation would be 
# content: "{{ ios_version_output.stdout.0 }}"

  - name: Display matches (system_facts)
    debug:
      var: system_facts 

succeeds, but returns this final variable:

ok: [ios01] => {
    "system_facts": {
        "image_file": null, 
        "memory": {
            "free": null, 
            "total": null
        }, 
        "model": null, 
        "uptime": null, 
        "version": "null"
    }
}

The error in this example is in the content line, but a similar situation could occur if one or more match rules were incorrect. If I run the playbook with -vvvv I can see the directives:

processing directive: match version
processing directive: match model
processing directive: match image
processing directive: match uptime
processing directive: match total memory
processing directive: match free memory
processing directive: export system facts to playbook

but there's no information about which ones find matches.

To help debug issues with content lines and issues with match definitions, could we:

  • add "found match" or "no match" to verbose output for each directive processed
  • add information on total matches (for example, "7 matches found out of 8 match directives processed" - I'm not sure what level of verbosity should be required for this
trishnaguha pushed a commit to trishnaguha/network-engine that referenced this issue Feb 5, 2019
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

3 participants