-
Notifications
You must be signed in to change notification settings - Fork 192
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 multi-machine setup script #2347
Merged
mergify
merged 8 commits into
os-autoinst:master
from
okurz:feature/setup_mm_poo132134_133025
Aug 1, 2023
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9cca1aa
Add multi-machine setup script
okurz bf24af5
Include os-autoinst-setup-multi-machine in doc+package
okurz fff230c
os-autoinst-setup-multi-machine: Add live-mode related steps
okurz b367773
os-autoinst-setup-multi-machine: Extract main function
okurz e86a827
os-autoinst-setup-multi-machine: Ensure IP forwarding
okurz 11d9834
os-autoinst-setup-multi-machine: Make zone configurable
okurz ad65ab6
os-autoinst-setup-multi-machine: Use more common 'br0' as ethernet
okurz a900bef
os-autoinst-setup-multi-machine: Ensure correct default zone
okurz File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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,77 @@ | ||
#!/bin/bash -e | ||
set -euo pipefail | ||
instances="${instances:-20}" | ||
bridge="${bridge:-"br1"}" | ||
ethernet="${ethernet:-"eth0"}" | ||
zone="${zone:-"trusted"}" | ||
|
||
ensure_ip_forwarding() { | ||
grep -q 1 /proc/sys/net/ipv4/ip_forward || echo -e 'net.ipv4.ip_forward = 1\nnet.ipv6.conf.all.forwarding = 1' > /etc/sysctl.d/ip_forward.conf | ||
} | ||
|
||
setup_multi_machine() { | ||
zypper -n in openvswitch os-autoinst-openvswitch firewalld | ||
ovs-vsctl add-br $bridge | ||
echo "OS_AUTOINST_USE_BRIDGE=$bridge" > /etc/sysconfig/os-autoinst-openvswitch | ||
cat > /etc/sysconfig/network/ifcfg-$bridge <<EOF | ||
BOOTPROTO='static' | ||
IPADDR='10.0.2.2/15' | ||
STARTMODE='auto' | ||
ZONE="$zone" | ||
OVS_BRIDGE='yes' | ||
PRE_UP_SCRIPT="wicked:gre_tunnel_preup.sh" | ||
OVS_BRIDGE_PORT_DEVICE_0='tap0' | ||
EOF | ||
cat > /etc/sysconfig/network/ifcfg-tap0 <<EOF | ||
BOOTPROTO='none' | ||
IPADDR='' | ||
NETMASK='' | ||
PREFIXLEN='' | ||
STARTMODE='auto' | ||
TUNNEL='tap' | ||
TUNNEL_SET_GROUP='nogroup' | ||
TUNNEL_SET_OWNER='_openqa-worker' | ||
EOF | ||
for i in $(seq 1 $instances; seq 64 $((64+$instances)); seq 128 $((128+$instances))); do ln -sf ifcfg-tap0 /etc/sysconfig/network/ifcfg-tap$i && echo "OVS_BRIDGE_PORT_DEVICE_$i='tap$i'" >> /etc/sysconfig/network/ifcfg-$bridge; done | ||
cat > /etc/firewalld/zones/"$zone".xml <<EOF | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<zone target="ACCEPT"> | ||
<short>"${zone^}"</short> | ||
<description>All network connections are accepted.</description> | ||
<service name="isotovideo"/> | ||
<interface name="$bridge"/> | ||
<interface name="ovs-system"/> | ||
<interface name="$ethernet"/> | ||
<masquerade/> | ||
</zone> | ||
EOF | ||
zypper -n in libcap-progs | ||
setcap CAP_NET_ADMIN=ep /usr/bin/qemu-system-x86_64 | ||
cat > /etc/wicked/scripts/gre_tunnel_preup.sh <<EOF | ||
#!/bin/sh | ||
action="\$1" | ||
bridge="\$2" | ||
ovs-vsctl set bridge \$bridge stp_enable=true | ||
# TODO add entries according to your network topology | ||
#ovs-vsctl --may-exist add-port \$bridge gre1 -- set interface gre1 type=gre options:remote_ip=<IP address of other host> | ||
EOF | ||
chmod +x /etc/wicked/scripts/gre_tunnel_preup.sh | ||
systemctl enable --now openvswitch os-autoinst-openvswitch | ||
} | ||
|
||
configure_firewall() { | ||
systemctl enable --now firewalld | ||
firewall-cmd --permanent --new-service isotovideo | ||
for i in $(seq 1 $instances); do firewall-cmd --permanent --service=isotovideo --add-port=$((i * 10 + 20003))/tcp ; done | ||
firewall-cmd --permanent --zone="$zone" --add-service=isotovideo | ||
firewall-cmd --set-default-zone="$zone" | ||
systemctl reload firewalld | ||
} | ||
|
||
main() { | ||
ensure_ip_forwarding | ||
setup_multi_machine | ||
configure_firewall | ||
} | ||
|
||
caller 0 >/dev/null || main "$@" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this TODO telling me? Do we need to add things here? Are we expecting users to edit the script before using it? If so, make it fail, so they know to edit it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the admin reading this needs to patch up the script afterwards. If it would fail then wicked would likely ignore the failure anyway.