Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- - hosts: etcdtmp
- gather_facts: true
- connection: local
- user: remote
- become: true
- vars_prompt:
- - name: "vcenter_hostname"
- prompt: "Enter vcenter hostname"
- private: no
- default: "gs02vc01.corp.example.com"
- - name: "vcenter_username"
- prompt: "Enter vcenter username"
- private: no
- default: "username@corp.example.com"
- - name: "vcenter_password"
- prompt: "Enter vcenter password"
- private: yes
- confirm: no
- - name: "notes"
- promt: "Enter notes for new VMS"
- private: no
- default: "From Ansible"
- - name: "datacenter"
- promt: "Enter Datacenter name"
- private: no
- default: "Tampa"
- - name: "vcenter_folder"
- promt: "Enter folder name for VMS"
- private: no
- default: "k8s"
- - name: "vcenter_cluster"
- promt: "Enter cluster name"
- private: no
- default: "GS02 Cluster"
- tasks:
- - name: Clone a virtual machine from Linux template and customize
- vmware_guest:
- hostname: "{{ vcenter_hostname }}"
- username: "{{ vcenter_username }}"
- password: "{{ vcenter_password }}"
- validate_certs: no
- datacenter: "{{ datacenter }}"
- state: present
- folder: "{{ vcenter_folder }}"
- template: "{{ template }}"
- name: "{{ inventory_hostname }}"
- cluster: "{{ vcenter_cluster }}"
- networks:
- - name: "{{ peer_network }}"
- ip: "{{ peer_ip }}"
- netmask: "{{ peer_mask }}"
- gateway: "{{ peer_gw }}"
- wait_for_ip_address: True
- customization:
- domain: "{{ guest_domain }}"
- dns_servers:
- - "{{ peer_dns1 }}"
- - "{{ peer_dns2 }}"
- dns_suffix:
- - "{{ guest_domain }}"
- delegate_to: localhost
- register: vmres
- - name: Debug First
- debug:
- var: hostvars['localhost']['vmres']
- - name: add to ansible hosts file
- lineinfile:
- dest: ./inventory/hosts
- insertafter: '^\[{{ hostname_groups }}\]'
- line: '{{ item }}'
- with_items: '{{play_hosts}}'
- run_once: true
- delegate_to: localhost
- - hosts: dns
- gather_facts: yes
- vars_prompt:
- - name: "domainuser_passwd"
- prompt: "Enter domain password"
- private: yes
- tasks:
- - name: Debug result
- debug:
- var: hostvars['localhost']['vmres']
- - name: Run
- win_command: powershell.exe -
- args:
- stdin: |
- echo "{{ hostvars['localhost'] }}" >> C:\Windows\Temp\ansible.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement