forked from seapath/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
playbooks/cluster_setup_network: configure PTP
If a PTP VLAN is defined configure and enable the PTP. Signed-off-by: Mathieu Dupré <[email protected]>
- Loading branch information
1 parent
f88f365
commit 8e2e95d
Showing
5 changed files
with
95 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,18 +55,60 @@ | |
- ../vars/network_vars.yml | ||
roles: | ||
- systemd_networkd | ||
vars: | ||
apply_config: "{{ apply_network_config | default(false) }}" | ||
tasks: | ||
- block: | ||
- name: add ptp vlan interfaces | ||
template: | ||
src: "../templates/{{ item }}.j2" | ||
dest: "/etc/systemd/network/{{ item }}" | ||
group: systemd-network | ||
with_items: | ||
- 00-ptp.netdev | ||
- 01-ptp.network | ||
register: ptp_interface | ||
- name: Register reboot | ||
set_fact: | ||
need_reboot: true | ||
when: | ||
- not apply_config | ||
- ptp_interface.changed | ||
when: | ||
- ptp_vlan_interface is defined | ||
- ptp_vlan is defined | ||
- ptp_vlan_address is defined | ||
- name: Restart systemd-networkd | ||
ansible.builtin.systemd: | ||
name: systemd-networkd | ||
state: restarted | ||
when: | ||
apply_config | ||
|
||
|
||
- name: Network configuration | ||
- name: Configure PTP ansible.builtin.service | ||
hosts: cluster_machines | ||
vars: | ||
apply_config: "{{ apply_network_config | default(false) }}" | ||
tasks: | ||
- name: Restart systemd-networkd | ||
ansible.builtin.systemd: | ||
name: systemd-networkd | ||
state: restarted | ||
- block: | ||
- name: disable systemd-timesyncd service | ||
ansible.builtin.systemd: | ||
name: systemd-timesyncd.service | ||
enabled: no | ||
state: stopped | ||
- name: Enable ptp service | ||
ansible.builtin.systemd: | ||
name: [email protected] | ||
enabled: yes | ||
- name: Start ptp service | ||
ansible.builtin.systemd: | ||
name: [email protected] | ||
state: started | ||
when: apply_config or (need_reboot is defined and not need_reboot) | ||
when: | ||
apply_config | ||
- ptp_vlan_interface is defined | ||
- ptp_vlan is defined | ||
|
||
- name: Configure hosts and hostname | ||
hosts: cluster_machines | ||
|
@@ -107,14 +149,17 @@ | |
line: 'NTP={{ ntp_servers }}' | ||
- regexp: '^\s*#?\s*(FallbackNTP=).*$' | ||
line: 'FallbackNTP={{ fallback_ntp_servers | default("") }}' | ||
when: | ||
- ptp_vlan_interface is not defined | ||
- ptp_vlan is not defined | ||
notify: | ||
- Restart systemd timesyncd | ||
|
||
handlers: | ||
- name: Restart systemd timesyncd | ||
ansible.builtin.service: | ||
name: systemd-timesyncd | ||
state: restarted | ||
|
||
- name: Configure syslog-ng | ||
hosts: cluster_machines | ||
tasks: | ||
|
@@ -127,7 +172,6 @@ | |
state: present | ||
notify: | ||
- Restart systemd syslog-ng | ||
|
||
handlers: | ||
- name: Restart systemd syslog-ng | ||
vars: | ||
|
@@ -136,7 +180,7 @@ | |
name: syslog-ng@default | ||
state: restarted | ||
when: | ||
apply_config | ||
apply_config or (need_reboot is defined and not need_reboot) | ||
|
||
- name: Configure systemd-networkd-wait-online.service | ||
hosts: hypervisors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
[NetDev] | ||
Name=ptp | ||
Kind=vlan | ||
|
||
[VLAN] | ||
Id={{ ptp_vlan }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
[Match] | ||
Name=ptp | ||
|
||
[Network] | ||
Address={{ ptp_vlan_address }}/{{ ptp_vlan_mask | default('24') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
# Copyright (C) 2021, RTE (http://www.rte-france.com) | ||
# SPDX-License-Identifier: Apache-2.0 | ||
--- | ||
systemd_networkd_network_custom: "{{ custom_network |default([]) }}" | ||
_systemd_networkd_network_custom: ["{{ custom_network |default([]) }}"] | ||
|
||
wired_systemd_networkd_network: | ||
_vlan_conditionnal: "{% if ptp_vlan is defined %}[{'VLAN': 'ptp'}]{% else %}[]{% endif %}" | ||
|
||
_network_common: | ||
- Gateway: "{{ gateway_addr }}" | ||
- Address: "{{ ip_addr }}/{{ subnet | default(24) }}" | ||
- DNS: "{{ dns_server }}" | ||
|
||
_wired_systemd_networkd_network: | ||
00-wired: | ||
- Match: | ||
- Name: "{{ network_interface }}" | ||
- Network: | ||
- Gateway: "{{ gateway_addr }}" | ||
- Address: "{{ ip_addr }}/{{ subnet | default(24) }}" | ||
- DNS: "{{ dns_server }}" | ||
- Network: "{{ _network_common + _vlan_conditionnal }}" | ||
|
||
|
||
systemd_networkd_network: "{{ wired_systemd_networkd_network | combine(systemd_networkd_network_custom) }}" | ||
systemd_networkd_network: "{{ _wired_systemd_networkd_network | combine(_systemd_networkd_network_custom) }}" |