ansible-collections / community.vmware

Ansible Collection for VMware
GNU General Public License v3.0
348 stars 336 forks source link

VMware: vmware_guest module does not set network for RHEL 8 template #233

Open saravananoff opened 4 years ago

saravananoff commented 4 years ago
SUMMARY

While using vmware_guest to clone RHEL 8 from template the network configuration is being ignored. Same parameters input works for RHEL 7. Even hostname as well not getting renamed.

ISSUE TYPE
COMPONENT NAME

vmware_guest.py

ANSIBLE VERSION
 ansible 2.9.6
   config file = /etc/ansible/ansible.cfg
   configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
   ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
   executable location = /usr/local/bin/ansible
   python version = 3.8.2 (default, Feb 26 2020, 14:58:38) [GCC 8.3.0]
CONFIGURATION
OS / ENVIRONMENT

Cloning VM from template using ansible vmware_guest module. Executed through Debian 10 docker container. Target Os is RHEL 8

STEPS TO REPRODUCE
Clone RHEL 8 VM from template using below task with parameters
  vmware_guest: 
    validate_certs: false
    hostname: "{{ vCenter }}"
    username: "{{ ansible_user }}"
    password: "{{ ansible_password }}"
    esxi_hostname: "{{ VirtualHost }}"
    datacenter: "{{ Datacenter }}"
    folder: "{{ VMFolder }}"
    resource_pool: "{{ ResourcePool }}"
    name: "{{ server_name }}"
    template: "{{ VMTemplate }}"
    state: poweredon
    disk: 
      - size_gb: "{{ os_disk_size }}"
        type: eagerzeroedthick
        datastore: "{{ OSDatastoreName }}"
        autoselect_datastore: false
    hardware: 
      memory_mb: "{{ memorymb }}"
      num_cpus: "{{ numcpus }}"
    networks: 
      - device_type: vmxnet3
        gateway: "{{ Gateway }}"
        ip: "{{ IPAddress }}"
        name: "{{ PortGroup }}"
        netmask: "{{ Subnet }}"
        start_connected: true
        type: static
    wait_for_ip_address: true
    customization: 
      hostname: "{{ server_name|lower }}"
      dns_servers: 
        - "{{ DNS1 }}"
        - "{{ DNS2 }}"
      dns_suffix:
        - lan.net
        - lan.com            
      Timezone: 20
  delegate_to: localhost  
EXPECTED RESULTS

VM must be configured with provided IP address and network must be connected.

ACTUAL RESULTS
Network configurations are ignored, Ip address not assigned to VM and network adapter not connected to VM (disconnected state even though stay_connected is set to true)
ChevyNovaLN commented 4 years ago

We are not experiencing the issues with RHEL8, however the difference in our template likely compared to yours, is the fact that our template has a Vmxnet3 NIC as part of the template so it doesn't need to be created. It merely changes the settings on it after deployment. Our 'networks' section of code is as simple as this and works on RHEL7 and RHEL8:

networks:
      - name: "{{ vm_port_group }}"
        ip: "{{ vm_ip }}"
        netmask: 255.255.255.0
        gateway: "{{ vm_gateway }}"
saravananoff commented 4 years ago

Hi ChevyNovaLN - Thanks for your response. Even in our template we have "VMXNET3" adaptor, we used "type" parameter in playbook to use that card(we just have only one card). Let me try without "Type"parameter and let you know.

ansibullbot commented 4 years ago

cc @Akasurde @Tomorrow9 @goneri @lparkes @nerzhul @pdellaert @pgbidkar @warthog9 click here for bot help

Akasurde commented 3 years ago

@saravananoff Could you please confirm if you are still facing this issue? Thanks.

needs_info

sanosir commented 3 years ago

hello, i am facing same issue, using vmware_guest module on ansible 2.9.2 with this playbook for network:

      networks:
      - name: "{{ vm_epg }}"
        ip: "{{ vm_ip }}"
        netmask: "{{ vm_subnet }}"
        gateway: "{{ vm_gateway }}"

try installed perl on rhel8 template, but still facing same issue.

I found something weird about this. when only have task to create vm from template without any reboot/restart task after that, like this only:

  - name: Create VM from template
    vmware_guest:
      hostname: "{{ lookup ('env', 'VMWARE_HOST' )}}"
      username: "{{ lookup ('env', 'VMWARE_USER' )}}"
      password: "{{ lookup ('env', 'VMWARE_PASSWORD' )}}"
      datacenter: "{{ datacenter }}"
      name: "{{ vm_name }}"
      state: poweredon
      networks:
      - name: "{{ vm_epg }}"
        ip: "{{ vm_ip }}"
        netmask: "{{ vm_subnet }}"
        gateway: "{{ vm_gateway }}"

