To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0e2c7491-cd53-4d07-8b20-c6870c600fc4%40googlegroups.com.--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
"It may be useful to use a playbook locally, rather than by connecting over SSH. This can be useful for assuring the configuration of a system by putting a playbook in a crontab. This may also be used to run a playbook inside an OS installer, such as an Anaconda kickstart.
To run an entire playbook locally, just set the “hosts:” line to “hosts: 127.0.0.1” and then run the playbook like so:
ansible-playbook playbook.yml --connection=local
Alternatively, a local connection can be used in a single playbook play, even if other plays in the playbook use the default remote connection type:
- hosts: 127.0.0.1 connection: local
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6383da04-b68b-4a33-85e9-87318eb0a5b8%40googlegroups.com.To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
---
- hosts: cisco
connection: local
gather_facts: False
ignore_errors: yes
vars:
cli:
host: "{{ host }}"
username: "{{ username }}"
password: "{{ password }}"
tasks:
- name: Gather NX-OS Facts
ios_facts:
provider: "{{ cli }}"
register: facts_output
- debug: var=facts_output
- debug: var=facts_output.ansible_facts.ansible_net_version
- local_action: copy content="{{ facts_output }}" dest="./{{ inventory_hostname }}.txt"
TASK [debug] ********************************************************************************************************************************************************
ok: [arctic-3650] => {
"facts_output.ansible_facts.ansible_net_version": "03.06.06E"
}
TASK [debug] ********************************************************************************************************************************************************
ok: [arctic-3650] => {
"output.results[0].item": "show version"
}
TASK [debug] ********************************************************************************************************************************************************
ok: [arctic-3650] => {
To become bigger person,need to walk with bigger Vision !!!!
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/826a69bb-d730-48f6-a7ce-103808c1f0f0%40googlegroups.com.--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/Ul5D-gAzRrg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
"ansible_facts": {
"ansible_net_all_ipv4_addresses": [
"10.1.10.25",
"192.0.2.33"
],
"ansible_net_all_ipv6_addresses": [],
"ansible_net_filesystems": [
"flash:"
],
tasks:
- name: Gather IOS Facts
ios_facts:
debug: var=facts_output.ansible_facts.ansible_net_version
root@e8d7daa45b5b:/ansible/ansible2_4_base# ansible-playbook -i hosts get_ios_cmd_filter.yml
PLAY [cisco] ********************************************************************************************************************************************************
TASK [Show command with embedded regexp inc connected for all Conneced interfaces] **********************************************************************************
ok: [arctic-3650] => (item=show int status | inc connected)
TASK [debug] ********************************************************************************************************************************************************
ok: [arctic-3650] => {
"output.results[0].stdout_lines": [
[
"Gi1/0/4 connected 1 a-full a-1000 10/100/1000BaseTX"
]
]
}
TASK [Show command with embedded regexp for all IPs] ****************************************************************************************************************
ok: [arctic-3650] => (item=show ip interface brief | inc \.[0-9]+[ ]+YES)
TASK [debug] ********************************************************************************************************************************************************
ok: [arctic-3650] => {
"output.results[0].stdout_lines": [
[
"Vlan1 192.0.2.33 YES manual up up ",
"GigabitEthernet0/0 10.1.10.25 YES DHCP up up"
]
]
}
PLAY RECAP **********************************************************************************************************************************************************
arctic-3650 : ok=4 changed=0 unreachable=0 failed=0
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BpLPDTaTE0o3NWOp00je5ZiRTMveL4z3MTTPuiU6%2Bemv6v6%3DQ%40mail.gmail.com.
To become bigger person,need to walk with bigger Vision !!!!
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAENRZgbhS%2Bu3PBLns78nBHo-C86p%2BoVQoWS96czJGfT80PJBbA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BpLPDRcKXtd_CZHJxu%3D8VPMu91iTaZgpZPV58ctan-He81nTw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAENRZgbiyZR5mz9%2BLZsHHSykXK%2Bh_g_ggimm2%2BxZHurGYONgkg%40mail.gmail.com.
To become bigger person,need to walk with bigger Vision !!!!
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAENRZgbiyZR5mz9%2BLZsHHSykXK%2Bh_g_ggimm2%2BxZHurGYONgkg%40mail.gmail.com.
# Make sure we have files to process (at least 1)
if len(file_list) > 0:
# Open the CSV file to store results
csv_results_fh = open_file(results_dir, 'wb')
csv_writer = csv.writer(csv_results_fh, quoting=csv.QUOTE_MINIMAL)
# Iterate through the valid file list. If the script was passed a filename it will be a file_list of 1
# If the script was passed a directory it will be a list of files with a valid extension
for fil in file_list:
print("Processing device file: " + fil)
# open_file function returns a file handle
fh = open_file(fil, 'r')
# Read the file contents into a variable for parsing
file_contents = fh.read()
# Close file
fh.close()
# Send TextFSM Template name and data to parse to text_fsm_parsing function
# file_results returns the parsed results and table returns the header
fil_results, table = text_fsm_parse(textfsm_template, file_contents)
print("file results of lenght {} from text_fsm_parse:\n{}".format(str(len(fil_results)),fil_results[1]))
# Append fil_results list of results to list of all results
fsm_all_results.append(fil_results)
# Keep track of files without parser output in the no_output list so it can be printed later
if len(fil_results) == 0:
no_output.append(fil)
# Write the header row in the CSV file
if table:
csv_writer.writerow(table.header)
else:
sys.exit("Parsing Error. Execution aborted.")
# Write each row in the fsm_all_results list to the CSV file
for re_row in fsm_all_results:
for single_row in re_row:
csv_writer.writerow(single_row)
# print(single_row)
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/826a69bb-d730-48f6-a7ce-103808c1f0f0%40googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/Ul5D-gAzRrg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BpLPDTaTE0o3NWOp00je5ZiRTMveL4z3MTTPuiU6%2Bemv6v6%3DQ%40mail.gmail.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/Ul5D-gAzRrg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAENRZgbhS%2Bu3PBLns78nBHo-C86p%2BoVQoWS96czJGfT80PJBbA%40mail.gmail.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/Ul5D-gAzRrg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BpLPDRcKXtd_CZHJxu%3D8VPMu91iTaZgpZPV58ctan-He81nTw%40mail.gmail.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/Ul5D-gAzRrg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/77eca948-46c4-4acf-ba10-d46420a39317%40googlegroups.com.
MGMT_IP | HOSTNAME | MODEL | VERSION | IMAGE |
1.1.1.1 | R1 | 3725 (R7000) processor | 12.4(15)T14 | tftp://255.255.255.255/unknown |
2.2.2.2 | R2 | 3725 (R7000) processor | 12.4(15)T14 | tftp://255.255.255.255/unknown |
3.3.3.3 | R3 | 3725 (R7000) processor | 12.4(15)T14 | tftp://255.255.255.255/unknown |
4.4.4.4 | R4 | 3725 (R7000) processor | 12.4(15)T14 | tftp://255.255.255.255/unknown |
5.5.5.5 | router_r5 | 3725 (R7000) processor | 12.4(15)T14 | tftp://255.255.255.255/unknown |
6.6.6.6 | R6 | 3725 (R7000) processor | 12.4(15)T14 | tftp://255.255.255.255/unknown |
7.7.7.7 | R7 | 3725 (R7000) processor | 12.4(15)T14 | tftp://255.255.255.255/unknown |
8.8.8.8 | router_r8 | 3725 (R7000) processor | 12.4(15)T14 | tftp://255.255.255.255/unknown |
To become bigger person,need to walk with bigger Vision !!!!