ansible / ansible-modules-core

Ansible modules - these modules ship with ansible
1.3k stars 1.95k forks source link

cl_interface|bond|bridge does not configure multiple addresses properly #3881

Closed yano-at-so-net closed 8 years ago

yano-at-so-net commented 8 years ago
ISSUE TYPE
$ ansible --version
ansible 2.1.0.0
  config file =
  configured module search path = Default w/o overrides
CONFIGURATION
OS / ENVIRONMENT

Mac OS 10.11.5

SUMMARY
STEPS TO REPRODUCE

Use the following Vagrant file to spin up a cumulus-vx switch.

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
  config.vm.box = "CumulusCommunity/cumulus-vx"
  config.vm.network "private_network", virtualbox__intnet: true, auto_config: false
  config.vm.network "private_network", virtualbox__intnet: true, auto_config: false
  config.vm.network "private_network", virtualbox__intnet: true, auto_config: false
  config.vm.provision "ansible" do |ansible|
    ansible.playbook = "cl.yml"
  end
end

Put the following ansible playbook in the same directory.


---
- name: add support for multiple addresses
  hosts: all
  become: yes
  tasks:
    - lineinfile:
        line: 'source /etc/network/interfaces.d/*'
        dest: /etc/network/interfaces
    - cl_interface:
        name: swp1
        ipv4: 192.0.2.1/24
        ipv6: 2001:db8::1/64
    - cl_bond:
        name: bond0
        slaves:
          - swp2
          - swp3
        ipv4: 198.51.100.1/24
        ipv6: 2001:db8:1::1/64
    - cl_bridge:
        name: br0
        ports:
          - swp4
          - swp5
        ipv4: 203.0.113.1/24
        ipv6: 2001:db8:2::1/64
    - service:
        name: networking
        state: restarted

Then vagrant up will provision the VM using Ansible.

$ vagrant up
(snip)
==> default: Running provisioner: ansible...
    default: Running ansible-playbook...

PLAY [add support for multiple addresses] **************************************

TASK [setup] *******************************************************************
ok: [default]

TASK [lineinfile] **************************************************************
changed: [default]

TASK [cl_interface] ************************************************************
changed: [default]

TASK [cl_bond] *****************************************************************
changed: [default]

TASK [cl_bridge] ***************************************************************
changed: [default]

TASK [service] *****************************************************************
changed: [default]

PLAY RECAP *********************************************************************
default                    : ok=6    changed=5    unreachable=0    failed=0

$
EXPECTED RESULTS

man interfaces 5 describes that address attributes should be written separately. So the above playbook should create files like the following and the addresses show be assigned to each interfaces.

/etc/network/interfaces.d/swp1

auto swp1
iface swp1
  address 192.0.2.1/24
  address 2001:db8::1/64

/etc/network/interfaces.d/bond0

iface bond0
  address 198.51.100.1/24
  address 2001:db8:1::1/64

/etc/network/interfaces.d/br0

auto br0
iface br0
  address 203.0.113.1/24
  address 2001:db8:2::1/64
ACTUAL RESULTS

The files created by the module have all address attributes in one line, which is not compliant. As a result, the addresses are not configured after running the playbook.

/etc/network/interfaces.d/swp1

auto swp1
iface swp1
    address 192.0.2.1/24 2001:db8::1/64

/etc/network/interfaces.d/bond0

auto bond0
iface bond0
    bond-miimon 100
    bond-lacp-rate 1
    bond-min-links 1
    bond-slaves swp2 swp3
    bond-mode 802.3ad
    address 198.51.100.1/24 2001:db8:1::1/64
    bond-xmit-hash-policy layer3+4

/etc/network/interfaces.d/br0

auto br0
iface br0
    bridge-ports swp4 swp5
    bridge-stp yes
    address 203.0.113.1/24 2001:db8:2::1/64
abenokraitis commented 8 years ago

Greetings, I'd like to request that this issue be closed as a duplicate of the upstream bug which is filed against the Cumulus GitHub repo/module:

https://github.com/CumulusNetworks/cumulus-linux-ansible-modules/pull/54

privateip commented 8 years ago

tracking issue in downstream repo, closing this issue