Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:crameleon:temporary
opensuse-infrastructure-vm-bootstrap
initial_setup.sh
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File initial_setup.sh of Package opensuse-infrastructure-vm-bootstrap
#!/bin/bash set -eu help() { echo echo "first boot configuration for infra.opensuse.org VMs" echo echo "Options:" echo "-n HOSTNAME The VM's hostname" echo "-i IP The last two digits of the VM's IP" echo "-l LOCATION The location of the VM. Choices:" echo " - vlan47 or heroes or nue (DEFAULT)" echo " - vlan42 or suse-dmz" echo " - vlan67 or heroes-prv or prv" echo " - vlan87 or ipx" echo " - geeko (for local test VMs)" echo } VM_LOCATION="heroes" [[ $1 == '--help' ]] && help && exit while getopts n:i:l:h arg; do case ${arg} in n) VM_HOSTNAME=${OPTARG} ;; i) VM_IP=${OPTARG} ;; l) VM_LOCATION=${OPTARG} ;; h) help && exit ;; *) help && exit 1 ;; esac done [[ -z $VM_HOSTNAME || -z $VM_IP || -z $VM_LOCATION ]] && help && exit 1 case $VM_LOCATION in vlan42|suse-dmz) NAMESERVERS="192.168.254.101 192.168.254.102" ROUTES="default 192.168.254.100 - -" SYSLOG_SERVER="192.168.254.1" VM_IP_FULL="192.168.254.${VM_IP}/24" VM_IP="192.168.254.${VM_IP}" VM_DOMAIN="suse-dmz.opensuse.org" SALT_CLUSTER="suse_external" SALTMASTER="kovu.$VM_DOMAIN" ;; vlan47|heroes|nue) NAMESERVERS="192.168.47.101 192.168.47.102" ROUTES="default 192.168.47.254 - -" SYSLOG_SERVER="192.168.47.7" VM_IP_FULL="192.168.47.${VM_IP}/24" VM_IP="192.168.47.${VM_IP}" VM_DOMAIN="infra.opensuse.org" SALT_CLUSTER="opensuse" SALTMASTER="minnie.$VM_DOMAIN" ;; vlan67|vlan1067|heroes-prv|prv) NAMESERVERS="192.168.47.101 192.168.47.102" ROUTES="default 192.168.67.20 - -" SYSLOG_SERVER="192.168.47.7" VM_IP_FULL="192.168.67.${VM_IP}/24" VM_IP="192.168.67.${VM_IP}" VM_DOMAIN="infra.opensuse.org" SALT_CLUSTER="opensuse" SALTMASTER="minnie.$VM_DOMAIN" echo "192.168.67.7 download.infra.opensuse.org download.opensuse.org" >> /etc/hosts ;; vlan87|qsc|ipx) NAMESERVERS="192.168.87.1" ROUTES="default 192.168.87.1 - -" SYSLOG_SERVER="192.168.47.7" VM_IP_FULL="192.168.87.${VM_IP}/24" VM_IP="192.168.87.${VM_IP}" VM_DOMAIN="infra.opensuse.org" SALT_CLUSTER="opensuse" SALTMASTER="minnie.$VM_DOMAIN" ;; geeko) NAMESERVERS="192.168.122.1" ROUTES="default 192.168.122.1 - -" SYSLOG_SERVER="192.168.122.1" VM_IP_FULL="192.168.122.${VM_IP}/24" VM_IP="192.168.122.${VM_IP}" VM_DOMAIN="geeko" SALT_CLUSTER="geeko" SALTMASTER="saltmaster.$VM_DOMAIN" ;; *) echo echo "Location not found - switching to manual mode..." echo "Hope, you know what you do. Otherwise use [CTRL]+C" echo echo -n "List of DNS Servers (use whitespace) : " read NAMESERVERS echo -n "Default route setting : " read ROUTES echo -n "IPv4 address (+/mask) of the machine : " read VM_IP_FULL echo -n "IPv4 address of the machine : " read VM_IP echo -n "IPv4 address of the remote syslog : " read SYSLOG_SERVER echo -n "DNS Domain, the machine is located in: " read VM_DOMAIN echo -n "The Salt Cluster name to join : " read SALT_CLUSTER echo -n "DNS Name of the Salt-Master : " read SALTMASTER echo ;; esac # # Network # sed -i -e "s/\(NETCONFIG_FORCE_REPLACE=\"\)yes/\1no/" \ -e "s/\(NETCONFIG_DNS_RESOLVER_OPTIONS=\"\)/\1attempts:1 timeout:1 rotate/" \ -e "s/\(DNS_STATIC_SERVERS=\"\)/\1$NAMESERVERS/" \ -e "s/\(NETCONFIG_MODULES_ORDER=\"\)/\1-dns-resolver -dns-bind -dns-dnsmasq -nis -ntp-runtime/" \ -e "s/\(SEARCHLIST=\"\)/\1$VM_DOMAIN/" /etc/sysconfig/network/config if $(ip link show | grep -q private); then sed -i -e "s#VM_IP#$VM_IP_FULL#" /etc/sysconfig/network/ifcfg-private rm /etc/sysconfig/network/ifcfg-eth0 elif $(ip link show | grep -q eth0 ); then sed -i -e "s#VM_IP#$VM_IP_FULL#" /etc/sysconfig/network/ifcfg-eth0 rm /etc/sysconfig/network/ifcfg-private fi echo "$ROUTES" > /etc/sysconfig/network/routes # # remote rsyslog # echo "${SYSLOG_SERVER} syslog.${VM_DOMAIN}" >> /etc/hosts # # Hostname # echo "$VM_HOSTNAME" > /etc/hostname # # Salt # echo "$VM_HOSTNAME.$VM_DOMAIN" >> /etc/salt/minion_id echo "salt_cluster: $SALT_CLUSTER" > /etc/salt/grains echo -e "master: $SALTMASTER\nenvironment: production\nhash_type: sha512" >> /etc/salt/minion # # Services # for service in salt-minion sshd; do systemctl enable $service; done # # Monitoring # sed -i -e "s|^#server_address=127.0.0.1|server_address=${VM_IP}|g" /etc/nrpe.cfg systemctl reload nrpe.service # # Grub2 # sed -i "s|GRUB_TIMEOUT=10|GRUB_TIMEOUT=2|g" /etc/default/grub /usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg # # reboot # zypper -n rm opensuse-infrastructure-vm-bootstrap reboot
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor