ansible-collections / community.vmware

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

Configuring static routes ESXi host #493

Open markuszeiter opened 3 years ago

markuszeiter commented 3 years ago
SUMMARY

Add feature to configure static routes on ESXi host according to VMware KB https://kb.vmware.com/s/article/2001426:

ISSUE TYPE
COMPONENT NAME

vmwarehost...

ADDITIONAL INFORMATION

This feature can then be used for example for NFS vmkernels where the network is based on L3.

Akasurde commented 3 years ago

@markuszeiter Thanks for requesting this feature. Currently, the user can execute esxcli as mentioned in https://medium.com/@AbhijeetKasurde/ansible-automating-esxcli-using-shell-module-6f691a551bca.

tl;dr

  1. Enable SSH service in the given ESXi using vmware_host_service_manager
  2. Add the given ESXi in Ansible Static inventory file
    [esxi1]
    10.65.201.113 ansible_ssh_user=root
---
- hosts: esxi1
  tasks:
    - name: Add static routes
      shell: "esxcli network ip route ipv4 add --gateway 192.168.0.1 --network 192.168.100.0/24"
      register: r

I totally agree that this is a short term solution and we should have a dedicated module for handling host system network related things. PR welcomed.

markuszeiter commented 3 years ago

@Akasurde thank you very much for your reply. I will try it definetly. I am new here, what do you mean with PR and how to do it?

Akasurde commented 3 years ago

@markuszeiter Welcome to the Ansible VMware community. PR means 'GitHub Pull Request'. You can create a new module as per requirement and submit a pull request here.

Please find the documentation for Ansible Development -

  1. Ansible development environment
  2. VMware module development guidelines

Let me know.