Problem creating a bridge with the nmcli module

1,277 views
Skip to first unread message

Patrick Laimbock

unread,
Jul 12, 2016, 12:53:01 PM7/12/16
to Ansible Project
Hi,

Using Ansible 2.1.0.0 I'm trying to create a bridge br0 on a CentOS 7
host to replace its standard eth0 interface (dhcp). The nmcli examples
don't cover a bridge so I tried to follow the logic for bonds. The
snippet below does not work, meaning no ifcfg_br0 and ifcfg_br0_slave_1
files are created and nmcli does not show any bridge connections yet
Ansible says "changed" when run. Anyone have an idea how to create a
bridge using the nmcli module?

TIA,
Patrick

---

- hosts: test
become: yes
become_user: root
gather_facts: True

tasks:
- name: install required NetworkManager packages
yum:
name: "{{item}}"
state: present
with_items:
- NetworkManager-glib
- nm-connection-editor
- libsemanage-python
- policycoreutils-python
tags:
- setup_br0

- name: add br0
nmcli:
type: bridge
conn_name: br0
ifname: br0
state: present
tags:
- setup_br0

- name: add eth0 to bridge br0
nmcli:
type: bridge
conn_name: br0_slave_1
ifname: eth0
master: br0
state: present
tags:
- setup_br0

TASK [install required NetworkManager packages]
********************************
ok: [test] => (item=[u'NetworkManager-glib', u'nm-connection-editor',
u'libsemanage-python', u'policycoreutils-python'])

TASK [add br0]
*****************************************************************
changed: [test]

TASK [add eth0 to bridge br0]
**************************************************
changed: [test]

PLAY RECAP
*********************************************************************
test : ok=4 changed=2 unreachable=0 failed=0


[root@test network-scripts]# ls -l | grep br0
[root@test network-scripts]#

[root@test network-scripts]# nmcli con show
NAME UUID TYPE DEVICE
eth0 e6a5de4e-cf70-4093-a907-9673c782266d 802-3-ethernet eth0

Anthony P V

unread,
Apr 4, 2017, 3:01:41 AM4/4/17
to Ansible Project, pat...@laimbock.com
I too am having the same issue.

Using Fedora 25 with Ansible 2.2.1.0 to change network settings on Centos 7 64bit.

This is what I did.

What am I missing?

----------- start -------------------------
---
- hosts: test
  user: root

  tasks:
    - name: yum upgrade all packages.
      yum: name=* state=latest

    - name: install needed network manager libs
      yum:
        name: '{{ item }}'
        state: installed

      with_items:
        - NetworkManager-glib
        - nm-connection-editor
        - libsemanage-python
        - policycoreutils-python
        - bridge-utils

    - name: setup network bridge
      nmcli:
        conn_name: br0
        ifname: br0
        type: bridge
        ip4: 10.0.0.42/24
        gw4: 10.0.0.1
        state: present

    - name: setup ethernet interface
      nmcli:
        conn_name: eth0

        ifname: eth0
        master: br0
        state: present
----------- end --------------------------
Reply all
Reply to author
Forward
0 new messages