]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
cobbler: Modify snippets to work with OpenSUSE Leap 15.0
authorDavid Galloway <dgallowa@redhat.com>
Tue, 2 Oct 2018 18:39:21 +0000 (14:39 -0400)
committerDavid Galloway <dgallowa@redhat.com>
Tue, 2 Oct 2018 19:01:17 +0000 (15:01 -0400)
The usermod command is a little different in OpenSUSE.

Also, in Leap, the /etc/rc.local equivalent is /etc/init.d/boot.local.

Signed-off-by: David Galloway <dgallowa@redhat.com>
roles/cobbler/templates/snippets/cephlab_rc_local
roles/cobbler/templates/snippets/cephlab_user

index 3f92e7b0316218657c789c5cf0d6dc7d50e3c796..0f95ba7ec3925236c5d63a530903665d5337f433 100644 (file)
@@ -5,6 +5,8 @@
 #set distro_ver = $getVar('distro','').split("-")[1]
 #if $distro == 'Fedora' and int($distro_ver) >= 22
 #set script = '/etc/rc.d/rc.local'
+#else if $distro == 'openSUSE'
+#set script = '/etc/init.d/boot.local'
 #else
 #set script = '/etc/rc.local'
 #end if
@@ -17,17 +19,23 @@ exec 1>&2
 set -ex
 
 {% if rclocal_nameserver is defined %}
-#raw
 if [ ! -f /.cephlab_net_configured ]; then
+#if $distro == 'openSUSE'
+  udevadm trigger
+  sleep 5
+#end if
+#raw
   nics=$(ls -1 /sys/class/net | grep -v lo)
 
   for nic in $nics; do
     # Bring the NIC up so we can detect if a link is present
-    ifconfig $nic up
+    ifconfig $nic up || ip link set $nic up
     # Sleep for a bit to let the NIC come up
     sleep 5
     if ethtool $nic | grep -q "Link detected: yes"; then
-      if command -v apt-get &>/dev/null; then
+      if command -v zypper &>/dev/null; then
+        echo -e "DEVICE=$nic\nBOOTPROTO=dhcp\nONBOOT=yes" > /etc/sysconfig/network/ifcfg-$nic
+      elif command -v apt-get &>/dev/null; then
         echo -e "auto lo\niface lo inet loopback\n\nauto $nic\niface $nic inet dhcp" > /etc/network/interfaces
       else
         echo -e "DEVICE=$nic\nBOOTPROTO=dhcp\nONBOOT=yes" > /etc/sysconfig/network-scripts/ifcfg-$nic
@@ -62,7 +70,7 @@ if [ ! -f /.cephlab_net_configured ]; then
       fi
     else
       # Take the NIC back down if it's not connected
-      ifconfig $nic down
+      ifconfig $nic down || ip link set $nic down
     fi
   done
 fi
@@ -108,7 +116,12 @@ fi
 {% endif %}
 
 # Regenerate SSH host keys on boot if needed
-if command -v apt-get &>/dev/null; then
+if command -v zypper &> /dev/null; then
+  if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
+    ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa
+    systemctl restart sshd
+  fi
+elif command -v apt-get &>/dev/null; then
   if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
      dpkg-reconfigure openssh-server
   fi
index 983cce775032ea297e289aa505cc3f6df40da7ea..4b03b89a2444e4b0327174e2a8999f4bf3c95ab7 100644 (file)
@@ -3,7 +3,13 @@
 #set $home = '/home/' + $user
 #set $auth_keys = $home + '/.ssh/authorized_keys'
 groupadd sudo
+#set distro = $getVar('distro','').split("-")[0]
+#set distro_ver = $getVar('distro','').split("-")[1]
+#if $distro == 'openSUSE'
+useradd -U -u {{ cm_user_uid }} -G sudo $user
+#else
 useradd -u {{ cm_user_uid }} -G sudo $user
+#end if
 passwd -d $user
 
 cat >> /etc/sudoers.d/cephlab_sudo << EOF