Git Product home page Git Product logo

ansible-role-network's Introduction

Network

Actions Status Ansible Role

Set up custom network interface configurations for a server.

Role Variables

  • network_ifaces: A list of dictionaries, one per network device, of network parameters which will be substituted into templates/etc-sysconfig-network-scripts-ifcfg.j2.
  • network_ifaces[].device: The device name. All other fields are optional, see the template for details.
  • network_ifaces[].bondmaster: If specified this NIC will be part of a bonded interface. If the device name matches bondmaster it will be set as the master, otherwise it will be a slave of bondmaster.
  • network_disable_ifaces: A list of network device names to be explicitly disabled, use this if you want to be sure the interface is disabled (as opposed to being auto-configured by the system).
  • network_delete_ifaces: A regular expression describing the network device name(s) to be removed (note this means the system may auto-configure them), use this for cleaning up spare configuration files.
  • network_additional_params: A dictionary containing additional parameters to be added to the interface configuration file. Keys will be set to upper case, and values will be set as supplied. Add this to the list of dictionaries, network_ifaces.

The set of network parameters which can be defined in network_ifaces are as follows. If these are not defined, and the parameter has a default value, it will be added with that default value.

  • bondmaster (not a parameter, per se, but configures bonding. See example below.)
  • bootproto (default: none)
  • bridge
  • device
  • devicetype
  • dns1
  • dns2
  • gateway
  • hwaddr
  • ip
  • ipv6init (default: yes)
  • mtu
  • netmask
  • ovsbridge
  • prefix
  • type

NB ONBOOT=yes is set by default, and is not configurable.

Example Playbook

# Simple network
- hosts: localhost
  roles:
  - role: ome.network
    network_ifaces:
    - device: eth0
      ip: 192.168.1.1
      netmask: 255.255.255.0
      type: ethernet
      gateway: 192.168.1.254
      dns1: 8.8.4.4
      dns2: 8.8.8.8
      network_additional_params:
        ipv6_autoconf: "no"

# Bonded network combining eth0 and eth1
- hosts: localhost
  roles:
  - role: ome.network
    network_ifaces:
    - device: bond0
      ip: 192.168.1.1
      prefix: 24
      gateway: 192.168.1.254
      dns1: 8.8.4.4
      dns2: 8.8.8.8
      bondmaster: bond0
    - device: eth0
      bondmaster: bond0
    - device: eth1
      bondmaster: bond0

Notes

  • If you change the network settings it may be restarted, which means your connection from Ansible may be broken.
  • In some cases restarting the network is insufficient, you may need to reboot.
  • If you are using this role to set a network IP after a system has been PXEed you may need to temporarily set ansible_host in your host inventory if DNS isn't already setup for the host.

Author Information

[email protected]

ansible-role-network's People

Contributors

jburel avatar joshmoore avatar kennethgillen avatar khaledk2 avatar manics avatar pwalczysko avatar sbesson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-role-network's Issues

too many values to unpack

The inclusion of #3 has broken the current state of prod-playbooks and management_tools inventory.

It was working and tested with the previous version of this role (as was used to most recently deploy ome-web-rw).

Now this PR is merged, prod-playbooks is broken with

"msg": "ValueError: too many values to unpack"}
ome-k8s-pg-01.openmicroscopy.org : ok=1    changed=0    unreachable=0    failed=1
ome-lochy-m01.openmicroscopy.org : ok=1    changed=0    unreachable=0    failed=1
ome-lochy-n01.openmicroscopy.org : ok=1    changed=0    unreachable=0    failed=1
ome-lochy-n02.openmicroscopy.org : ok=1    changed=0    unreachable=0    failed=1
ome-web-rw.openmicroscopy.org : ok=1    changed=0    unreachable=0    failed=1

I presume this is something to do with how the list / dictionary / etc is structured in https://github.com/openmicroscopy/management_tools/blob/master/ansible/inventory/group_vars/vlan-10ge-servers ?

i.e. if you've removed .items() then do we need to change the data structure in the group_vars file?

No longer works in latest version of Ansible

Getting multiple errrors as apparently Ansible has changed the way dictionary works and how it's referenced.

with_items no longer works with dictionary as is.

I can get it to work if I change it to with_dict. However, item.device will need to be changed to item.key; and of course jinja2 template also doesn't work with the syntax the way it's set up.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.