Last active
July 11, 2020 21:24
-
-
Save gainskills/20b6920d536a94de484ad073a06ef7d8 to your computer and use it in GitHub Desktop.
Sample about Ansible telnet
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
#telnet part1 | |
ansible-playbook -i inventory_telnet.yml pb_telnet.yml | |
#Telnet Part2 | |
ansible-playbook -i inventory_telnet.yml --vault-id test@prompt pb_telnet.yml | |
#SSH | |
ansible-playbook -i inventory_ssh.yml pb_first.yml | |
ansible-playbook -i inventory_ssh.yml --vault-id test@prompt pb_first.yml |
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
--- | |
telnet: | |
hosts: | |
sw1: | |
ansible_host: "192.168.1.100" | |
connection: local | |
ansible_ssh_user: test | |
ansible_ssh_pass: !vault | | |
$ANSIBLE_VAULT;1.2;AES256;test | |
63386332356237643731346539336262336231343432313963376438653933323737636535383365 | |
3562383633646261653739343536386566323462323063320a613638373439363032353137343330 | |
34306264613932323832373532636230323730626239393564326564303563356666343734633135 | |
6664373266663238660a363666336661353364393437356433616462346331313537623430393861 | |
3536 | |
ansible_ssh_timeout: 2 | |
ansible_ssh_port: 23 |
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
--- | |
netconf: | |
hosts: | |
netconfIos: | |
ansible_host: "172.16.254.100" | |
ansible_network_os: "ios" | |
ansible_ssh_port: 22 | |
netconfJunos: | |
ansible_host: "172.16.254.9" | |
ansible_network_os: "junos" | |
ansible_ssh_port: 830 | |
vars: | |
ansible_connection: "netconf" | |
ansible_ssh_user: test | |
ansible_ssh_pass: test123 |
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
--- | |
user: | |
hosts: | |
user_R: | |
ansible_host: "192.168.1.97" | |
vars: | |
ansible_network_os: "ios" | |
ansible_ssh_user: test | |
ansible_ssh_pass: test123 | |
pubkeynopass: | |
hosts: | |
pubkeynopass_R: | |
ansible_host: "192.168.1.98" | |
vars: | |
ansible_network_os: "ios" | |
ansible_ssh_user: sshpubkey | |
ansible_ssh_private_key_file: '/Users/kz/Documents/SSH/tmp/id_rsa_nokey' | |
pubkeypass: | |
hosts: | |
pubkeypass_R: | |
ansible_host: "192.168.1.99" | |
vars: | |
ansible_network_os: "ios" | |
ansible_ssh_user: sshpubkeypass | |
ansible_ssh_private_key_file: /Users/kz/Documents/SSH/tmp/id_rsa_pass | |
ansible_ssh_pass: test123 |
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
--- | |
telnet: | |
hosts: | |
sw1: | |
ansible_host: "192.168.1.100" |
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
--- | |
telnet: | |
hosts: | |
sw1: | |
ansible_host: "192.168.1.100" | |
connection: local | |
ansible_ssh_user: test | |
ansible_ssh_pass: test123 | |
ansible_ssh_timeout: 2 | |
ansible_ssh_port: 23 |
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
--- | |
- name: show version | |
hosts: telnet | |
gather_facts: false | |
# connection: local | |
tasks: | |
- name: CM via telnet | |
telnet: | |
login_prompt: "Username: " | |
prompts: | |
- '[>|#]' | |
command: | |
- terminal length 0 | |
- show version |
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
--- | |
- name: show version | |
hosts: telnet | |
gather_facts: false | |
# connection: local | |
tasks: | |
- name: CM via telnet | |
telnet: | |
login_prompt: "Username: " | |
prompts: | |
- '[>#]' | |
command: | |
- terminal length 0 | |
- show version | include uptime | |
- show version | include Processor board ID | |
- exit |
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
--- | |
- name: ssh username/password | |
connection: network_cli | |
hosts: user | |
become_method: enable | |
tasks: | |
- name: Get config for IOS devices | |
ios_facts: | |
gather_subset: all | |
- name: Display the config | |
debug: | |
msg: "The hostname is {{ ansible_net_hostname }} and the OS is {{ ansible_net_version }}" | |
- name: ssh username/keyWithoutPassword | |
connection: network_cli | |
hosts: pubkeynopass | |
become_method: enable | |
tasks: | |
- name: Get config for IOS devices | |
ios_facts: | |
gather_subset: all | |
- name: Display the config | |
debug: | |
msg: "The hostname is {{ ansible_net_hostname }} and the OS is {{ ansible_net_version }}" | |
- name: ssh username/keyWithPassword | |
connection: network_cli | |
hosts: pubkeypass | |
become_method: enable | |
tasks: | |
- name: Get config for IOS devices | |
ios_facts: | |
gather_subset: all | |
- name: Display the config | |
debug: | |
msg: "The hostname is {{ ansible_net_hostname }} and the OS is {{ ansible_net_version }}" |
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
--- | |
- name: IOS | |
hosts: netconfIos | |
gather_facts: false | |
tasks: | |
- name: Get config for IOS devices | |
netconf_get: | |
source: running | |
register: iosnetconf | |
- name: Display output | |
debug: | |
msg: "{{ iosnetconf.stdout }}" |
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
--- | |
- name: show version | |
hosts: telnet | |
gather_facts: false | |
connection: local | |
tasks: | |
- name: telnet sw | |
telnet: | |
user: test | |
password: test123 | |
login_prompt: "Username: " | |
prompts: | |
- '[>|#]' | |
command: | |
- terminal length 0 | |
- show version |
Hi Guys,
How i get the output from show version via Telnet?
Best Regards.
Please try to follow this: https://blog.gainskills.top/2018/09/04/ansible-access-network-via-telnet/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Guys,
How i get the output from show version via Telnet?
Best Regards.