success to add an IP and subnet but no gateway. either the state was present or poweredon. but after reboot (manual or ansible), the IP and subnet gone.

also try manual setup network over ssh using this command and its work:

# nmcli con mod "System ens192" ipv4.method manual ip4 <ipaddr>/<subnet23/24> gw4 <ipgateway> ipv4.dns "<dns1> <dns2> <dns3>"

then reboot vm, the config still exist.

prw9913 commented 2 years ago

Does anyone have any insight here? I'm having similar problems.
My playbook works perfectly on Linux 7 (7.9), but the networks is not adding IPs, gateways or anything network related for my Linux 8 templates.

For reference I'm using Oracle Linux 7 and 8. Oracle Linux 7 works...8 does not.

I've tried both vmware_guest and community.vmware.vmware_guest

danner26 commented 2 years ago

We are experiencing this issue with RHEL 8.4 as well. Is there any information I can provide to help diagnose the issue further?

dstephens1980 commented 2 years ago

I too am experiencing this issue. RHEL 7 will deploy fine but RHEL 8.4 will fail at setting the Network parameters. In addition RHEL 8.4 VMs created with vm_guest "that set IP" will NEVER auto-start the NIC. Some testing I have done:

RHEL8.4: Clone VM from template in vCenter - works fine Clone using vm_guest - vm clones from template and boots, just sits at the user login, at which point ansible host hangs at the setting network task for a long time, then the VM reboots and the ansible task completes, no failures indicated. Going back to the VM, it is inaccessible by SSH and vCenter shows the network as disconnected, so console login and running "ip addr" shows primary NIC is down. Now at this point I can "ifup " and it works but the "/etc/sysconfig/network-scripts/ifcfg-" distinctly has the "ONBOOT=yes" set, so manually bringing the interface up should not be necessary. Review of all relevant system logs reveals nothing, no errors. Please let me know if I can provide any more information.

martijnvdp commented 2 years ago

Hello, this could have to do with a conflict with cloud-init, you could try to disable coud init in the template and see if the ip can be set correctly

also more information can be found in : https://docs.vmware.com/en/vRealize-Automation/8.1/Using-and-Managing-Cloud-Assembly/GUID-57D5D20B-B613-4BDE-A19F-223719F0BABB.html

prw9913 commented 2 years ago

Cloud-init is not installed or running on the VM.

On Fri, May 13, 2022 at 2:38 AM Martijn van der Ploeg < @.***> wrote:

Hello, this could have to do with a conflict with cloud-init, you could try to disable coud init in the templated and see if that solves it also more information kan be found in :

https://docs.vmware.com/en/vRealize-Automation/8.1/Using-and-Managing-Cloud-Assembly/GUID-57D5D20B-B613-4BDE-A19F-223719F0BABB.html

— Reply to this email directly, view it on GitHub https://github.com/ansible-collections/community.vmware/issues/233#issuecomment-1125852456, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWGALKU2KCFDOOXKZYJKLD3VJYPIVANCNFSM4N3K7DZQ . You are receiving this because you commented.Message ID: @.***>

goneri commented 2 years ago

Are you sure the OpenVM tools (open-vm-tools) are installed in the image?

martijnvdp commented 2 years ago

if cloud init is not installed you could take a look at this kb from vmware: https://kb.vmware.com/s/article/59687 Note: This step is not required for vSphere 6.7 U3 and later.

Open the /lib/systemd/system/open-vm-tools.service file.
Add the line “After=dbus.service” under [Unit].

vmware tools needs to be running ofc

danner26 commented 2 years ago

We have tried with and without cloud-init, and open-vm-tools is installed and running correctly. We still have this issue.

pittc79 commented 2 years ago

Hi all,

I add the same issue, everything OK for RedHat 7 but failed for RedHat 8, open-vm-tools without cloud-init. I noticed an error into /var/log/vmware-imc/toolsDeployPkg.log file telling that perl module File::Temp was missing.

After adding perl-File-Temp to my template, network interface are available under RedHat 8 for new VM.

If it can help...

ironbishop commented 1 year ago

Hi, I have the same issue, and I solved dowgrading cloud-init from version 22 to version 18.5!

mehdik2023 commented 1 year ago

Same issue here, although it's working with OL8 but not RHEL8! open-vm-tools is installed and no cloud-init.

teomanS commented 1 year ago

Hi,

I also had the same issue. The Perl binary was missing in my template. I noticed that from /var/log/vmware-imc/toolsDeployPkg.log file. I installed Perl as the workaround.