--- - name: Converge hosts: all become: true tasks: - name: create os-net-config config file tempfile: state: file prefix: os-net-config register: onc_cfg # This is a simple test to reconfigure the loopback interface # because it's not easy to know what nics are available on the host # and not breaking the current network configs. - name: write os-net-config config file copy: content: network_config: - type: interface name: lo use_dhcp: false use_dhcpv6: false addresses: - ip_netmask: 127.0.0.1/8 dest: "{{ onc_cfg.path }}" - name: Create safe os-net-config defaults for all interfaces become: true shell: | set -eux cat > {{ onc_cfg.path }} </dev/null HAS_LINK="$(cat /sys/class/net/${iface}/carrier || echo 0)" if [ "$HAS_LINK" == "1" ]; then break else sleep 1 fi TRIES=$(( TRIES - 1 )) done if [ "$HAS_LINK" == "1" ] ; then cat >> {{ onc_cfg.path }} <