diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..0d0ba9f --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,24 @@ +--- +# Copyright 2018, Logan Vig +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Restart systemd-networkd + systemd: + name: "systemd-networkd" + daemon_reload: yes + state: restarted + when: + - systemd_run_networkd | bool + tags: + - systemd-networkd diff --git a/tasks/main.yml b/tasks/main.yml index b87b9e7..987c425 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -29,6 +29,8 @@ mode: "0644" config_overrides: "{{ systemd_link_config_overrides }}" config_type: "ini" + notify: + - Restart systemd-networkd tags: - systemd-networkd @@ -60,6 +62,8 @@ group: "root" mode: "0644" with_indexed_items: "{{ systemd_netdevs }}" + notify: + - Restart systemd-networkd tags: - systemd-networkd @@ -73,14 +77,16 @@ config_overrides: "{{ item.1.config_overrides | default({}) }}" config_type: "ini" with_indexed_items: "{{ systemd_networks }}" + notify: + - Restart systemd-networkd tags: - systemd-networkd -- name: Restart systemd-networkd +- name: Set systemd-networkd service state systemd: name: "systemd-networkd" daemon_reload: yes enabled: "{{ (systemd_run_networkd | bool) | ternary('yes', 'no') }}" - state: "{{ (systemd_run_networkd | bool) | ternary('restarted', omit) }}" + state: "{{ (systemd_run_networkd | bool) | ternary('started', 'stopped') }}" tags: - systemd-networkd