diff --git a/releasenotes/notes/networkmanager-compatibility-87c7c1c121469714.yaml b/releasenotes/notes/networkmanager-compatibility-87c7c1c121469714.yaml new file mode 100644 index 00000000..d940977c --- /dev/null +++ b/releasenotes/notes/networkmanager-compatibility-87c7c1c121469714.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + The ``lxcbr0`` bridge now allows NetworkManager to control it, which + allows for networks to start in the correct order when the system boots. + In addition, the ``NetworkManager-wait-online.service`` is enabled to + ensure that all services that require networking to function, such as + ``keepalived``, will only start when network configuration is complete. + These changes are only applied if a deployer is actively using + NetworkManager in their environment. diff --git a/tasks/lxc_net.yml b/tasks/lxc_net.yml index b11c48d7..79b93ed9 100644 --- a/tasks/lxc_net.yml +++ b/tasks/lxc_net.yml @@ -13,6 +13,24 @@ # See the License for the specific language governing permissions and # limitations under the License. +# NOTE(mhayden): One of three exit codes should be returned. +# 0 = service is running +# 3 = service is installed, but not running +# 4 = service is not installed, and not running +- name: Check if NetworkManager is running + command: systemctl status NetworkManager + changed_when: false + failed_when: false + register: networkmanager_check + tags: + - skip_ansible_lint + +- name: Ensure network services wait on networking (if using NetworkManager) + service: + name: NetworkManager-wait-online.service + status: enabled + when: networkmanager_check.rc == 0 + - name: Drop lxc net bridge template: src: "{{ item.src }}" diff --git a/templates/lxc-net-redhat-bridge.cfg.j2 b/templates/lxc-net-redhat-bridge.cfg.j2 index b15e854f..a8a0a9c9 100644 --- a/templates/lxc-net-redhat-bridge.cfg.j2 +++ b/templates/lxc-net-redhat-bridge.cfg.j2 @@ -9,6 +9,6 @@ GATEWAY={{ lxc_net_gateway }} {% endif %} ONBOOT=yes BOOTPROTO=none -NM_CONTROLLED=no +NM_CONTROLLED={{ (networkmanager_check.rc == 0) | ternary('yes', 'no') }} DELAY=0 STP=no