ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
823 stars 1.52k forks source link

nmcli: Unable to configure the network interface #4928

Open Udayendu opened 2 years ago

Udayendu commented 2 years ago

Summary

nmcli is not configuring the interface and saying "Connections already exist and no changes made".

Issue Type

Bug Report

Component Name

Ansible Version

$ pip3 show ansible
Name: ansible
Version: 6.0.0
Summary: Radically simple IT automation
Home-page: https://ansible.com/
Author: Ansible, Inc.
Author-email: info@ansible.com
License: GPLv3+
Location: /usr/local/lib/python3.8/dist-packages
Requires: ansible-core
Required-by:

Community.general Version

$ ansible-galaxy collection list community.general

Configuration

$ ansible-galaxy collection list community.general
# /usr/local/lib/python3.8/dist-packages/ansible_collections
Collection        Version
----------------- -------
community.general 5.0.2

OS / Environment

Steps to Reproduce

Deploy a vm from ovf template which is available in the content library using the following play and then configure the network:

- name: Deploy Virtual Machine from template in content library
  vmware_content_deploy_template:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    template: '{{ vmware_rhel8_temp }}'
    library: '{{ vmware_Content_library }}'
    cluster: '{{ vsphere_cluster }}'
    datastore: '{{ vsphere_datastore }}'
    datacenter: '{{ vsphere_datacenter }}'
    folder: '{{ vsphere_folder }}'
    resource_pool: '{{ resource_pool }}'
    name: '{{ inventory_hostname }}'
    validate_certs: 'no'
    state: present
  delegate_to: localhost

- name: Configure Network Interface '{{ vmware_vm_ifname }}'
  nmcli:
    conn_name: "{{ vmware_vm_ifname }}"
    ifname: "{{ vmware_vm_ifname }}"
    type: ethernet
    ip4: "{{ Mgmt_network_ipv4 }}"
    gw4: "{{ Mgmt_network_gwv4 }}"
    dns4:
      - "{{ dns_server1 }}"
    state: present

Expected Results

Actual Results

There is a requirement to use the content library and hence exploring the network configuration using nmcli which is not working.

Code of Conduct

ansibullbot commented 2 years ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 2 years ago

cc @alcamie101 click here for bot help

Udayendu commented 2 years ago

Here is the debug out put while running the ansible role to configure the network:

Tuesday 05 July 2022  07:10:40 +0000 (0:00:51.520)       0:00:53.006 **********

ok: [rhel8-ansible-nmcli-uskar] => {
    "Exists": "Connections already exist and no changes made",
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "conn_name": "ens192",
    "invocation": {
        "module_args": {
            "addr_gen_mode6": null,
            "ageingtime": 300,
            "arp_interval": null,
            "arp_ip_target": null,
            "autoconnect": true,
            "conn_name": "ens192",
            "dhcp_client_id": null,
            "dns4": [
                "xxx.xxx.xxx.xxx"
            ],
            "dns4_ignore_auto": false,
            "dns4_search": null,
            "dns6": null,
            "dns6_ignore_auto": false,
            "dns6_search": null,
            "downdelay": null,
            "egress": null,
            "flags": null,
            "forwarddelay": 15,
            "gsm": null,
            "gw4": "xxx.xxx.xxx.xxx",
            "gw4_ignore_auto": false,
            "gw6": null,
            "gw6_ignore_auto": false,
            "hairpin": null,
            "hellotime": 2,
            "ifname": "ens192",
            "ignore_unsupported_suboptions": false,
            "ingress": null,
            "ip4": [
                "xxx.xxx.xxx.xxx"
            ],
            "ip6": null,
            "ip_privacy6": null,
            "ip_tunnel_dev": null,
            "ip_tunnel_input_key": null,
            "ip_tunnel_local": null,
            "ip_tunnel_output_key": null,
            "ip_tunnel_remote": null,
            "mac": null,
            "master": null,
            "maxage": 20,
            "may_fail4": true,
            "method4": null,
            "method6": null,
            "miimon": null,
            "mode": "balance-rr",
            "mtu": null,
            "never_default4": false,
            "path_cost": 100,
            "primary": null,
            "priority": 128,
            "route_metric4": null,
            "route_metric6": null,
            "routes4": null,
            "routes4_extended": null,
            "routes6": null,
            "routes6_extended": null,
            "routing_rules4": null,
            "runner": "roundrobin",
            "runner_hwaddr_policy": null,
            "slavepriority": 32,
            "ssid": null,
            "state": "present",
            "stp": true,
            "type": "ethernet",
            "updelay": null,
            "vlandev": null,
            "vlanid": null,
            "vxlan_id": null,
            "vxlan_local": null,
            "vxlan_remote": null,
            "wifi": null,
            "wifi_sec": null,
            "wireguard": null,
            "zone": null
        }
    },
    "state": "present"
}
ansibullbot commented 1 year ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help