<commit_before>.. _vmware_troubleshooting:

**********************************
Troubleshooting Ansible for VMware
**********************************

.. contents:: Topics

This section lists things that can go wrong and possible ways to fix them.

Debugging
=========

When debugging or creating a new issue, you will need information about your VMware infrastructure. You can get this information using
`govc <https://github.com/vmware/govmomi/tree/master/govc>`_, For example:


.. code-block:: bash

    $ export GOVC_USERNAME=ESXI_OR_VCENTER_USERNAME
    $ export GOVC_PASSWORD=<PASSWORD>
    $ export GOVC_URL=https://ESXI_OR_VCENTER_HOSTNAME:443
    $ govc find /


Troubleshooting Item 
====================

Description

Potential Workaround
--------------------

How to fix...<commit_msg>VMware: added documentation for missing netplan support (#46685)<commit_after>.. _vmware_troubleshooting:

**********************************
Troubleshooting Ansible for VMware
**********************************

.. contents:: Topics

This section lists things that can go wrong and possible ways to fix them.

Debugging
=========

When debugging or creating a new issue, you will need information about your VMware infrastructure. You can get this information using
`govc <https://github.com/vmware/govmomi/tree/master/govc>`_, For example:


.. code-block:: bash

    $ export GOVC_USERNAME=ESXI_OR_VCENTER_USERNAME
    $ export GOVC_PASSWORD=<PASSWORD>
    $ export GOVC_URL=https://ESXI_OR_VCENTER_HOSTNAME:443
    $ govc find /

Known issues
============


Network settings with vmware_guest in Ubuntu 18.04
--------------------------------------------------

Setting the network with ``vmware_guest`` in Ubuntu 18.04 is known to be broken, due to missing support for ``netplan`` in the ``open-vm-tools``.
This issue is tracked via:

* https://github.com/vmware/open-vm-tools/issues/240
* https://github.com/ansible/ansible/issues/41133

Potential Workaround
^^^^^^^^^^^^^^^^^^^^

There are several workarounds for this issue.

1) Modifying the Ubuntu 18.04 images and installing ``ifupdown`` in them via ``sudo apt install ifupdown``.
   If so you need to remove ``netplan`` via ``sudo apt remove netplan.io`` and you need stop ``systemd-networkd`` via ``sudo systemctl disable systemctl-networkd``.

2) You can generate the ``systemd-networkd`` files with a task in your vmware Ansible role:

.. code-block:: yaml

   - name: make sure cache directory exists
     file: path="{{ inventory_dir }}/cache" state=directory
     delegate_to: localhost

   - name: generate network templates
     template: src=network.j2 dest="{{ inventory_dir }}/cache/{{ inventory_hostname }}.network"
     delegate_to: localhost

   - name: copy generated files to vm
     vmware_guest_file_operation:
       hostname: "{{ vmware_general.hostname }}"
       username: "{{ vmware_username }}"
       password: "{{ <PASSWORD> }}"
       datacenter: "{{ vmware_general.datacenter }}"
       validate_certs: "{{ vmware_general.validate_certs }}"
       vm_id: "{{ inventory_hostname }}"
       vm_username: root
       vm_password: "{{ <PASSWORD> }}"
       copy:
           src: "{{ inventory_dir }}/cache/{{ inventory_hostname }}.network"
           dest: "/etc/systemd/network/ens160.network"
           overwrite: False
     delegate_to: localhost

   - name: restart systemd-networkd
     vmware_vm_shell:
       hostname: "{{ vmware_general.hostname }}"
       username: "{{ vmware_username }}"
       password: "{{ <PASSWORD> }}"
       datacenter: "{{ vmware_general.datacenter }}"
       folder: /vm
       vm_id: "{{ inventory_hostname}}"
       vm_username: root
       vm_password: "{{ <PASSWORD> }}"
       vm_shell: /bin/systemctl
       vm_shell_args: " restart systemd-networkd"
     delegate_to: localhost

   - name: restart systemd-resolved
     vmware_vm_shell:
       hostname: "{{ vmware_general.hostname }}"
       username: "{{ vmware_username }}"
       password: "{{ <PASSWORD> }}"
       datacenter: "{{ vmware_general.datacenter }}"
       folder: /vm
       vm_id: "{{ inventory_hostname}}"
       vm_username: root
       vm_password: "{{ <PASSWORD> }}"
       vm_shell: /bin/systemctl
       vm_shell_args: " restart systemd-resolved"
     delegate_to: localhost

3) Wait for ``netplan`` support in ``open-vm-tools``


Troubleshooting Item
====================

Description

Potential Workaround
--------------------

How to fix...
{'fraction_non_alphanumeric': 0.17060544677020031, 'fraction_numerical': 0.008552779653387351, 'mean_word_length': 3.3568627450980393, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5541483', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1299, 'n_words': 362}