Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restart networking service when interfaces changed #23

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Restart Networking service
ansible.builtin.systemd_service:
name: networking
state: restarted
6 changes: 3 additions & 3 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
hosts: all
gather_facts: false
tasks:
- name: Example assertion
ansible.builtin.assert:
that: true
- name: Example assertion
ansible.builtin.assert:
that: true
20 changes: 12 additions & 8 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,16 @@
dest: /etc/network/interfaces
owner: root
group: root
mode: 0644
mode: '0644'
register: config_interface
become: true
when: ifupdown_network_interfaces | length > 0
notify: Restart Networking service

- name: Restarting Network Interfaces
- name: Flush handlers
ansible.builtin.meta: flush_handlers

- name: Restarting Network Interfaces # noqa no-changed-when
ansible.builtin.shell: bash -c "ifdown {{ item.name }} --force && ifup {{ item.name }} --force"
become: true
with_items: "{{ ifupdown_network_interfaces }}"
Expand All @@ -65,7 +69,7 @@
item['configure'] and
config_interface['changed']

- name: Restarting Network VLANs
- name: Restarting Network VLANs # noqa no-changed-when
ansible.builtin.shell: bash -c "ifdown {{ item.name }} --force && ifup {{ item.name }} --force"
become: true
with_items: "{{ ifupdown_network_vlans }}"
Expand All @@ -75,7 +79,7 @@
item['configure'] and
config_interface['changed']

- name: Restarting Network Bridges
- name: Restarting Network Bridges # noqa no-changed-when
ansible.builtin.shell: bash -c "ifdown {{ item.name }} --force && ifup {{ item.name }} --force"
become: true
with_items: "{{ ifupdown_network_bridges }}"
Expand All @@ -85,7 +89,7 @@
item['configure'] and
config_interface['changed']

- name: Restarting OVS Bridges
- name: Restarting OVS Bridges # noqa no-changed-when
ansible.builtin.shell: bash -c "ifdown {{ item.name }} --force && ifup {{ item.name }} --force"
become: true
with_items: "{{ ifupdown_ovs_bridges }}"
Expand All @@ -95,7 +99,7 @@
item['configure'] and
config_interface['changed']

- name: Restarting OVS Bonds
- name: Restarting OVS Bonds # noqa no-changed-when
ansible.builtin.shell: bash -c "ifdown {{ item.name }} --force && ifup {{ item.name }} --force"
become: true
with_items: "{{ ifupdown_ovs_bonds }}"
Expand All @@ -105,7 +109,7 @@
item['configure'] and
config_interface['changed']

- name: Restarting OVS Interfaces
- name: Restarting OVS Interfaces # noqa no-changed-when
ansible.builtin.shell: bash -c "ifdown {{ item.name }} --force && ifup {{ item.name }} --force"
become: true
with_items: "{{ ifupdown_ovs_interfaces }}"
Expand All @@ -115,7 +119,7 @@
item['configure'] and
config_interface['changed']

- name: Restarting OVS Ports
- name: Restarting OVS Ports # noqa no-changed-when
ansible.builtin.shell: bash -c "ifdown {{ item.name }} --force && ifup {{ item.name }} --force"
become: true
with_items: "{{ ifupdown_ovs_ports }}"
Expand Down
Loading