-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b8cd26
commit 64c5b1b
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
|
||
# This Playbook will build the correct *.parsed file, based on the *.raw file. The presumption is you are running the playbook from the helpers folder, and it will find the correct test path. | ||
# You can set extra vars for root_directory, os, command, and num ( which is a way to differentiate when you have multiple tests) | ||
|
||
# Example command below, makes use of localhost, | ||
# ansible-playbook -i localhost, create-parsed.yml --extra-vars="os=cisco_ios command='show mac-address-table'" | ||
|
||
# Use number to differentiate raw and parsed files | ||
# ansible-playbook -i localhost, create-parsed.yml --extra-vars="os=cisco_ios command='show mac-address-table' num=3" | ||
|
||
# With library and python interperter set | ||
# ansible-playbook -i localhost, create-parsed.yml --extra-vars="os=cisco_ios command='show ip bgp' ansible_python_interpreter=python" -M "/etc/modules/library" | ||
|
||
- name: CREATE PARSED FILE FOR NTC TEMPLATES | ||
hosts: localhost | ||
gather_facts: no | ||
connection: local | ||
|
||
tasks: | ||
|
||
- name: SET FACT FOR COMMAND | ||
set_fact: | ||
command_dash: "{{ command | regex_replace(' ', '_')}}" | ||
|
||
- name: SET FACT FOR ROOT DIR | ||
set_fact: | ||
root_directory: "{{ root_dir | default('..') }}" | ||
|
||
- name: OFFLINE NTC SHOW COMMAND | ||
ntc_show_command: | ||
connection: "offline" | ||
file: "{{ root_directory }}/tests/{{ os }}/{{ command_dash }}/{{ os }}_{{ command_dash}}{{ num | default('') }}.raw" | ||
platform: '{{ os }}' | ||
command: '{{ command }}' | ||
template_dir: '{{ root_directory }}/templates/' | ||
register: "value" | ||
|
||
- name: DISPLAY IN JSON VALUES | ||
debug: | ||
var: "value" | ||
|
||
- name: BUILD YAML FILE PARSED OUTPUT | ||
template: | ||
src: "./make-parsed.j2" | ||
dest: "{{ root_directory }}/tests/{{ os }}/{{ command_dash }}/{{ os }}_{{ command_dash}}{{ num | default('') }}.parsed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
parsed_sample: | ||
|
||
{{ value.get('response') | to_nice_yaml }} |