2
votes

Mainly I am trying to build an ansible role/playbook that would configure an openvswitch bridge that is using the main/primary network interface of the machine and avoid the most common problem with openvswitch bridges -- getting locked out when you add the port.

$ ip addr flush dev eth0
$ ip addr add 192.168.128.5/24 dev br0
$ ip link set br0 up

As you can figure out yourself, while configuring this with ansible (ssh), is very easy to loose access to the target machine.

To simplify the problem assume we already know the name of the main network interface (eth0) and that it is configured using DHCP.

1

1 Answers

2
votes

One solution is to load a script on your slave machine via ansible. Create a script:

script.sh

#!/bin/bash
sudo ip addr flush dev eth0
sudo ip addr add 192.168.128.5/24 dev br0
sudo ip link set br0 up

Then one playbook, which will send the script and execute it. Something like this :

- hosts: slave
  tasks:
  - name: copy script
    copy: src=./script.sh dest=/root/script.sh mode=a+x
  - name: execute script
    shell: ./root/script.sh >> somelog.txt

EDIT:

>     - hosts: slave
>       tasks:
>       - name: copy/execute script
>         copy: src=./script.sh dest=/root/script.sh mode=a+x
>         shell: ./root/script.sh >> somelog.txt
>         async: 10