Advertisement
Guest User

Ansible Example Corrected

a guest
Mar 24th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.38 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.  
  25.     - debug:
  26.         msg: "{{ output_{{X}}.stdout }}"
  27.         verbosity: 3
  28.  
  29.     - name: "Sending Email via SMTP Server"
  30.       mail:
  31.         subject: Email regarding {{ X }}
  32.         body: Here is the configuration you requested. Please refer to the attachment section of the email.
  33.         username: example@gmail.com
  34.         secure: always  
  35.         host: smtp.gmail.com
  36.         password: passwordexample
  37.         port: 587
  38.         to: example@gmail.com
  39.         from: example@gmail.com
  40.         attach: home/myname/desktop/configs/output_{{X}}.txt
  41.  
  42.   vars:
  43.     X:
  44.   - ec2_instance_inventory
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement