File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11[defaults]
22root = ~/projects/netdevops/
33inventory = ./inventory
4- stdout_callback = json
4+ stdout_callback = default
5+ callback_result_format = yaml
56result_format = yaml
67forks = 10
78timeout = 30
89gathering = explicit
910retry_files_enabled = False
1011host_key_checking = False
11- deprecation_warnings = True
12+ deprecation_warnings = False
1213log_path = ./logs/ansible.log
1314
1415[persistent_connection]
Original file line number Diff line number Diff line change 1+ all :
2+ children :
3+ consoles :
4+ vars :
5+ ansible_connection : local
6+ ansible_host : localhost
7+ telnet_user : " {{ lookup('env', 'CISCO_USER') }}"
8+ telnet_password : " {{ lookup('env', 'CISCO_PASS') }}"
9+ hosts :
10+ r1 :
11+ telnet_port : 9001
12+ r2 :
13+ telnet_port : 9002
14+ r3 :
15+ telnet_port : 9003
16+ r4 :
17+ telnet_port : 9004
18+ r5 :
19+ telnet_port : 9005
20+ r6 :
21+ telnet_port : 9006
Original file line number Diff line number Diff line change 1+ ansible_connection : ansible.netcommon.network_cli
2+ ansible_network_os : cisco.ios.ios
3+
4+ ansible_user : " {{ lookup('env', 'CISCO_USER') }}"
5+ ansible_password : " {{ lookup('env', 'CISCO_PASS') }}"
6+
7+ ansible_command_timeout : 60
8+ ansible_connect_timeout : 60
Original file line number Diff line number Diff line change 3030 hosts :
3131 sp1 :
3232 ansible_host : 10.0.0.248
33+ consoles :
34+ vars :
35+ ansible_connection : local
36+ ansible_host : localhost
37+ telnet_user : " {{ lookup('env', 'CISCO_USER') }}"
38+ telnet_password : " {{ lookup('env', 'CISCO_PASS') }}"
39+ hosts :
40+ r1 :
41+ telnet_port : 9001
42+ r2 :
43+ telnet_port : 9002
44+ r3 :
45+ telnet_port : 9003
46+ r4 :
47+ telnet_port : 9004
48+ r5 :
49+ telnet_port : 9005
50+ r6 :
51+ telnet_port : 9006
Original file line number Diff line number Diff line change 1+ - name : CML console playbook
2+ hosts : consoles
3+ gather_facts : false
4+
5+ tasks :
6+ - name : Run commands through an existing or new console session
7+ ansible.builtin.expect :
8+ command : " telnet {{ ansible_host }} {{ telnet_port }}"
9+ timeout : 10
10+ echo : false
11+ responses :
12+ " (?i)Escape character is \\'\\^\\]\\'\\.\\s*$ " : " \r "
13+
14+ ' (?i)Username:\s*$ ' : " {{ telnet_user }}"
15+ ' (?i)Password:\s*$ ' : " {{ telnet_password }}"
16+
17+ # Exit the local Telnet client cleanly.
18+ ' (?i)telnet>\s*$ ' : " quit"
19+
20+ " (?i)Press RETURN to get started\\. " : " \u001d "
21+
22+ # Each successive IOS prompt sends the next response.
23+ ' (?m)^(?!telnet>)[^\r\n]*[>#]\s*$ ' :
24+ - " terminal length 0"
25+ - " show clock"
26+ - " show version | include uptime"
27+ - " show ip interface brief"
28+ # - "exit\r\n\u001dquit\r"
29+ - " exit"
30+ - " \u001d "
31+ register : out
32+ changed_when : false
33+ delegate_to : localhost
34+ vars :
35+ ansible_python_interpreter : " {{ ansible_playbook_python }}"
36+
37+ - name : Results
38+ ansible.builtin.debug :
39+ msg : " {{ out.stdout | replace('\\ '', '') }}"
Original file line number Diff line number Diff line change 11---
2- - hosts : default
2+ - hosts : consoles
33 gather_facts : no
44
55 tasks :
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ dependencies = [
88 " ansible>=11.9.0" ,
99 " ansible-pylibssh>=1.2.2" ,
1010 " paramiko>=4.0.0" ,
11+ " pexpect>=4.9.0" ,
1112 " pyats[full]>=25.7" ,
1213 " python-dotenv>=1.1.1" ,
1314]
You can’t perform that action at this time.
0 commit comments