Hi Team,

I have created sh running config getting output but have 150 routers but it 
triggered one notepad text it include all config output any chance to get 
trigger each host name with each text output.

Regards,

S.Manivannan










On Friday, September 30, 2016 at 3:25:22 PM UTC-7, Jimbo wrote:
>
> I am relatively knew to ansible and need a little assistance. We are 
> trying to use ansible to backup our Cisco configuration. I figured that 
> this would be fairly simple and I have made some progress but I am stuck at 
> the moment.
>
> I want to be able to run this playbook and have it output the 
> configuration of the cisco router to a simple text file on the ansible 
> server. The file name needs to be the current time when it ran in the 
> format MMDDYYYY. I want to deposit the file in a folder that is the 
> hostname of the switch defined in the inventory file.
>
> I can get the playbook to run when I use the hostname for the file name 
> and do not include the directory based on hostname, but the timestamp from 
> the ansible server is failing due to the length of the filename being to 
> long. Also the text of the configuration file is devoid of formatting so it 
> is in a single line with quotation around each entry from the config. Here 
> is a snippet from the file output:
>
> {"changed": false, "cisco.stdout_lines": [["Building configuration...", 
> "", "Current configuration : 3389 bytes", "!", "version 12.2", "no service 
> pad",
>
> So the items I need help with are:
>
>    1. Format the show run so that we can use it for a copy paste restore 
>    at some point
>    2. Attach the local timestamp to the filename
>    3. Attach the hostname to the folder that the backup is placed
>
> Running ansible 2.1.2
>
> Here is my playbook so far (or what I thought would work)...
> =================================================================
> ---
> - hosts: switches
>   connection: local
>   vars:
>     cli:
>       host: "{{ inventory_hostname }}"
>       username: circle
>       password: Circle86
>       transport: cli
>       backup: yes
>   tasks:
>     - name: timestamp
>       local_action: command date +%Y%m%d
>       register: timestamp
>
>     - name: run show running-config on remote devices
>       ios_command:
>         commands: show running
>         provider: "{{ cli }}"
>       register: cisco
>       
>     - name: debug
>       debug:
>         var: cisco.stdout_lines
>       register: debug
>       
>     - copy: content={{ debug }} 
> dest=/home/james/ansible/Cisco/test3/backups/{{ inventory_hostname }}/{{ 
> timestamp }}
>
> =============================================================================================
>
> While I know there are other methods of doing this through SCP or FTP and 
> the archive command on cisco, we are trying to keep this centralized within 
> Ansible since we manage many linux servers from there as well.
>
> Thoughts?
>
> Thanks
>

-- 
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+unsubscr...@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/affb2fd7-0d69-4c75-9b2b-d0d51236369c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to