---
title: VMware Portgroup
slug: homologacao-atmosphere/vmware-portgroup
description: Learn how to create a VMware Port Group in a VMware Standard Switch (vSS) for ESXi hosts or a cluster with this comprehensive document. It covers essential parameters like switch modification, portgroup naming, VLAN ID assignment, security policies, teami
createdAt: 2023-03-16T18:04:01.000Z
---

## Resumo

- Crie um VMware Port Group em um VMware Standard Switch (vSS) para determinados hosts ESXi ou hosts de determinado cluster.



## Parâmetros

| **Parâmetro**    | **Tipo**  | **Escolhas \|&#x20;**<u>**Valor Padrão**</u> | **Comentários**                                                                                                                                                                                                                                                                                            |
| ---------------- | --------- | -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| switch           | string    | <u>****</u>                                  | - vSwitch para modificar.<br />                                                                                                                                                                                                                                                                            |
| portgroup        | string    |                                              | - Nome do portgroup para ser adicionado                                                                                                                                                                                                                                                                    |
| vlan\_id         | insterger | - <u>**0**</u>                               | - ID da VLAN para atribuir ao grupo de portas.<br />- Definido como 0 (sem marcação de VLAN) por padrão.                                                                                                                                                                                                   |
| security         | dict      |                                              | - A política de rede especifica as configurações de segurança da camada 2 para um  portgroup como o modo promíscuo, onde o adaptador convidado escuta a todos os pacotes, alterações de endereço MAC e transmissões forjadas.<br />- Dict que configura os diferentes valores de segurança para portgroup. |
| teaming          | dict      |                                              | - Dicionário que configura os diferentes valores de agrupamento para portgroup.                                                                                                                                                                                                                            |
| traffic\_shaping | dict      |                                              | - Dicionário que configura o modelagem de tráfego para o switch.                                                                                                                                                                                                                                           |
| cluster\_name    | string    |                                              | - Nome do nome do cluster para associação de host.<br />- O grupo de portas será criado em todos os hosts do cluster fornecido.<br />- Esta opção é necessária se C(hosts) não for especificado.                                                                                                           |
| hosts            | string    |                                              | - Lista de nomes de host ou hosts nos quais o grupo de portas precisa ser adicionado.<br />- Esta opção é necessária se C(cluster\_name) não for especificado.                                                                                                                                             |
| state            | string    | - <u>**present**</u><br />- absent           | - Determina se o portgroup deve estar presente ou não.                                                                                                                                                                                                                                                     |

