Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.33 KB | None | 0 0
  1. ---
  2. #Please be careful with this script, as it is very sensitive to formatting. Please use caution and backup before editing.
  3. #Script is designed to pull information for a customer on a cisco ios device and send it to a corporate contact via email who can then forward it over
  4.  
  5. #DIAGNOSTICS AND GENERAL DEVICE INFORMATION POLL PLAYBOOK
  6. - hosts: "ec2-54-92-152-183.compute-1.amazonaws.com"
  7.   gather_facts: false
  8.   connection: network_cli
  9.   become: yes
  10.  
  11.   tasks:
  12.     - name: Information Discovery on Cisco IOS Device
  13.       ios_command:
  14.         commands:
  15.          - "show run"
  16.           - "show license"
  17.           - "show inventory"
  18.           - "show tech-support"
  19.         become: yes
  20.         retries: 10
  21.         interval: 1
  22.         match: any  
  23.       register: output_{{X}}
  24.       debug:
  25.         msg: "{{ output_{{X}}.stdout }}"
  26.         verbosity: 3
  27.  
  28. - name: "Sending Email via SMTP Server"
  29.   mail:
  30.     subject: Email regarding {{ X }}
  31.     body: Here is the configuration you requested. Please refer to the attachment section of the email.
  32.     username: example@gmail.com
  33.     secure: always  
  34.     host: smtp.gmail.com
  35.     password: passwordexample
  36.     port: 587
  37.     to: example@gmail.com
  38.     from: example@gmail.com
  39.     attach: home/myname/desktop/configs/output_{{X}}.txt
  40.  
  41.   vars:
  42.     X:
  43.      - ec2_instance_inventory
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement