fix(rpm): Ensure telegraf is installed after useradd (#14654)

This commit is contained in:
Joshua Powers 2024-01-31 07:41:49 -07:00 committed by GitHub
parent ab8073f20b
commit ff8e28b5e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 6 deletions

View File

@ -368,10 +368,10 @@ $(include_packages):
--after-remove scripts/rpm/post-remove.sh \
--description "Plugin-driven server agent for reporting metrics into InfluxDB." \
--depends coreutils \
--depends shadow-utils \
--rpm-digest sha256 \
--rpm-posttrans scripts/rpm/post-install.sh \
--rpm-os ${GOOS} \
--rpm-tag "Requires(pre): /usr/sbin/useradd" \
--name telegraf \
--version $(version) \
--iteration $(rpm_iteration) \

View File

@ -82,7 +82,7 @@ func (c *Container) Install(packageName ...string) error {
case "dnf":
cmd = append([]string{"dnf", "install", "-y"}, packageName...)
case "zypper":
cmd = append([]string{"zypper", "install", "-y"}, packageName...)
cmd = append([]string{"zypper", "--gpg-auto-import-keys", "install", "-y"}, packageName...)
}
err := c.client.Exec(c.Name, cmd...)
@ -247,7 +247,8 @@ func (c *Container) configureDnf() error {
func (c *Container) configureZypper() error {
err := c.client.Exec(
c.Name,
"echo", fmt.Sprintf("%q", influxDataRPMRepo), ">", "/etc/zypp/repos.d/influxdata.repo",
"bash", "-c", "--",
fmt.Sprintf("echo -e %q > /etc/zypp/repos.d/influxdata.repo", influxDataRPMRepo),
)
if err != nil {
return err
@ -259,7 +260,7 @@ func (c *Container) configureZypper() error {
"cat /etc/zypp/repos.d/influxdata.repo",
)
return c.client.Exec(c.Name, "zypper", "refresh")
return c.client.Exec(c.Name, "zypper", "--no-gpg-checks", "refresh")
}
// Determine if the system uses yum or apt for software
@ -285,6 +286,12 @@ func (c *Container) detectPackageManager() error {
return nil
}
err = c.client.Exec(c.Name, "which", "zypper")
if err == nil {
c.packageManager = "zypper"
return nil
}
return fmt.Errorf("unable to determine package manager")
}

View File

@ -13,8 +13,7 @@ var imagesRPM = []string{
"fedora/39",
"fedora/38",
"centos/9-Stream",
//"opensuse/15.3", // shadow-utils dependency bug see #3833
//"opensuse/tumbleweed", // shadow-utils dependency bug see #3833
"opensuse/tumbleweed",
}
var imagesDEB = []string{