From a468089727de4fb2b7eec373a2412cc0028c4a03 Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Mon, 8 Jan 2018 09:22:51 -0600 Subject: [PATCH] Allow NetworkManager to work (if present) This patch adds tasks that check to see if NetworkManager is installed and running. If it is, the tasks allow NetworkManager to handle the `lxcbr0` interface. In addition, the `NetworkManager-wait-online.service` will be enabled to ensure that all services that depend on networking will wait for network configuration to be completed. Partial-Bug: 1738467 Change-Id: I415241daccf22f03826062eea18b3b36b2d9e53e --- ...manager-compatibility-87c7c1c121469714.yaml | 10 ++++++++++ tasks/lxc_net.yml | 18 ++++++++++++++++++ templates/lxc-net-redhat-bridge.cfg.j2 | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/networkmanager-compatibility-87c7c1c121469714.yaml 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