Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29245

Backup of a Cisco Router 1000v on Amazon Web Services with Ansible

$
0
0

I try to copy the configuration of a CSR Router on AWS by using Ansible on a debian-VM. I can log in on the router via ssh.

To check the connection to the router I run the following Ansible command on the VM,

ansible CSR_Routers -m raw -a "show clock" -vvv

and get the following output:

ansible 2.9.7  config file = /etc/ansible/ansible.cfg  configured module search path = [u'/home/usr/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']  ansible python module location = /usr/lib/python2.7/dist-packages/ansible  executable location = /usr/bin/ansible  python version = 2.7.16 (default, Oct 10 2019, 22:02:15) [GCC 8.3.0]Using /etc/ansible/ansible.cfg as config filehost_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() methodscript declined parsing /etc/ansible/hosts as it did not pass its verify_file() methodauto declined parsing /etc/ansible/hosts as it did not pass its verify_file() methodParsed /etc/ansible/hosts inventory source with ini pluginMETA: ran handlers<my-ec2-public-dns> ESTABLISH SSH CONNECTION FOR USER: ec2-user<my-ec2-public-dns> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/usr/ssh-key-pair.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="ec2-user"' -o ConnectTimeout=10 -o ControlPath=/home/usr/.ansible/cp/8eab188f0e -tt my-ec2-public-dns 'show clock'<my-ec2-public-dns> (0, '\r\n\r\n\r\n*11:36:11.637 UTC Tue May 5 2020', 'Shared connection to my-ec2-public-dns closed.\r\n')CSR-01 | CHANGED | rc=0 >>*11:36:11.637 UTC Tue May 5 2020Shared connection to my-ec2-public-dns closed.

My configuration looks like:

hosts:

[CSR_Routers]CSR-01 ansible_host=my-ec2-public-dns ansible_connection=ssh ansible_ssh_user=ec2-user ansible_ssh_private_key_file=/home/usr/ssh-key-pair.pem

playbook:

---- hosts: CSR-01  gather_facts: true  connection: ssh  tasks:   - name: show run     ios_command:       commands:         - show run       host: "{{ ansible_host }}"       username: ec2-user     register: config   - name: save output to /etc/ansible/backups     copy:       content: "{{ config.stdout[0] }}"       dest: "/etc/ansible/backups/show_run_{{ inventory_hostname }}.txt"

Unfortunately, when I run my Ansible Playbook, I get the following error:

PLAY [CSR-01] **************************************************************************************************************************************************TASK [Gathering Facts] *****************************************************************************************************************************************[WARNING]: Unhandled error in Python interpreter discovery for host CSR-01: unexpected output from Python interpreter discovery[WARNING]: sftp transfer mechanism failed on [my-ec2-public-dns]. Use ANSIBLE_DEBUG=1 to see detailed informationfatal: [CSR-01]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"setup": {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "failed": true, "module_stderr": "Shared connection to my-ec2-public-dns closed.\r\n", "module_stdout": "\r\n\r\n\r\nLine has invalid autocommand \"/bin/sh -c '/usr/bin/python '\"'\"'Line has invalid autocommand \"/bin/sh -c '\"'\"'\"'\"'\"'\"'\"'\"'( umask 77 && mkdir -p \"` echo Line has invalid autocommand \"/bin/sh -c '\"'\"'\"'\"'\"'\"'\"'\"'\"'\"'\"'\"'\"'\"'\"'\"'\"'\"'\"'\"'\"'\"'\"'\"'\"'\"'echo ~ec2-user && sleep 0'\"'\"'\"'\"'\"'\"'\"\"", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 0, "warnings": ["Platform unknown on host CSR-01 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information."]}}, "msg": "The following modules failed to execute: setup\n"}PLAY RECAP *****************************************************************************************************************************************************CSR-01                     : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

On the one hand I see the error "Unhandled error in Python interpreter discovery for host CSR-01" and on the other hand the error "sftp transfer mechanism failed on [my-ec2-public-dns]"

is my playbook correct? how can I fix these errors so my playbook runs?


Viewing all articles
Browse latest Browse all 29245

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>