From ed7aaec12d4d6e2d74f3d30f06a15e42ecce89ae Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Wed, 12 Oct 2022 16:42:48 -0700 Subject: [PATCH] distro: Move RHEL 8 SAP config data into sap.go This can be shared between cloud providers so move it out of the EC2 SAP config into its own file and drop the X86_64 from the name (there is nothing arch specific in it, even if it is only ever used on X86). --- internal/distro/rhel8/distro.go | 110 +---------------------------- internal/distro/rhel8/sap.go | 118 ++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 109 deletions(-) create mode 100644 internal/distro/rhel8/sap.go diff --git a/internal/distro/rhel8/distro.go b/internal/distro/rhel8/distro.go index d9666d1a8..c88b0aeb3 100644 --- a/internal/distro/rhel8/distro.go +++ b/internal/distro/rhel8/distro.go @@ -1319,115 +1319,7 @@ func newDistro(distroName string) distro.Distro { } // default EC2-SAP image config (x86_64) - defaultEc2SapImageConfigX86_64 := &distro.ImageConfig{ - SELinuxConfig: &osbuild.SELinuxConfigStageOptions{ - State: osbuild.SELinuxStatePermissive, - }, - // RHBZ#1960617 - Tuned: osbuild.NewTunedStageOptions("sap-hana"), - // RHBZ#1959979 - Tmpfilesd: []*osbuild.TmpfilesdStageOptions{ - osbuild.NewTmpfilesdStageOptions("sap.conf", - []osbuild.TmpfilesdConfigLine{ - { - Type: "x", - Path: "/tmp/.sap*", - }, - { - Type: "x", - Path: "/tmp/.hdb*lock", - }, - { - Type: "x", - Path: "/tmp/.trex*lock", - }, - }, - ), - }, - // RHBZ#1959963 - PamLimitsConf: []*osbuild.PamLimitsConfStageOptions{ - osbuild.NewPamLimitsConfStageOptions("99-sap.conf", - []osbuild.PamLimitsConfigLine{ - { - Domain: "@sapsys", - Type: osbuild.PamLimitsTypeHard, - Item: osbuild.PamLimitsItemNofile, - Value: osbuild.PamLimitsValueInt(1048576), - }, - { - Domain: "@sapsys", - Type: osbuild.PamLimitsTypeSoft, - Item: osbuild.PamLimitsItemNofile, - Value: osbuild.PamLimitsValueInt(1048576), - }, - { - Domain: "@dba", - Type: osbuild.PamLimitsTypeHard, - Item: osbuild.PamLimitsItemNofile, - Value: osbuild.PamLimitsValueInt(1048576), - }, - { - Domain: "@dba", - Type: osbuild.PamLimitsTypeSoft, - Item: osbuild.PamLimitsItemNofile, - Value: osbuild.PamLimitsValueInt(1048576), - }, - { - Domain: "@sapsys", - Type: osbuild.PamLimitsTypeHard, - Item: osbuild.PamLimitsItemNproc, - Value: osbuild.PamLimitsValueUnlimited, - }, - { - Domain: "@sapsys", - Type: osbuild.PamLimitsTypeSoft, - Item: osbuild.PamLimitsItemNproc, - Value: osbuild.PamLimitsValueUnlimited, - }, - { - Domain: "@dba", - Type: osbuild.PamLimitsTypeHard, - Item: osbuild.PamLimitsItemNproc, - Value: osbuild.PamLimitsValueUnlimited, - }, - { - Domain: "@dba", - Type: osbuild.PamLimitsTypeSoft, - Item: osbuild.PamLimitsItemNproc, - Value: osbuild.PamLimitsValueUnlimited, - }, - }, - ), - }, - // RHBZ#1959962 - Sysctld: []*osbuild.SysctldStageOptions{ - osbuild.NewSysctldStageOptions("sap.conf", - []osbuild.SysctldConfigLine{ - { - Key: "kernel.pid_max", - Value: "4194304", - }, - { - Key: "vm.max_map_count", - Value: "2147483647", - }, - }, - ), - }, - // E4S/EUS - DNFConfig: []*osbuild.DNFConfigStageOptions{ - osbuild.NewDNFConfigStageOptions( - []osbuild.DNFVariable{ - { - Name: "releasever", - Value: rd.osVersion, - }, - }, - nil, - ), - }, - } - defaultEc2SapImageConfigX86_64 = defaultEc2SapImageConfigX86_64.InheritFrom(defaultEc2ImageConfigX86_64) + defaultEc2SapImageConfigX86_64 := SapImageConfig(rd).InheritFrom(defaultEc2ImageConfigX86_64) ec2SapImgTypeX86_64 := imageType{ name: "ec2-sap", diff --git a/internal/distro/rhel8/sap.go b/internal/distro/rhel8/sap.go new file mode 100644 index 000000000..f4194798f --- /dev/null +++ b/internal/distro/rhel8/sap.go @@ -0,0 +1,118 @@ +package rhel8 + +import ( + "github.com/osbuild/osbuild-composer/internal/distro" + "github.com/osbuild/osbuild-composer/internal/osbuild" +) + +// SapImageConfig returns the SAP specific ImageConfig data +func SapImageConfig(rd distribution) *distro.ImageConfig { + return &distro.ImageConfig{ + SELinuxConfig: &osbuild.SELinuxConfigStageOptions{ + State: osbuild.SELinuxStatePermissive, + }, + // RHBZ#1960617 + Tuned: osbuild.NewTunedStageOptions("sap-hana"), + // RHBZ#1959979 + Tmpfilesd: []*osbuild.TmpfilesdStageOptions{ + osbuild.NewTmpfilesdStageOptions("sap.conf", + []osbuild.TmpfilesdConfigLine{ + { + Type: "x", + Path: "/tmp/.sap*", + }, + { + Type: "x", + Path: "/tmp/.hdb*lock", + }, + { + Type: "x", + Path: "/tmp/.trex*lock", + }, + }, + ), + }, + // RHBZ#1959963 + PamLimitsConf: []*osbuild.PamLimitsConfStageOptions{ + osbuild.NewPamLimitsConfStageOptions("99-sap.conf", + []osbuild.PamLimitsConfigLine{ + { + Domain: "@sapsys", + Type: osbuild.PamLimitsTypeHard, + Item: osbuild.PamLimitsItemNofile, + Value: osbuild.PamLimitsValueInt(1048576), + }, + { + Domain: "@sapsys", + Type: osbuild.PamLimitsTypeSoft, + Item: osbuild.PamLimitsItemNofile, + Value: osbuild.PamLimitsValueInt(1048576), + }, + { + Domain: "@dba", + Type: osbuild.PamLimitsTypeHard, + Item: osbuild.PamLimitsItemNofile, + Value: osbuild.PamLimitsValueInt(1048576), + }, + { + Domain: "@dba", + Type: osbuild.PamLimitsTypeSoft, + Item: osbuild.PamLimitsItemNofile, + Value: osbuild.PamLimitsValueInt(1048576), + }, + { + Domain: "@sapsys", + Type: osbuild.PamLimitsTypeHard, + Item: osbuild.PamLimitsItemNproc, + Value: osbuild.PamLimitsValueUnlimited, + }, + { + Domain: "@sapsys", + Type: osbuild.PamLimitsTypeSoft, + Item: osbuild.PamLimitsItemNproc, + Value: osbuild.PamLimitsValueUnlimited, + }, + { + Domain: "@dba", + Type: osbuild.PamLimitsTypeHard, + Item: osbuild.PamLimitsItemNproc, + Value: osbuild.PamLimitsValueUnlimited, + }, + { + Domain: "@dba", + Type: osbuild.PamLimitsTypeSoft, + Item: osbuild.PamLimitsItemNproc, + Value: osbuild.PamLimitsValueUnlimited, + }, + }, + ), + }, + // RHBZ#1959962 + Sysctld: []*osbuild.SysctldStageOptions{ + osbuild.NewSysctldStageOptions("sap.conf", + []osbuild.SysctldConfigLine{ + { + Key: "kernel.pid_max", + Value: "4194304", + }, + { + Key: "vm.max_map_count", + Value: "2147483647", + }, + }, + ), + }, + // E4S/EUS + DNFConfig: []*osbuild.DNFConfigStageOptions{ + osbuild.NewDNFConfigStageOptions( + []osbuild.DNFVariable{ + { + Name: "releasever", + Value: rd.osVersion, + }, + }, + nil, + ), + }, + } +}