Estende fragmentos da documentação do módulo [VMware Options](https://app.archbee.com/docs/qhqZWWA92JYWAihQOL_T5/lUq5eineIhH7ZwvyWZYCa).

## Sub-options de security

| **Parâmetro**     | **Tipo** | **Escolhas \|&#x20;**<u>**Valor Padrão**</u> | **Comentários**                                      |
| ----------------- | -------- | -------------------------------------------- | ---------------------------------------------------- |
| promiscuous\_mode | bool     | - <u>**False**</u><br />- True               | - Indica se o modo promíscuo é permitido.            |
| forged\_transmits | bool     | - <u>**False**</u><br />- True               | - Indica se as transmissões forjadas são permitidas. |
| mac\_changes      | bool     | - security\_policy<br />- network\_policy    | - Indica se as alterações do mac são permitidas.     |

## Sub-options de teaming

| **Parâmetro**                | **Tipo**             | **Escolhas \|&#x20;**<u>**Valor Padrão**</u>                                                                 | **Comentários**                                                                                                                                                                                        |
| ---------------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| load\_balancing              | string               | - loadbalance\_ip<br />- loadbalance\_srcmac<br />- loadbalance\_srcid<br />- failover\_explicit<br />- None | - Política de agrupamento de adaptadores de rede.                                                                                                                                                      |
| network\_falilure\_detection | string               | - link\_status\_only<br />- beacon\_probing                                                                  | - Detecção de falha de rede.                                                                                                                                                                           |
| notify\_switches             | bool                 | - <u>**False**</u><br />- True                                                                               | - Indique se deve ou não notificar o comutador físico se um link falhar.                                                                                                                               |
| failback                     | bool                 | - <u>**False**</u><br />- True                                                                               | - Indique se deve ou não usar um failback ao restaurar links.                                                                                                                                          |
| active\_adapters             | list/elements=string |                                                                                                              | - Lista de adaptadores ativos usados ​​para balanceamento de carga.<br />- Todos os vmnics são usados ​​como adaptadores ativos se C(active\_adapters) e C(standby\_adapters) não estiverem definidos. |
| standby\_adapters            | list/elements=string |                                                                                                              | - Lista de adaptadores em espera usados ​​para failover.<br />- Todos os vmnics são usados ​​como adaptadores ativos se C(active\_adapters) e C(standby\_adapters) não estiverem definidos.            |

## Sub-options de traffic\_shaping

| **Parâmetro**      | **Tipo** | **Escolhas \|&#x20;**<u>**Valor Padrão**</u>                                                                                                          | **Comentários**                               |
| ------------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
| enabled            | bool     | <u>****</u>                                                                                                                                           | - Status da Política de Modelagem de Tráfego. |
| average\_bandwidth | interger | - present<br />- absent<br />- <u>**add**</u><br />- remove<br />- set                                                                                | - Largura de banda média (kbit/s).            |
| peak\_bandwidth    | interger | - VirtualMachine<br />- Datacenter<br />- ClusterComputeResource<br />- HostSystem<br />- DistributedVirtualSwitch<br />- DistributedVirtualPortgroup | - Largura de banda máxima (kbit/s).           |
| burst\_size        | interger |                                                                                                                                                       | - Tamanho da rajada (KB).                     |

## Notas

Observação

- Testado em ESXi 7.0.2
- Todos os módulos requerem acesso de gravação API e, portanto, não são suportados em uma licença ESXi gratuita.

## Exemplos

```yaml
- name: Add Management Network VM Portgroup
  vmware_portgroup:
    hostname: "{{ esxi_hostname }}"
    username: "{{ esxi_username }}"
    password: "{{ esxi_password }}"
    switch: "{{ vswitch_name }}"
    portgroup: "{{ portgroup_name }}"
    vlan_id: "{{ vlan_id }}"
  delegate_to: localhost

- name: Add Portgroup with Promiscuous Mode Enabled
  vmware_portgroup:
    hostname: "{{ esxi_hostname }}"
    username: "{{ esxi_username }}"
    password: "{{ esxi_password }}"
    switch: "{{ vswitch_name }}"
    portgroup: "{{ portgroup_name }}"
    security:
        promiscuous_mode: True
  delegate_to: localhost

- name: Add Management Network VM Portgroup to specific hosts
  vmware_portgroup:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    hosts: [esxi_hostname_one]
    switch: "{{ vswitch_name }}"
    portgroup: "{{ portgroup_name }}"
    vlan_id: "{{ vlan_id }}"
  delegate_to: localhost

- name: Add Management Network VM Portgroup to all hosts in a cluster
  vmware_portgroup:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    cluster_name: "{{ cluster_name }}"
    switch: "{{ vswitch_name }}"
    portgroup: "{{ portgroup_name }}"
    vlan_id: "{{ vlan_id }}"
  delegate_to: localhost

- name: Remove Management Network VM Portgroup to all hosts in a cluster
  vmware_portgroup:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    cluster_name: "{{ cluster_name }}"
    switch: "{{ vswitch_name }}"
    portgroup: "{{ portgroup_name }}"
    vlan_id: "{{ vlan_id }}"
    state: absent
  delegate_to: localhost

- name: Add Portgroup with all settings defined
  vmware_portgroup:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    esxi_hostname: "{{ inventory_hostname }}"
    switch: "{{ vswitch_name }}"
    portgroup: "{{ portgroup_name }}"
    vlan_id: 10
    security:
        promiscuous_mode: False
        mac_changes: False
        forged_transmits: False
    traffic_shaping:
        enabled: True
        average_bandwidth: 100000
        peak_bandwidth: 100000
        burst_size: 102400
    teaming:
        load_balancing: failover_explicit
        network_failure_detection: link_status_only
        notify_switches: true
        failback: true
        active_adapters:
            - vmnic0
        standby_adapters:
            - vmnic1
  delegate_to: localhost
  register: teaming_result
```

## Valores Retornados

| **Chave** | **Tipo** | **Retornado quando** | **Descrição**                       |
| --------- | -------- | -------------------- | ----------------------------------- |
| result    | dict     | sempre               | metadados sobre os portgroups<br /> |

