summaryrefslogtreecommitdiffstats
path: root/lib/sunhpc/modules
diff options
context:
space:
mode:
authorxiubuzhe <xiubuzhe@sina.com>2023-10-08 20:59:00 +0800
committerxiubuzhe <xiubuzhe@sina.com>2023-10-08 20:59:00 +0800
commit1dac2263372df2b85db5d029a45721fa158a5c9d (patch)
tree0365f9c57df04178a726d7584ca6a6b955a7ce6a /lib/sunhpc/modules
parentb494be364bb39e1de128ada7dc576a729d99907e (diff)
downloadsunhpc-1dac2263372df2b85db5d029a45721fa158a5c9d.tar.gz
sunhpc-1dac2263372df2b85db5d029a45721fa158a5c9d.tar.bz2
sunhpc-1dac2263372df2b85db5d029a45721fa158a5c9d.zip
first add files
Diffstat (limited to 'lib/sunhpc/modules')
-rw-r--r--lib/sunhpc/modules/__init__.py0
-rw-r--r--lib/sunhpc/modules/compute/00_selinux.py11
-rw-r--r--lib/sunhpc/modules/compute/__init__.py0
-rw-r--r--lib/sunhpc/modules/control/00-base.py191
-rw-r--r--lib/sunhpc/modules/control/05-securtiy.py98
-rw-r--r--lib/sunhpc/modules/control/50-packages.py94
-rw-r--r--lib/sunhpc/modules/control/__init__.py0
-rw-r--r--lib/sunhpc/modules/kickstart/00-base.py79
-rw-r--r--lib/sunhpc/modules/kickstart/05-partition.py42
-rw-r--r--lib/sunhpc/modules/kickstart/10-hostauth.py62
-rw-r--r--lib/sunhpc/modules/kickstart/12-security.py147
-rw-r--r--lib/sunhpc/modules/kickstart/15-network.py40
-rw-r--r--lib/sunhpc/modules/kickstart/20-scripts.py161
-rw-r--r--lib/sunhpc/modules/kickstart/30-services.py59
-rw-r--r--lib/sunhpc/modules/kickstart/50-packages.py98
-rw-r--r--lib/sunhpc/modules/kickstart/60-addons.py30
-rw-r--r--lib/sunhpc/modules/kickstart/62-anaconda.py32
-rw-r--r--lib/sunhpc/modules/kickstart/64-pxeboot.py39
-rw-r--r--lib/sunhpc/modules/kickstart/__init__.py0
19 files changed, 1183 insertions, 0 deletions
diff --git a/lib/sunhpc/modules/__init__.py b/lib/sunhpc/modules/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/lib/sunhpc/modules/__init__.py
diff --git a/lib/sunhpc/modules/compute/00_selinux.py b/lib/sunhpc/modules/compute/00_selinux.py
new file mode 100644
index 0000000..13f4558
--- /dev/null
+++ b/lib/sunhpc/modules/compute/00_selinux.py
@@ -0,0 +1,11 @@
+#coding:utf-8
+
+class Modules(object):
+ def __init__(self, command):
+ self.cmd = command
+
+ def run(self, args):
+ print ('this is compute selinux modules....')
+
+ def __repr__(self):
+ return "selinux"
diff --git a/lib/sunhpc/modules/compute/__init__.py b/lib/sunhpc/modules/compute/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/lib/sunhpc/modules/compute/__init__.py
diff --git a/lib/sunhpc/modules/control/00-base.py b/lib/sunhpc/modules/control/00-base.py
new file mode 100644
index 0000000..a539411
--- /dev/null
+++ b/lib/sunhpc/modules/control/00-base.py
@@ -0,0 +1,191 @@
+#coding:utf-8
+import time
+import sunhpc
+class Modules(object):
+ """
+ Configure base for the sunhpc cluster
+ """
+ def __init__(self, command):
+ self.cmd = command
+ @property
+ def __help__(self):
+ info = """
+ #==============================================================
+ # %s
+ #
+ # module_path: %s
+ # module_name: %s
+ #==============================================================
+ """ % (self.__doc__.strip(), self.__module__.strip(), self.__repr__())
+ return info
+
+ def run(self, args):
+
+ content = []
+ content.append(self.__help__)
+
+ # hostname setting
+ hostname = self.cmd.db.getHostAttr('localhost', 'Kickstart_PublicHostname')
+ hostname_info = "hostnamectl --static set-hostname %s" % hostname
+ content.append(hostname_info)
+
+ # selinux config
+ selinux = '/etc/selinux/config'
+ selinux_info = """
+ #
+ # Generated by sunhpc selinux module.
+ #
+ # This file controls the state of SELinux on the system.
+ # SELINUX= can take one of these three values:
+ # enforcing - SELinux security policy is enforced.
+ # permissive - SELinux prints warnings instead of enforcing.
+ # disabled - No SELinux policy is loaded.
+ SELINUX=disabled
+ # SELINUXTYPE= can take one of three values:
+ # targeted - Targeted processes are protected,
+ # minimum - Modification of targeted policy. Only selected processes are protected.
+ # mls - Multi Level Security protection.
+ SELINUXTYPE=targeted
+ """
+ content.append(self.cmd.ks.makefile(selinux_info, selinux))
+
+ # hosts
+ hostfile = '/etc/hosts'
+ hostinfo = self.cmd.command('report.host').strip()
+ content.append(self.cmd.ks.makefile(hostinfo, hostfile))
+
+
+ # resolv
+ resolv = '/etc/resolv.conf'
+ search_lan = self.cmd.db.getHostAttr('localhost', 'Kickstart_PrivateDNSDomain')
+ search_wan = self.cmd.db.getHostAttr('localhost', 'Kickstart_PublicDNSDomain')
+ public_dns = self.cmd.db.getHostAttr('localhost', 'Kickstart_PublicDNSServer')
+ resolv_info = """
+ search %s %s
+ nameserver %s
+ nameserver 223.5.5.5
+ """ % (search_lan, search_wan, public_dns)
+ content.append(self.cmd.ks.makefile(resolv_info, resolv))
+
+ # motd
+ tnow = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())
+ motd = '/etc/motd'
+ motd_info = """
+ SunhpcOS %s (%s)
+ Profile built %s
+
+ _____ _
+ / ____| | |
+ ======= | (___ _ _ _ __ | |__ _ __ ___
+ \ // \___ \| | | | '_ \| '_ \| '_ \ / __|
+ \ // ___ ) | |_| | | | | | | | |_) | (__
+ \// |_____/ \__,_|_| |_|_| |_| .__/ \___|
+ | |
+ Powered by HengPU Technology |_| By kylins
+
+ PlatName : HengPu High Performance Computing Platform
+ WeChat : xiubuzhe
+ Version : %s (%s)
+ Email : info@sunhpc.com
+ Phone : +86 18640977650
+ Homepage : https://www.sunhpc.com - @kylins
+ -----------------------------------------------------
+
+
+ """ % (sunhpc.version, sunhpc.release, tnow, sunhpc.version, sunhpc.release)
+ content.append(self.cmd.ks.makefile(motd_info, motd))
+
+ # sunhpc-release
+ rels = '/etc/sunhpc-release'
+ rels_info = "SunhpcOS %s" % sunhpc.version
+ content.append(self.cmd.ks.makefile(rels_info, rels))
+
+ # sys-release
+ sysrels = '/etc/system-release'
+ sysrels_info = "SunhpcOS Linux release %s (%s)" % (sunhpc.version, sunhpc.release)
+ content.append(self.cmd.ks.makefile(sysrels_info, sysrels))
+
+ # os-release
+ osrels = '/etc/os-release'
+ osrels_info = """
+ NAME="SunHPC Linux"
+ VERSION="%s (%s)"
+ ID="sunhpc"
+ ID_LIKE="rhel fedora"
+ VERSION_ID="%s"
+ PRETTY_NAME="SunhpcOS Linux %s (%s)"
+ ANSI_COLOR="0;31"
+ CPE_NAME="cpe:/o:sunhpc:sunhpc:%s"
+ HOME_URL="https://www.sunhpc.com/"
+ BUG_REPORT_URL="https://bugs.sunhpc.com/"
+
+ CENTOS_MANTISBT_PROJECT="SunhpcOS-%s"
+ CENTOS_MANTISBT_PROJECT_VERSION="%s"
+ REDHAT_SUPPORT_PRODUCT="sunhpc"
+ REDHAT_SUPPORT_PRODUCT_VERSION="%s"
+ """ % (self.cmd.major, sunhpc.release,
+ self.cmd.major, self.cmd.major, sunhpc.release,
+ self.cmd.major, self.cmd.major, self.cmd.major,
+ self.cmd.major)
+ content.append(self.cmd.ks.makefile(osrels_info, osrels))
+
+ # issue
+ issue = '/etc/issue'
+ issue_net = '/etc/issue.net'
+ issue_info = """
+ \S
+ Kernel \r on an \m
+ Current times \d \t
+
+ _____ _
+ / ____| | |
+ ======= | (___ _ _ _ __ | |__ _ __ ___
+ \\ // \\___ \\| | | | '_ \\| '_ \\| '_ \\ / __|
+ \\ // ___ ) | |_| | | | | | | | |_) | (__
+ \\// |_____/ \\__,_|_| |_|_| |_| .__/ \\___|
+ | |
+ Powered by HengPU Technology |_| By kylins
+
+ PlatName : HengPu High Performance Computing Platform
+ WeChat : xiubuzhe
+ Version : %s (%s)
+ Email : info@sunhpc.com
+ Phone : +86 18640977650
+ Homepage : https://www.sunhpc.com - @kylins
+ -----------------------------------------------------
+
+ """ % (sunhpc.version, sunhpc.release)
+ content.append(self.cmd.ks.makefile(issue_info, issue))
+ content.append(self.cmd.ks.makefile(issue_info, issue_net))
+
+ self.cmd.ks.addMain(content)
+ def __repr__(self):
+ return "control-base"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/sunhpc/modules/control/05-securtiy.py b/lib/sunhpc/modules/control/05-securtiy.py
new file mode 100644
index 0000000..ab71cc4
--- /dev/null
+++ b/lib/sunhpc/modules/control/05-securtiy.py
@@ -0,0 +1,98 @@
+#coding:utf-8
+import time
+import sunhpc
+class Modules(object):
+ """
+ Configure base for the sunhpc cluster
+ """
+ def __init__(self, command):
+ self.cmd = command
+ @property
+ def __help__(self):
+ info = """
+ #==============================================================
+ # %s
+ #
+ # module_path: %s
+ # module_name: %s
+ #==============================================================
+ """ % (self.__doc__.strip(), self.__module__.strip(), self.__repr__())
+ return info
+
+ def run(self, args):
+
+ content = []
+ content.append(self.__help__)
+
+ # create rsa keys
+ rsa_command = "sunhpc create security keyname=rsa"
+ content.append(rsa_command)
+
+ ssh_config = '/etc/ssh/ssh_config'
+ ssh_config_info = """
+ Host *
+ CheckHostIP no
+ ForwardX11 yes
+ ForwardAgent yes
+ StrictHostKeyChecking no
+ UsePrivilegedPort no
+ Protocol 2,1
+ HostbasedAuthentication yes
+ EnableSSHKeySign yes
+ """
+ content.append(self.cmd.ks.makefile(ssh_config_info, ssh_config))
+
+
+ sshd_config = '/etc/ssh/sshd_config'
+ sshd_config_info = """
+ Match User root
+ HostbasedAuthentication no
+ """
+ content.append(self.cmd.ks.makefile(sshd_config_info, sshd_config, mode="append"))
+
+ root_info = """
+ ROOTRSAKEY=/root/.ssh/id_rsa
+ if [ ! -f $ROOTRSAKEY ]; then
+ /usr/bin/ssh-keygen -q -t rsa -P '' -f $ROOTRSAKEY
+ fi
+
+ mkdir -p /etc/ssh/authorized_keys
+ AUTHKEYS = /etc/ssh/authorized_keys/id_rsa.pub
+ if [ ! -f $AUTHKEYS ]; then
+ /usr/bin/cat /root/.ssh/id_rsa.pub > $AUTHKEYS
+ fi
+ """
+ content.append(root_info)
+
+
+ self.cmd.ks.addMain(content)
+ def __repr__(self):
+ return "control-base"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/sunhpc/modules/control/50-packages.py b/lib/sunhpc/modules/control/50-packages.py
new file mode 100644
index 0000000..28bbf5c
--- /dev/null
+++ b/lib/sunhpc/modules/control/50-packages.py
@@ -0,0 +1,94 @@
+#coding:utf-8
+import textwrap
+class Modules(object):
+ """
+ Configure nodes packages.
+ """
+ def __init__(self, command):
+ self.cmd = command
+
+ @property
+ def __help__(self):
+ info = """
+ #==============================================================
+ # %s
+ #
+ # module_path: %s
+ # module_name: %s
+ #==============================================================
+ """ % (self.__doc__.strip(), self.__module__.strip(), self.__repr__())
+ return info
+
+ def run(self, args):
+
+ must_package = ['libffi-devel']
+
+
+ content = []
+ content.append(self.__help__)
+ #@^gnome-desktop-environment
+ parts = """
+ @^developer-workstation-environment
+ @additional-devel
+ @base
+ @compat-libraries
+ @core
+ @debugging
+ @desktop-debugging
+ @development
+ @dial-up
+ @directory-client
+ @fonts
+ @gnome-apps
+ @gnome-desktop
+ @guest-agents
+ @guest-desktop-agents
+ @hardware-monitoring
+ @identity-management-server
+ @infiniband
+ @input-methods
+ @internet-applications
+ @internet-browser
+ @java-platform
+ @large-systems
+ @multimedia
+ @network-file-system-client
+ @performance
+ @perl-runtime
+ @perl-web
+ @php
+ @platform-devel
+ @print-client
+ @python-web
+ @ruby-runtime
+ @system-admin-tools
+ @virtualization-client
+ @virtualization-hypervisor
+ @virtualization-tools
+ @web-server
+ @x11
+ """
+
+ mini = """
+ @^minimal
+ wget
+ net-tools
+ libffi-devel
+ """
+ content.append(mini)
+ self.cmd.ks.addPackages(content)
+
+ def __repr__(self):
+ return "kickstart-packages"
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/sunhpc/modules/control/__init__.py b/lib/sunhpc/modules/control/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/lib/sunhpc/modules/control/__init__.py
diff --git a/lib/sunhpc/modules/kickstart/00-base.py b/lib/sunhpc/modules/kickstart/00-base.py
new file mode 100644
index 0000000..e07100e
--- /dev/null
+++ b/lib/sunhpc/modules/kickstart/00-base.py
@@ -0,0 +1,79 @@
+#coding:utf-8
+import textwrap
+class Modules(object):
+ """
+ base config module.
+ """
+ def __init__(self, command):
+ self.cmd = command
+
+ @property
+ def __help__(self):
+ info = """
+ #==============================================================
+ # %s
+ #
+ # module_path: %s
+ # module_name: %s
+ #==============================================================
+ """ % (self.__doc__.strip(), self.__module__.strip(), self.__repr__())
+ return info
+
+ def run(self, args):
+
+ addr = self.cmd.db.getHostAttr('localhost', 'Kickstart_PrivateAddress')
+ base = self.cmd.db.getHostAttr('localhost', 'Kickstart_BaseDir')
+ dist = self.cmd.db.getHostAttr('localhost', 'distribution')
+ http = "http://%s/%s/%s/%s" % (addr, base, dist, self.cmd.arch)
+ zone = self.cmd.db.getHostAttr('localhost', 'Kickstart_Timezone')
+
+ main = ['#', '# sunhpc cluster system for kickstart', '#']
+ main.append(self.__help__)
+
+ # System authorization information
+ main.append('auth --enableshadow --passalgo=sha512')
+
+ # Use URL installation
+ main.append('install')
+ main.append('url --url %s' % http)
+
+ # Use graphical install
+ main.append('graphical')
+
+ # # Keyboard layouts
+ main.append("keyboard --vckeymap=us --xlayouts='us'")
+
+ # System language
+ main.append('lang en_US.UTF-8')
+
+ main.append('eula --agreed')
+
+ # Run the Setup Agent on first boot
+ main.append('firstboot --disable')
+
+ # System timezone
+ main.append('timezone %s --isUtc --nontp' % zone)
+
+ # X Window System configuration information
+ # 请不要在不安装X windows系统中使用下面命令.
+ # --startxonboot - 在安装的系统中使用图形界面登录
+ # main.append('xconfig --startxonboot')
+
+ # System services
+ main.append("services --disabled='chronyd'")
+
+ # Root password
+ passwd = '$6$6oVIU.5y$mAFN7begXFk5A1g0ODIQauIz6na5ja3AM0'
+ passwd += 'QebWc8dLVHmLguPv65nVQbpYR3.w1h6HdfbUkFfhJkv/KNO2Sj3/'
+ main.append('rootpw --iscrypted %s' % passwd)
+
+ # Reboot install finished
+ main.append('reboot')
+
+ # Disk partitioning information
+ main.append('%include /tmp/partition-info')
+
+ self.cmd.ks.addMain(main)
+
+ def __repr__(self):
+ return "kickstart-base"
diff --git a/lib/sunhpc/modules/kickstart/05-partition.py b/lib/sunhpc/modules/kickstart/05-partition.py
new file mode 100644
index 0000000..42ac552
--- /dev/null
+++ b/lib/sunhpc/modules/kickstart/05-partition.py
@@ -0,0 +1,42 @@
+#coding:utf-8
+import textwrap
+class Modules(object):
+ """
+ Client auto partition module.
+ """
+ def __init__(self, command):
+ self.cmd = command
+
+ @property
+ def __help__(self):
+ info = """
+ #==============================================================
+ # %s
+ #
+ # module_path: %s
+ # module_name: %s
+ #==============================================================
+ """ % (self.__doc__.strip(), self.__module__.strip(), self.__repr__())
+ return info
+
+ def run(self, args):
+
+ content = []
+ content.append(self.__help__)
+
+ parts = """
+ /bin/echo "sunhpc force-default" > /tmp/user_partition_info
+
+ if [ ! -f /tmp/do_partition.py ]
+ then
+ /bin/cat /applets/partition.py > /tmp/do_partition.py
+ fi
+
+ /bin/chmod 755 /tmp/do_partition.py
+ /tmp/do_partition.py
+ """
+ content.append(parts)
+ self.cmd.ks.addPre(content)
+
+ def __repr__(self):
+ return "kickstart-partition"
diff --git a/lib/sunhpc/modules/kickstart/10-hostauth.py b/lib/sunhpc/modules/kickstart/10-hostauth.py
new file mode 100644
index 0000000..4ffdbc4
--- /dev/null
+++ b/lib/sunhpc/modules/kickstart/10-hostauth.py
@@ -0,0 +1,62 @@
+#coding:utf-8
+import textwrap
+class Modules(object):
+ """
+ Configure sshd, authorized, rsa and so on.
+ """
+ def __init__(self, command):
+ self.cmd = command
+
+ @property
+ def __help__(self):
+ info = """
+ #==============================================================
+ # %s
+ #
+ # module_path: %s
+ # module_name: %s
+ #==============================================================
+ """ % (self.__doc__.strip(), self.__module__.strip(), self.__repr__())
+ return info
+
+ def run(self, args):
+
+ text = ''
+ # get root's public keys
+ public = '/etc/ssh/authorized_keys/id_rsa.pub'
+ try:
+ with open(public, 'r') as f:
+ for key in f.readlines():
+ if len(key) > 0:
+ text = key[:-1]
+ except:
+ pass
+
+ content = []
+ content.append(self.__help__)
+
+ parts = """
+ [ ! -e /root/.ssh ] && mkdir -p /root/.ssh
+ chmod -R 700 /root/.ssh
+
+ cat > /root/.ssh/authorized_keys << 'EOF'
+ %s
+ EOF
+ chmod 600 /root/.ssh/authorized_keys
+
+ ifconfig virbr0 down
+ brctl delbr virbr0
+ systemctl disable libvirtd.service
+
+ sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
+
+ systemctl set-default multi-user.target
+
+ systemctl enable autofs
+ """ % (text)
+
+ content.append(parts)
+ self.cmd.ks.addPost(content)
+
+ def __repr__(self):
+ return "kickstart-secret"
diff --git a/lib/sunhpc/modules/kickstart/12-security.py b/lib/sunhpc/modules/kickstart/12-security.py
new file mode 100644
index 0000000..42ae555
--- /dev/null
+++ b/lib/sunhpc/modules/kickstart/12-security.py
@@ -0,0 +1,147 @@
+#coding:utf-8
+import time
+import sunhpc
+class Modules(object):
+ """
+ Configure sunhpc cluster security.
+ """
+ def __init__(self, command):
+ self.cmd = command
+
+ @property
+ def __help__(self):
+ info = """
+ #==============================================================
+ # %s
+ #
+ # module_path: %s
+ # module_name: %s
+ #==============================================================
+ """ % (self.__doc__.strip(), self.__module__.strip(), self.__repr__())
+ return info
+
+ def run(self, args):
+
+ content = [self.__help__]
+
+ # master.pub and shared.key
+ try:
+ nodeid = self.cmd.newdb.getNodeId(args)
+ except:
+ nodeid = None
+
+ if nodeid:
+ mkeys = '/etc/safe-security/master.pub'
+ skeys = '/etc/safe-security/shared.key'
+ with open(mkeys, 'r') as f: mtext = f.read()
+ with open(skeys, 'r') as f: stext = f.read()
+
+ content.append(
+ self.cmd.ks.makefile(
+ mtext, mkeys, perms="444", owner="root:root"))
+ content.append(
+ self.cmd.ks.makefile(
+ stext, skeys, perms="400", owner="root:root"))
+
+ # ssh config not autogen ssh keys
+ # check /usr/sbin/sshd-keygen
+ sshd_file = "/etc/sysconfig/sshd"
+ sshconfig = """
+ # Configuration file for the sshd service.
+
+ # The server keys are automatically generated if they are missing.
+ # To change the automatic creation uncomment and change the appropriate
+ # line. Accepted key types are: DSA RSA ECDSA ED25519.
+ # The default is "RSA ECDSA ED25519"
+
+ AUTOCREATE_SERVER_KEYS="NO"
+ # AUTOCREATE_SERVER_KEYS="RSA ECDSA ED25519"
+
+ # Do not change this option unless you have hardware random
+ # generator and you REALLY know what you are doing
+
+ SSH_USE_STRONG_RNG=0
+ # SSH_USE_STRONG_RNG=1
+ """
+ content.append(self.cmd.ks.makefile(sshconfig, sshd_file, perms="640", owner="root.root"))
+
+ # /etc/safe.conf
+ address = self.cmd.db.getHostAttr('localhost', 'Kickstart_PrivateAddress')
+ safeport = self.cmd.db.getHostAttr('localhost', 'safeport')
+ safedirs = self.cmd.db.getHostAttr('localhost', 'safedirs')
+ safe_file = '/etc/safe.conf'
+ safe_conf = """
+ <!-- Safe security configuration -->
+ <config>
+ <url>http://%s</url>
+ <port>%s</port>
+ <urldir>%s</urldir>
+ </config>
+ """ % (address, safeport, safedirs)
+ content.append(self.cmd.ks.makefile(safe_conf, safe_file, perms="644", owner="root.root"))
+
+ # safeGet
+ safe_info = """
+ if [ -f /opt/sunhpc/sbin/safeGet ];then
+ /opt/sunhpc/sbin/safeGet --all
+ else
+ echo "Error safeGet command not found." >> /tmp/sunhpc.log
+ fi
+
+ /usr/bin/chown root:ssh_keys /etc/ssh/ssh_host_ecdsa_key
+ /usr/bin/chown root:ssh_keys /etc/ssh/ssh_host_ed25519_key
+ /usr/bin/chown root:ssh_keys /etc/ssh/ssh_host_rsa_key
+ """
+ content.append(safe_info)
+
+ ssh_config = '/etc/ssh/ssh_config'
+ ssh_info = """
+ Host *
+ CheckHostIP no
+ ForwardX11 yes
+ ForwardAgent yes
+ StrictHostKeyChecking no
+ UsePrivilegedPort no
+ Protocol 2,1
+ HostbasedAuthentication yes
+ EnableSSHKeySign yes
+ """
+ content.append(self.cmd.ks.makefile(ssh_info, ssh_config, perms="644", owner="root.root"))
+
+ sshd_info = """
+ echo "MaxStartups 1280" >> /etc/ssh/sshd_config
+ echo "Match User root" >> /etc/ssh/sshd_config
+ echo " HostbasedAuthentication no" >> /etc/ssh/sshd_config
+ """
+ content.append(sshd_info)
+
+ # memory sysctl
+ mem_info = """
+ SHMSIZE=`gawk '/MemTotal:/ { printf("(%s/4) * (3 * 1024)\\n", $2); }' /proc/meminfo | bc`
+ if [ $SHMSIZE ]
+ then
+ echo "kernel.shmmax = " $SHMSIZE >> /etc/sysctl.conf
+ fi
+
+ """
+ content.append(mem_info)
+
+ self.cmd.ks.addPost(content)
+ def __repr__(self):
+ return "kickstart-security"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/sunhpc/modules/kickstart/15-network.py b/lib/sunhpc/modules/kickstart/15-network.py
new file mode 100644
index 0000000..22e3cca
--- /dev/null
+++ b/lib/sunhpc/modules/kickstart/15-network.py
@@ -0,0 +1,40 @@
+#coding:utf-8
+import textwrap
+class Modules(object):
+ """
+ Configure node networks.
+ """
+ def __init__(self, command):
+ self.cmd = command
+
+ @property
+ def __help__(self):
+ info = """
+ #==============================================================
+ # %s
+ #
+ # module_path: %s
+ # module_name: %s
+ #==============================================================
+ """ % (self.__doc__.strip(), self.__module__.strip(), self.__repr__())
+ return info
+
+ def run(self, args):
+
+ # network --bootproto=static
+ # --device=eth0
+ # --gateway=192.168.199.1
+ # --ip=192.168.199.155
+ # --nameserver=192.168.199.1
+ # --netmask=255.255.255.0
+ # --ipv6=auto --activate
+ # --hostname=cluster
+
+ network = []
+ network.append(self.__help__)
+ #network.append('network --bootproto=static --hostname=%s --activate' % args)
+ network.append('network --hostname=%s' % args)
+ self.cmd.ks.addMain(network)
+
+ def __repr__(self):
+ return "kickstart-network"
diff --git a/lib/sunhpc/modules/kickstart/20-scripts.py b/lib/sunhpc/modules/kickstart/20-scripts.py
new file mode 100644
index 0000000..ab86dac
--- /dev/null
+++ b/lib/sunhpc/modules/kickstart/20-scripts.py
@@ -0,0 +1,161 @@
+#coding:utf-8
+import time
+import sunhpc
+class Modules(object):
+ """
+ Configure yum repos, /etc/hosts.
+ """
+ def __init__(self, command):
+ self.cmd = command
+
+ @property
+ def __help__(self):
+ info = """
+ #==============================================================
+ # %s
+ #
+ # module_path: %s
+ # module_name: %s
+ #==============================================================
+ """ % (self.__doc__.strip(), self.__module__.strip(), self.__repr__())
+ return info
+
+ def run(self, args):
+
+ #
+ # self.cmd.ks.makefile
+ # args:
+ # text, type:list
+ # name, type:file path
+ # mode, owner, perms, expr, quot
+ #
+
+ contents = [self.__help__]
+ repofile = "/etc/yum.repos.d/sunhpc-local.repo"
+ with open(repofile, 'r') as fe:
+ repotext = fe.readlines()
+ contents.append(self.cmd.ks.makefile(repotext, repofile))
+
+ # hosts
+ hostfile = '/etc/hosts'
+ hostinfo = self.cmd.command('report.host').strip()
+ contents.append(self.cmd.ks.makefile(hostinfo, hostfile))
+
+
+ # resolv
+ resolv = '/etc/resolv.conf'
+ landns = "nameserver %s" % self.cmd.db.getHostAttr(
+ 'localhost', 'Kickstart_PrivateDNSServer')
+ contents.append(self.cmd.ks.makefile(landns, resolv))
+
+
+ # selinux
+ selinux = '/etc/selinux/config'
+ selinux_info = """
+ # This file controls the state of SELinux on the system.
+ # SELINUX= can take one of these three values:
+ # enforcing - SELinux security policy is enforced.
+ # permissive - SELinux prints warnings instead of enforcing.
+ # disabled - No SELinux policy is loaded.
+ SELINUX=disabled
+ # SELINUXTYPE= can take one of three two values:
+ # targeted - Targeted processes are protected,
+ # minimum - Modification of targeted policy. Only selected processes are protected.
+ # mls - Multi Level Security protection.
+ SELINUXTYPE=targeted
+ """
+ contents.append(self.cmd.ks.makefile(selinux_info, selinux))
+
+ # motd
+ tnow = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())
+ motd = '/etc/motd'
+ motd_info = """
+ SunhpcOS %s (%s)
+ Profile built %s
+
+ """ % (sunhpc.version, sunhpc.release, tnow)
+ contents.append(self.cmd.ks.makefile(motd_info, motd))
+
+ # sunhpc-release
+ rels = '/etc/sunhpc-release'
+ rels_info = "SunhpcOS %s" % sunhpc.version
+ contents.append(self.cmd.ks.makefile(rels_info, rels))
+
+ # sys-release
+ sysrels = '/etc/system-release'
+ sysrels_info = "SunhpcOS Linux release %s (%s)" % (sunhpc.version, sunhpc.release)
+ contents.append(self.cmd.ks.makefile(sysrels_info, sysrels))
+
+ # os-release
+ osrels = '/etc/os-release'
+ osrels_info = """
+ NAME="SunHPC Linux"
+ VERSION="%s (%s)"
+ ID="sunhpc"
+ ID_LIKE="rhel fedora"
+ VERSION_ID="%s"
+ PRETTY_NAME="SunhpcOS Linux %s (%s)"
+ ANSI_COLOR="0;31"
+ CPE_NAME="cpe:/o:sunhpc:sunhpc:%s"
+ HOME_URL="https://www.sunhpc.com/"
+ BUG_REPORT_URL="https://bugs.sunhpc.com/"
+
+ CENTOS_MANTISBT_PROJECT="SunhpcOS-%s"
+ CENTOS_MANTISBT_PROJECT_VERSION="%s"
+ REDHAT_SUPPORT_PRODUCT="sunhpc"
+ REDHAT_SUPPORT_PRODUCT_VERSION="%s"
+ """ % (self.cmd.major, sunhpc.release,
+ self.cmd.major, self.cmd.major, sunhpc.release,
+ self.cmd.major, self.cmd.major, self.cmd.major,
+ self.cmd.major)
+ contents.append(self.cmd.ks.makefile(osrels_info, osrels))
+
+ # issue
+ issue = '/etc/issue'
+ issue_net = '/etc/issue.net'
+ issue_info = """
+ \S
+ Kernel \\r on an \m
+ Current times \d \\t
+
+ _____ _
+ / ____| | |
+ ======= | (___ _ _ _ __ | |__ _ __ ___
+ \\\ // \\\___ \\\| | | | '_ \\\| '_ \\\| '_ \\\ / __|
+ \\\ // ___ ) | |_| | | | | | | | |_) | (__
+ \\\// |_____/ \\\__,_|_| |_|_| |_| .__/ \\\___|
+ | |
+ Powered by HengPU Technology |_| By kylins
+
+ PlatName : HengPu High Performance Computing Platform
+ WeChat : xiubuzhe
+ Version : %s (%s)
+ Email : info@sunhpc.com
+ Phone : +86 18640977650
+ Homepage : https://www.sunhpc.com - @kylins
+ -----------------------------------------------------
+
+ """ % (sunhpc.version, sunhpc.release)
+ contents.append(self.cmd.ks.makefile(issue_info, issue))
+ contents.append(self.cmd.ks.makefile(issue_info, issue_net))
+
+
+ self.cmd.ks.addPost(contents)
+ def __repr__(self):
+ return "kickstart-auxiliary"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/sunhpc/modules/kickstart/30-services.py b/lib/sunhpc/modules/kickstart/30-services.py
new file mode 100644
index 0000000..7d56ca2
--- /dev/null
+++ b/lib/sunhpc/modules/kickstart/30-services.py
@@ -0,0 +1,59 @@
+#coding:utf-8
+import time
+import sunhpc
+class Modules(object):
+ """
+ Configure sunhpc compute node services.
+ """
+ def __init__(self, command):
+ self.cmd = command
+
+ @property
+ def __help__(self):
+ info = """
+ #==============================================================
+ # %s
+ #
+ # module_path: %s
+ # module_name: %s
+ #==============================================================
+ """ % (self.__doc__.strip(), self.__module__.strip(), self.__repr__())
+ return info
+
+ def run(self, args):
+
+ #
+ # self.cmd.ks.makefile
+ # args:
+ # text, type:list
+ # name, type:file path
+ # mode, owner, perms, expr, quot
+ #
+
+ content = [self.__help__]
+
+ # Autofs
+ autofs_info = """
+ sed -i 's/mount_nfs_default_protocol = 4/mount_nfs_default_protocol = 3/g' /etc/autofs.conf
+ """
+ content.append(autofs_info)
+
+ self.cmd.ks.addPost(content)
+ def __repr__(self):
+ return "kickstart-services"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/sunhpc/modules/kickstart/50-packages.py b/lib/sunhpc/modules/kickstart/50-packages.py
new file mode 100644
index 0000000..020e0bc
--- /dev/null
+++ b/lib/sunhpc/modules/kickstart/50-packages.py
@@ -0,0 +1,98 @@
+#coding:utf-8
+import textwrap
+class Modules(object):
+ """
+ Configure nodes packages.
+ """
+ def __init__(self, command):
+ self.cmd = command
+
+ @property
+ def __help__(self):
+ info = """
+ #==============================================================
+ # %s
+ #
+ # module_path: %s
+ # module_name: %s
+ #==============================================================
+ """ % (self.__doc__.strip(), self.__module__.strip(), self.__repr__())
+ return info
+
+ def run(self, args):
+
+ content = []
+ content.append(self.__help__)
+ #@^gnome-desktop-environment
+ parts = """
+ @^developer-workstation-environment
+ @additional-devel
+ @base
+ @compat-libraries
+ @core
+ @debugging
+ @desktop-debugging
+ @development
+ @dial-up
+ @directory-client
+ @fonts
+ @gnome-apps
+ @gnome-desktop
+ @guest-agents
+ @guest-desktop-agents
+ @hardware-monitoring
+ @identity-management-server
+ @infiniband
+ @input-methods
+ @internet-applications
+ @internet-browser
+ @java-platform
+ @large-systems
+ @multimedia
+ @network-file-system-client
+ @performance
+ @perl-runtime
+ @perl-web
+ @php
+ @platform-devel
+ @print-client
+ @python-web
+ @ruby-runtime
+ @system-admin-tools
+ @virtualization-client
+ @virtualization-hypervisor
+ @virtualization-tools
+ @web-server
+ @x11
+ """
+
+ mini = """
+ @^minimal
+ wget
+ net-tools
+ libffi-devel
+ libffi-devel*.i686
+ nfs*
+ autofs
+ vim
+ sunhpc-client
+ sunhpc-python
+ """
+ content.append(mini)
+ #content.append(parts)
+ self.cmd.ks.addPackages(content, arg="--multilib --ignoremissing")
+
+ def __repr__(self):
+ return "kickstart-packages"
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/sunhpc/modules/kickstart/60-addons.py b/lib/sunhpc/modules/kickstart/60-addons.py
new file mode 100644
index 0000000..9663b6b
--- /dev/null
+++ b/lib/sunhpc/modules/kickstart/60-addons.py
@@ -0,0 +1,30 @@
+#coding:utf-8
+import textwrap
+class Modules(object):
+ """
+ Configure node kdump.
+ """
+ def __init__(self, command):
+ self.cmd = command
+
+ @property
+ def __help__(self):
+ info = """
+ #==============================================================
+ # %s
+ #
+ # module_path: %s
+ # module_name: %s
+ #==============================================================
+ """ % (self.__doc__.strip(), self.__module__.strip(), self.__repr__())
+ return info
+
+ def run(self, args):
+
+ content = []
+ content.append(self.__help__)
+ content.append("%addon com_redhat_kdump --disable --reserve-mb='auto'")
+ self.cmd.ks.addAddons(content)
+
+ def __repr__(self):
+ return "kickstart-addons"
diff --git a/lib/sunhpc/modules/kickstart/62-anaconda.py b/lib/sunhpc/modules/kickstart/62-anaconda.py
new file mode 100644
index 0000000..bd32ce3
--- /dev/null
+++ b/lib/sunhpc/modules/kickstart/62-anaconda.py
@@ -0,0 +1,32 @@
+#coding:utf-8
+import textwrap
+class Modules(object):
+ """
+ Configure node system pwpolicy.
+ """
+ def __init__(self, command):
+ self.cmd = command
+
+ @property
+ def __help__(self):
+ info = """
+ #==============================================================
+ # %s
+ #
+ # module_path: %s
+ # module_name: %s
+ #==============================================================
+ """ % (self.__doc__.strip(), self.__module__.strip(), self.__repr__())
+ return info
+
+ def run(self, args):
+
+ anaconda = []
+ anaconda.append(self.__help__)
+ anaconda.append("pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty")
+ anaconda.append("pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok")
+ anaconda.append("pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty")
+ self.cmd.ks.addAnaconda(anaconda)
+
+ def __repr__(self):
+ return "kickstart-anaconda"
diff --git a/lib/sunhpc/modules/kickstart/64-pxeboot.py b/lib/sunhpc/modules/kickstart/64-pxeboot.py
new file mode 100644
index 0000000..7f74d7d
--- /dev/null
+++ b/lib/sunhpc/modules/kickstart/64-pxeboot.py
@@ -0,0 +1,39 @@
+#coding:utf-8
+import textwrap
+class Modules(object):
+ """
+ Configure node install pxeboot.
+ """
+ def __init__(self, command):
+ self.cmd = command
+
+ @property
+ def __help__(self):
+ info = """
+ #==============================================================
+ # %s
+ #
+ # module_path: %s
+ # module_name: %s
+ #==============================================================
+ """ % (self.__doc__.strip(), self.__module__.strip(), self.__repr__())
+ return info
+
+ def run(self, args):
+
+ content = []
+ content.append(self.__help__)
+ addr = self.cmd.db.getHostAttr('localhost', 'Kickstart_PrivateAddress')
+ base = self.cmd.db.getHostAttr('localhost', 'Kickstart_BaseDir')
+ http = "http://%s/%s/%s/%s" % (addr, base, 'sbin', 'setPxeboot.cgi')
+
+ setPxeboot = "wget --no-check-certificate -O /dev/null %s" % http
+ content.append(setPxeboot)
+
+ makegrub = "grub2-mkconfig > /boot/grub2/grub.cfg"
+ content.append(makegrub)
+
+ self.cmd.ks.addPost(content)
+
+ def __repr__(self):
+ return "kickstart-pxeboot"
diff --git a/lib/sunhpc/modules/kickstart/__init__.py b/lib/sunhpc/modules/kickstart/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/lib/sunhpc/modules/kickstart/__init__.py