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

Add sonic role to support SONiC switches. #121

Merged
merged 124 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
0acc3a3
Add `sonic` role to support SONiC switches.
Gerrit91 Jan 23, 2023
7d24f39
Set lldp hello timer on sonic, default to 10s
majst01 Jan 26, 2023
fc240c1
set ntp timezone (#131)
GrigoriyMikhalkin Jan 27, 2023
3dddfa5
quote timezone
mwindower Jan 30, 2023
9af639b
Implemented vtep support (#132)
mwindower Feb 2, 2023
620246e
Support interconnects with sonic role (#137)
mwindower Feb 7, 2023
c305eec
fix condition in dhcp role
mwindower Feb 10, 2023
c3e2c06
do not manage routes installed by FRR with systemd
mwindower Feb 14, 2023
5185a2a
add support for L3VNIs by mapping a VRF to a VNI
mwindower Feb 15, 2023
f0e2de5
remove ro restriction for redis
mwindower Feb 16, 2023
2275cb1
add net_admin capability for metal-core
mwindower Feb 16, 2023
ac4abd6
Add frr-reload.py
majst01 Feb 21, 2023
19854e8
remove config save temporarily (#147)
GrigoriyMikhalkin Feb 22, 2023
ab9a394
support multiple neighbors for interconnects with BGP unnumbered
mwindower Feb 23, 2023
9695a4c
support multiple neighbors for interconnects with BGP unnumbered
mwindower Feb 23, 2023
4ff7b6d
support multiple neighbors for interconnects with BGP unnumbered
mwindower Feb 23, 2023
7441911
advance systemd-networkd role with redhat/almalinux support and intro…
mwindower Feb 23, 2023
cf2a232
provide sysctls with frr role
mwindower Feb 23, 2023
fda581e
fix tests
mwindower Feb 23, 2023
6275de0
do not support breakouts via metal.yaml - it breaks stuff
mwindower Feb 23, 2023
be418c4
make vlan members optional
mwindower Feb 27, 2023
710bb9b
Remove now unuse metal-core parameters
majst01 Feb 28, 2023
d8e6562
metal-core write directly into redis therefore write-to-db@.service i…
robertvolkmann Mar 1, 2023
e9218cd
use frr-reload from SONiC
robertvolkmann Mar 1, 2023
2fd6524
Change docker package to docker.io to be consistent with gitlabci-run…
mreiger Mar 1, 2023
52f89e0
Add capability to set a static gateway
mreiger Mar 1, 2023
6e11ed1
Add gpg package as a requirement for adding the frr repo
mreiger Mar 1, 2023
3bdaf2c
fix description of frr-reload.service
robertvolkmann Mar 1, 2023
2639503
reintroduce METAL_CORE_LOOPBACK_IP for the router-id in frr.conf
robertvolkmann Mar 2, 2023
3a6300f
Change DHCP options handling so we can set options without 'options' …
mreiger Mar 2, 2023
ad355db
Merge branch 'sonic-2' of github.com:metal-stack/metal-roles into son…
mreiger Mar 2, 2023
6ce15e8
Fix nginx default html path so that the ztp script actually gets served
mreiger Mar 3, 2023
26dbbf5
Merge branch 'master' into sonic-2
Gerrit91 Mar 7, 2023
a1567ba
Remove duplicated keys.
Gerrit91 Mar 7, 2023
dd8cfaa
Add ssh key to gitlab runner role
mreiger Mar 9, 2023
42e0c2e
Specify ssh keys directly, not path to file
mreiger Mar 9, 2023
2bc9433
Add the possibility to specify a fixed management interface IP
mreiger Mar 10, 2023
e5a48a8
Clarify sonic_mgmtif_ip format
mreiger Mar 10, 2023
eefa43f
Add ssh setup to mgmtserver role
mreiger Mar 10, 2023
f95972e
Add handler so sshd can be restarted after config change
mreiger Mar 10, 2023
05e40c0
Fixed ssh key filenames
mreiger Mar 10, 2023
cf4712e
Render ssh config instead of static file
mreiger Mar 10, 2023
7c6a436
Fix sonic unit tests after adding fixed mgmt ip
mreiger Mar 10, 2023
5ef9982
Fix the sonic unittest fix 🙂
mreiger Mar 10, 2023
f7f6bef
Only write ssh config for hosts with ansible_host defined to prevent …
mreiger Mar 10, 2023
18915b2
Add metal user's ssh key to its own authorized_keys for self and cros…
mreiger Mar 10, 2023
eb7b92e
Add recomendet options from edgecore support
majst01 Mar 14, 2023
ee2bd8d
Try and implement an ACL to allow SSH to a switch on its prod addresses
mreiger Mar 14, 2023
801c2cf
Ports for controlplane ACLs probably not relevant
mreiger Mar 14, 2023
4388d20
Also remove ssh interface check
mreiger Mar 14, 2023
512798a
Attempt to allow more than one source range for ssh access list
mreiger Mar 14, 2023
d6e3496
Try and fix having more than one source range
mreiger Mar 14, 2023
203042f
Prevent ACL rules from overwriting each other by varying rule priority
mreiger Mar 14, 2023
2340c3a
Fix sonic role tests
mreiger Mar 14, 2023
0ed5306
Try out script for hopefully more reliable renaming of interfaces
mreiger Mar 16, 2023
68f895f
Work around async not being supported in script module
mreiger Mar 16, 2023
7537f98
Actually include the script this time...
mreiger Mar 16, 2023
1676c5b
Try and have sensible timeouts set
mreiger Mar 16, 2023
e16d695
Try and fix order of handlers
mreiger Mar 16, 2023
c9fecf1
Try and force execution of rename interface handler when called
mreiger Mar 16, 2023
2a3c724
Try and force rename interface hander, try 2
mreiger Mar 16, 2023
3231093
Try and force rename interface hander, try 3
mreiger Mar 16, 2023
6eecfa0
Default routemap to deny redistribution of mgmt interface address ove…
mreiger Mar 17, 2023
6209569
Fix name of that default routemap
mreiger Mar 17, 2023
402246b
Add ACL to allow NTP because apparently this is necessary when an ACL…
mreiger Mar 20, 2023
3ed186e
Try and fix NTP ACL
mreiger Mar 20, 2023
39c274e
Option to configure dhcpv4 route metrics so that DHCP routes can be p…
mreiger Mar 21, 2023
7393dea
Fix sonic role tests
mreiger Mar 21, 2023
c5f85bd
Fix typo in sonic role tests
mreiger Mar 21, 2023
1b7b892
Cosmetic fix in sonic frr template
mreiger Mar 21, 2023
efc2531
Fix sonic metal.yaml template test
mreiger Mar 21, 2023
d1a0105
Fix dhcpv4 metric: Use the value, not the variable name...
mreiger Mar 22, 2023
4c2e73a
Flag to keep dhcp route because it can serve as backup with proper ad…
mreiger Mar 22, 2023
7a36f7e
Try and fix preserve dhcp route conditional
mreiger Mar 22, 2023
bfd0028
If mgmt vrf is enabled, run sshd in it so that outbound connections work
mreiger Mar 23, 2023
2e0c81e
Only put sshd in mgmt vrf if it is actually enabled
mreiger Mar 23, 2023
b62ea96
Try to start sshd after mgmt vrf so it does not fail after reboot
mreiger Mar 24, 2023
caef2a9
Try and fix ssh service override syntax
mreiger Mar 24, 2023
39e64ed
Try and move ssh vrf switch after switch configuration because when b…
mreiger Mar 24, 2023
7313b74
Disable ssh in mgmt vrf for now because it breaks on config reload
mreiger Mar 24, 2023
464c089
Use ansible_hostname as host alias for shorter ssh commands connectio…
mreiger Mar 27, 2023
f171eb9
Fix mgmtserver /etc/hosts syntax
mreiger Mar 27, 2023
88a40e8
Matching entry in ssh_config so that simple ssh to short hostnames works
mreiger Mar 27, 2023
5e1d634
Use a variable that's not already predefined for host alias
mreiger Mar 27, 2023
e6c6606
Explicitly exit the vrf so that static routes defined later do not ac…
mreiger Mar 29, 2023
0306f0e
Make sonic role work with plain routed IP ports in underlay
mreiger Apr 4, 2023
31c2730
Try and fix template for plain routed ports in underlay
mreiger Apr 4, 2023
66c578d
Add underlay interconnects (with no vrf defined) for dynamic routing …
mreiger Apr 6, 2023
3bbb885
Fix dhcp test
mreiger Apr 6, 2023
029f49b
interconnect with bgp unnumbered interfaces and ipv6 config for these
mreiger Apr 6, 2023
617ac2a
add toggle for providing default route via bgp and use frr 8.5-0
mwindower Apr 6, 2023
261e6d3
Add delay timer on boot for metal-core to wait until Sonic has sorted…
mreiger Apr 12, 2023
73be6e0
Add extended control plane ACLs to sonic role
mreiger Apr 13, 2023
a1148f3
Merge remote-tracking branch 'origin/master' into sonic-2
Gerrit91 Apr 14, 2023
63536b9
Revert changes on dhcpd role.
Gerrit91 Apr 14, 2023
d63ed98
Document sonic extended CACL variables
mreiger Apr 14, 2023
8a9ce98
Merge branch 'master' into sonic-2
Gerrit91 Apr 14, 2023
3d5680d
Merge branch 'master' into sonic-2
Gerrit91 Apr 14, 2023
ac5db29
Merge branch 'master' of github.com:metal-stack/metal-roles into sonic-2
mreiger Apr 14, 2023
e2044e9
Merge remote-tracking branch 'origin/master' into sonic-2
Gerrit91 Apr 17, 2023
9b81d94
Add global defaults to ztp role
mreiger Apr 17, 2023
e27f477
Actually use release vector in ztp role
mreiger Apr 17, 2023
f3c0511
Introduce role for upgrading Sonic switches
mreiger Apr 18, 2023
f5c3db2
Make vrf from which to pull upgrade image configurable, and default t…
mreiger Apr 19, 2023
f74ad6f
Download the image first before installing
mreiger Apr 19, 2023
69d05c8
add remove neighbors workaround
robertvolkmann Apr 19, 2023
6ce00f8
Wait for sonic to become ready after upgrade; and allow pushing the i…
mreiger Apr 19, 2023
7e1fb9b
Try command without outer quotes
mreiger Apr 19, 2023
776ba3a
Apparently system status is not everything; small additional delay to…
mreiger Apr 19, 2023
28377b7
fix file ending
robertvolkmann Apr 21, 2023
1180b26
parse stdout of the breakout command to distinguish between a change …
robertvolkmann Apr 21, 2023
5b6db26
Merge pull request #164 from metal-stack/bgp-crash-workaround
robertvolkmann Apr 21, 2023
50b3b85
Revert "Add delay timer on boot for metal-core to wait until Sonic ha…
robertvolkmann Apr 21, 2023
d303009
Merge remote-tracking branch 'origin/master' into sonic-2
robertvolkmann Apr 21, 2023
addf328
Revert "fix file ending"
robertvolkmann Apr 28, 2023
d76e624
Revert "add remove neighbors workaround"
robertvolkmann Apr 28, 2023
b1d2b4a
Merge remote-tracking branch 'origin/master' into sonic-2
Gerrit91 Jun 16, 2023
7396072
Merge branch 'master' into sonic-2
Gerrit91 Jun 27, 2023
58659d0
Resolve comments on frr role.
Gerrit91 Jun 27, 2023
e00de17
README.
Gerrit91 Jun 27, 2023
a56ca27
Improvements on mgmt-server role.
Gerrit91 Jun 27, 2023
d50dbaf
Review on sonic-upgrade.
Gerrit91 Jun 27, 2023
d00e754
Review on sonic role.
Gerrit91 Jun 27, 2023
11aeaf2
Review on systemd-networkd role.
Gerrit91 Jun 27, 2023
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
12 changes: 12 additions & 0 deletions partition/roles/frr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frr

Configures and starts frr.

This role can deploy on bare metal machines with Debian or Almalinux. It depends on fact gathering.

## Variables

| Name | Mandatory | Description |
| ----------- | --------- | ----------------------------------- |
| frr_version | | The version of FRR to be installed. |
| frr_repo | | The repository that contains FRR. |
3 changes: 3 additions & 0 deletions partition/roles/frr/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
frr_version: 8.4
frr_repo: frr-8
3 changes: 3 additions & 0 deletions partition/roles/frr/files/daemons
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bgpd=yes
zebra=yes
bfdd=yes
55 changes: 55 additions & 0 deletions partition/roles/frr/files/sysctl.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# source: https://github.com/FRRouting/frr/blob/master/doc/user/Useful_Sysctl_Settings.md
# The below sysctl values provide a logical set of defaults which can be further optimized.
#
# /etc/sysctl.d/99frr_defaults.conf
# Place this file at the location above and reload the device.
# or run the sysctl -p /etc/sysctl.d/99frr_defaults.conf

# Enables IPv4/IPv6 Routing
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding=1

# Routing
net.ipv6.route.max_size=131072
net.ipv4.conf.all.ignore_routes_with_linkdown=1
net.ipv6.conf.all.ignore_routes_with_linkdown=1

# Best Settings for Peering w/ BGP Unnumbered
# and OSPF Neighbors
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.lo.rp_filter = 0
net.ipv4.conf.all.forwarding = 1
net.ipv4.conf.default.forwarding = 1
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.default.arp_notify = 1
net.ipv4.conf.default.arp_ignore=1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.all.arp_notify = 1
net.ipv4.conf.all.arp_ignore=1
net.ipv4.icmp_errors_use_inbound_ifaddr=1

# Miscellaneous Settings
# Keep ipv6 permanent addresses on an admin down
net.ipv6.conf.all.keep_addr_on_down=1

# igmp
net.ipv4.igmp_max_memberships=1000
net.ipv4.neigh.default.mcast_solicit = 10

# MLD
net.ipv6.mld_max_msf=512

# Garbage Collection Settings for ARP and Neighbors
net.ipv4.neigh.default.gc_thresh2=7168
net.ipv4.neigh.default.gc_thresh3=8192
net.ipv4.neigh.default.base_reachable_time_ms=14400000
net.ipv6.neigh.default.gc_thresh2=3584
net.ipv6.neigh.default.gc_thresh3=4096
net.ipv6.neigh.default.base_reachable_time_ms=14400000

# Use neigh information on selection of nexthop for multipath hops
net.ipv4.fib_multipath_use_neigh=1

# Allows Apps to Work with VRF
net.ipv4.tcp_l3mdev_accept=1
1 change: 1 addition & 0 deletions partition/roles/frr/files/vtysh.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
service integrated-vtysh-config
13 changes: 13 additions & 0 deletions partition/roles/frr/handlers/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: reload frr
service:
name: frr
state: reloaded

- name: restart frr
service:
name: frr
state: restarted

- name: reload sysctls
command: sysctl --system
19 changes: 19 additions & 0 deletions partition/roles/frr/tasks/install/debian.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- name: add FRR apt-key to verify FRR package
apt_key:
url: https://deb-us.frrouting.org/frr/keys.asc
state: present

- name: add mainline FRR repository to install FRR
apt_repository:
repo: deb https://deb-us.frrouting.org/frr {{ ansible_distribution_release }} {{ frr_repo }}
state: present
filename: frr.list

- name: install required packages to have the network stack in place
apt:
name:
- frr={{ frr_version }}*
- frr-pythontools={{ frr_version }}*
update_cache : yes
force_apt_get: yes
5 changes: 5 additions & 0 deletions partition/roles/frr/tasks/install/redhat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: install frr
dnf:
name: frr
state: present
53 changes: 53 additions & 0 deletions partition/roles/frr/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
- name: check mandatory variables for this role are set
assert:
fail_msg: "not all mandatory variables given, check role documentation"
quiet: yes
that:
- frr_version is not none
- frr_repo is not none
- ansible_os_family in ['Debian', 'RedHat']

- name: gather package facts
package_facts:
manager: auto

- name: check if frr is installed
set_fact:
frr_installed: "{{ ('packages' in ansible_facts and ('frr' in ansible_facts.packages) and (frr_version|string in (ansible_facts.packages['frr'][0].version))) | bool }}"

- import_tasks: install/debian.yaml
when: not frr_installed and ansible_os_family == 'Debian'

- import_tasks: install/redhat.yaml
when: not frr_installed and ansible_os_family == 'RedHat'

- name: copy sysctls for frr
copy:
src: sysctl.conf
dest: /etc/sysctl.d/98-frr.conf
notify: reload sysctls

- name: enable vtysh
copy:
src: vtysh.conf
dest: /etc/frr/
notify: restart frr

- name: enable frr daemons
copy:
src: daemons
dest: /etc/frr/daemons
notify: restart frr

- name: ensure frr is started
systemd:
name: frr
enabled: yes
state: started

- name: copy frr conf
copy:
content: "{{ frr_conf }}"
dest: /etc/frr/frr.conf
notify: reload frr
1 change: 1 addition & 0 deletions partition/roles/metal-core/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
systemd_docker_volumes: "{{ lookup('template', 'metal-core-volumes.j2') | from_yaml }}"
systemd_docker_cap_add:
- sys_admin
- net_admin
systemd_service_environment: "{{ lookup('template', 'metal-core-env.j2') | from_yaml }}"
systemd_external_config_changed: "{{ grpc_certs is changed }}"
systemd_service_after: "{{ metal_core_service_dependency }}"
Expand Down
29 changes: 17 additions & 12 deletions partition/roles/mgmt-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ Configures a server to act as management server for a metal-stack partition.

## Variables

| Name | Mandatory | Description |
|---------------------------------------|-----------|---------------------------------------------------------------------------------|
| mgmt_server_asn | yes | the ASN to use for routing. |
| mgmt_server_dns_over_tls | | whether to use DNSoverTLS (default is true). |
| mgmt_server_firewall_facing_interface | yes | the interface where the firewall is connected at the management server. |
| mgmt_server_firewall_ip | | the remote ip of the firewall for setting up a numbered BGP session. |
| mgmt_server_frr_match_interfaces | | announce the networks attached to the given interfaces over BGP. |
| mgmt_server_frr_rep | | the FRR repo to use. |
| mgmt_server_frr_version | | the FRR version to use. |
| mgmt_server_nameservers | | the nameservers to use (default is dns0.eu). |
| mgmt_server_router_id | yes | the router-id to use for routing. |
| mgmt_server_spine_facing_interface | yes | the interface where the management spine is connected at the management server. |
| Name | Mandatory | Description |
| ------------------------------------- | --------- | ------------------------------------------------------------------------------------ |
| mgmt_server_asn | yes | the ASN to use for routing. |
| mgmt_server_dns_over_tls | | whether to use DNSoverTLS (default is true). |
| mgmt_server_firewall_facing_interface | yes | the interface where the firewall is connected at the management server. |
| mgmt_server_firewall_ip | | the remote ip of the firewall for setting up a numbered BGP session. |
| mgmt_server_frr_match_interfaces | | announce the networks attached to the given interfaces over BGP. |
| mgmt_server_frr_repo | | the FRR repo to use. |
| mgmt_server_frr_version | | the FRR version to use. |
| mgmt_server_nameservers | | the nameservers to use (default is dns0.eu). |
| mgmt_server_router_id | yes | the router-id to use for routing. |
| mgmt_server_spine_facing_interface | yes | the interface where the management spine is connected at the management server. |
| mgmt_server_metal_ssh_groups | | the ansible group to include into the ssh config |
| mgmt_server_metal_ssh_privkey | yes | the private SSH key of the `metal` admin user for connecting to the other components |
| mgmt_server_metal_ssh_pubkey | yes | the public SSH key of the `metal` admin user for connecting to the other components |
| mgmt_server_preserve_dhcp_route | no | preserve the dhcp (default) route the mgmt server got from the mgmt firewall |
| mgmt_server_provide_default_route | no | provide the default route with bgp (`network 0.0.0.0/0`) |
7 changes: 5 additions & 2 deletions partition/roles/mgmt-server/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# mgmt_server_router_id:
# mgmt_server_spine_facing_interface:
# mgmt_server_firewall_facing_interface:
# mgmt_server_firewall_ip:
# mgmt_server_firewall_ip:

mgmt_server_registry_mirror: https://mirror.gcr.io

Expand All @@ -17,5 +17,8 @@ mgmt_server_dns_over_tls: true
mgmt_server_frr_match_interfaces:
- lo

mgmt_server_frr_version: 8.4.2
mgmt_server_frr_version: 8.5-0
mgmt_server_frr_repo: frr-8
mgmt_server_provide_default_route: false

mgmt_server_metal_ssh_groups: "{{ groups.all }}"
6 changes: 6 additions & 0 deletions partition/roles/mgmt-server/handlers/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@
- name: save iptables v6 rules
shell: ip6tables-save > /etc/iptables/rules.v6
listen: persist iptables

- name: restart sshd
service:
name: sshd
enabled: true
state: restarted
7 changes: 7 additions & 0 deletions partition/roles/mgmt-server/tasks/install_frr.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
---
- name: ensure gpg is installed to handle FRR repo key
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit sad we have an FRR role now and the mgmt-server's FRR is still installed here without using it.

apt:
name:
- gpg
update_cache : yes
force_apt_get: yes

- name: add FRR apt-key to verify FRR package
apt_key:
url: https://deb-us.frrouting.org/frr/keys.asc
Expand Down
63 changes: 61 additions & 2 deletions partition/roles/mgmt-server/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- mgmt_server_asn is not none
- mgmt_server_router_id is not none
- mgmt_server_spine_facing_interface is not none
- mgmt_server_metal_ssh_privkey is not none
- mgmt_server_metal_ssh_pubkey is not none

- name: gather package facts
package_facts:
Expand All @@ -33,7 +35,7 @@
name:
- net-tools
- ipmitool
- docker-ce
- docker.io
- iptables-persistent
update_cache : yes
force_apt_get: yes
Expand Down Expand Up @@ -85,9 +87,66 @@
notify:
- reload frr

- name: Copy ssh key pair for metal user
copy:
content: "{{ item.content }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode}}"
owner: metal
group: metal
loop:
- content: "{{ mgmt_server_metal_ssh_privkey }}"
dest: /home/metal/.ssh/id_rsa
mode: "0600"
- content: "{{ mgmt_server_metal_ssh_pubkey }}"
dest: /home/metal/.ssh/id_rsa.pub
mode: "0644"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need the public key on the machine?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know.


# This is so that self connect and cross connect to the other mgmtserver is possible
- name: Add own ssh key to authorized_keys
lineinfile:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using ansible.posix.authorized_key?

path: /home/metal/.ssh/authorized_keys
regexp: '^{{ mgmt_server_metal_ssh_pubkey }}$'
line: '{{ mgmt_server_metal_ssh_pubkey }}'

- name: configure sshd to avoid root login and password authentication, hide OS information
lineinfile:
path: /etc/ssh/sshd_config
state: present
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
validate: /usr/sbin/sshd -t -f %s
notify: restart sshd
loop:
- { regexp: "^PasswordAuthentication .+", line: "PasswordAuthentication no" }
- { regexp: "^PermitRootLogin .+", line: "PermitRootLogin no" }
- { regexp: "^DebianBanner .+", line: "DebianBanner no" }

- name: Add IP's of all hosts to /etc/hosts to use those hostnames for connections
lineinfile:
dest: /etc/hosts
regexp: '.*\s{{ item }}$'
line: "{{ hostvars[item].ansible_host }} {{ item }} {{ hostvars[item].host_alias|default('') }}"
owner: root
group: root
mode: 0644
when:
- hostvars[item].ansible_host is defined
loop: "{{ mgmt_server_metal_ssh_groups }}"

- name: Create ssh configuration for easier access to mgmt components
template:
src: ssh_config.j2
dest: /home/metal/.ssh/config
mode: 0644
owner: metal
group: metal

- name: flush handlers to complete the mgmt-server setup
meta: flush_handlers

- name: flush dhcp routes if we have a bgp session to the firewall
command: ip route flush proto dhcp
when: mgmt_server_firewall_ip is defined
when:
- mgmt_server_firewall_ip is defined
- mgmt_server_preserve_dhcp_route is undefined or not mgmt_server_preserve_dhcp_route
3 changes: 3 additions & 0 deletions partition/roles/mgmt-server/templates/frr.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ router bgp {{ mgmt_server_asn }}
!
address-family ipv4 unicast
redistribute connected route-map LOCAL_INTERFACES
{% if mgmt_server_provide_default_route %}
network 0.0.0.0/0
{% endif %}
exit-address-family
!
route-map LOCAL_INTERFACES permit 10
Expand Down
8 changes: 8 additions & 0 deletions partition/roles/mgmt-server/templates/ssh_config.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% for host in mgmt_server_metal_ssh_groups %}
{% if hostvars[host].ansible_host is defined %}
{% if hostvars[host].ansible_user is defined %}
Host {{ host }} {{ hostvars[host].host_alias|default('') }}
User {{ hostvars[host].ansible_user }}
{% endif %}
{% endif %}
{% endfor %}
16 changes: 16 additions & 0 deletions partition/roles/sonic-upgrade/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# sonic-upgrade

Performs an upgrade of the SONiC OS on a device and reboots it to complete the installation.

It depends on the `switch_facts` module from `ansible-common`, so make sure modules from `ansible-common` are included before executing this role.

## Variables

| Name | Mandatory | Description |
| ------------------------ | --------- | ------------------------------------------------------------------------------------------------------------------- |
| sonic_upgrade_host | yes | The host from which to dowload the image. |
| sonic_upgrade_image_path | | The path to the image. If this is given and not `sonic_upgrade_host`, the image is pushed to the device by ansible. |
| sonic_upgrade_vrf | | The vrf used for pulling the upgrade image. |
| sonic_upgrade_protocol | | The protocol (http or https) to use when downloading the sonic image. |
| sonic_upgrade_port | | The port on which the image server listens. |
| sonic_upgrade_image | yes | The file name of the sonic image. |
4 changes: 4 additions & 0 deletions partition/roles/sonic-upgrade/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
sonic_upgrade_protocol: "http"
sonic_upgrade_port: 8080
sonic_upgrade_vrf: "mgmt"
Loading