Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.00 KB | None | 0 0
  1. ##################
  2. #### PLAYBOOK ####
  3. ##################
  4. ---
  5.  
  6. - hosts: localhost
  7.   gather_facts: False
  8.   vars:
  9.     db_instances:
  10.       - { name: "ferrari", dns: "www.ferrari.com" }
  11.       - { name: "yahoo", dns: "www.yahoo.com" }
  12.       - { name: "microsoft", dns: "www.microsoft.com" }
  13.   tasks:
  14.     - name: dig each host
  15.       command: dig +short CNAME {{ item.dns }}
  16.       with_items: "{{ db_instances }}"
  17.       register: db_cnames
  18.  
  19.     - name: Print cname_record_sets values
  20.       debug:
  21.         var: item.stdout
  22.       loop: '{{db_cnames.results}}'
  23.  
  24.     - name: template file
  25.       template:
  26.         src: '{{playbook_dir}}/before.txt'
  27.         dest: '{{playbook_dir}}/after.txt'
  28.  
  29. ##############
  30. # before.txt #
  31. ##############
  32.  
  33. {% for item in db_cnames.results %}
  34.   - server: {{ item.stdout }}
  35. {% endfor %}
  36.  
  37. #############
  38. # after.txt #
  39. #############
  40.  
  41.   - server: dkehzmrflhws1.cloudfront.net.
  42.   - server: atsv2-fp.wg1.b.yahoo.com.
  43.   - server: www.microsoft.com-c-3.edgekey.net.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement