Advertisement
Guest User

ansible

a guest
Aug 10th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. ---
  2. - hosts: localhost
  3. gather_facts: false
  4. connection: local
  5. vars_prompt:
  6. - name: "vcenter_hostname"
  7. prompt: "Enter vcenter hostname"
  8. private: no
  9. default: "slc-vcenter01.internal.nwresearch.com"
  10. - name: "vcenter_user"
  11. prompt: "Enter vcenter username"
  12. private: no
  13. - name: "vcenter_pass"
  14. prompt: "Enter vcenter password"
  15. private: yes
  16. vars:
  17. guest_password:
  18.  
  19. tasks:
  20. - name: including hostnames
  21. include_vars: /opt/git/devops/hostnames_for_vmware.yml
  22.  
  23. - name: Gather VM facts
  24. vmware_guest:
  25. validate_certs: false
  26. vcenter_hostname: "{{ vcenter_hostname }}"
  27. username: "{{ vcenter_user }}"
  28. password: "{{ vcenter_pass }}"
  29. guest: "{{ hostnames }}"
  30. vmware_guest_facts: yes
  31. register: vars
  32. - add_host: name="{{ hostnames }}" ansible_ssh_host="{{var.ansible_facts.hw_eth0.ipaddresses[0]}}" ansible_ssh_pass="{{guest_password}}" groups=dynamic_hosts
  33.  
  34. - hosts: dynamic_hosts
  35. tasks:
  36. - name: move over public key
  37. command: authorized_key user=root key="{{ lookup('file', '~/.ssh/id_rsa') }}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement