specify a host in each task.

28 views
Skip to first unread message

blue fox

unread,
Nov 21, 2020, 3:32:39 AM11/21/20
to Ansible Project
Hello ,

how I can specify a host in each task.

Thank you

Dick Visser

unread,
Nov 21, 2020, 5:23:49 AM11/21/20
to ansible...@googlegroups.com
Please explain a bit more why what etc
And share a playbook 

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/98965131-1426-4e91-8537-01bdee198e4bn%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.
Message has been deleted

Roberto Paz

unread,
Nov 21, 2020, 10:54:53 AM11/21/20
to Ansible Project
I didn't tested, but maybe adding somethine like this?

- lineinfile:
      path: path_to_localLogfile
      insertafter: EOF
      line:  '{{ vm_IP }}'  
      create: yes
   delegate_to: localhost

(Assuming you want to save the info stored in '{{ vm_IP }}' to a localfile
El sábado, 21 de noviembre de 2020 a la(s) 06:37:56 UTC-6, foxb...@gmail.com escribió:
i want to copy ip address of VM in local file (localhost)

- hosts: localhost

  gather_facts: false

  vars_files:

    - vars.yml

  tasks:

    - name: provisioning vm

      vmware_guest:

        hostname: '{{ vsphere_hostname }}'

        username: '{{ vsphere_username }}'

        password: '{{ vsphere_password }}'

        validate_certs: no

        datacenter: '{{ vsphere_datacenter }}'

        cluster: '{{ vsphere_cluster }}'

        folder: '{{ vsphere_folder }}'

        name: "{{ inventory_hostname }}"

        state: poweredon

        guest_id: '{{ vm_id }}'

        template: '{{ vm_template }}'

        networks:

        - name: '{{ vm_network_US }}'

          ip: '{{ vm_IP }}'

          netmask: '{{ vm_netmask}}'

          gateway: '{{ vm_gateway}}'

          dns_servers: '{{ vm_dns }}'

          start_connected: yes

          connected: yes

        wait_for_ip_address: yes

        state: poweredon

      delegate_to: localhost

      register: vm



 

blue fox

unread,
Nov 21, 2020, 8:56:05 PM11/21/20
to Ansible Project
he working :)
Thank you
Reply all
Reply to author
Forward
0 new messages