vagrant/plugins/provisioners/cfengine/cap/redhat/cfengine_install.rb
oss-core-libraries-dashboard[bot] ea57f40b89
Some checks failed
/ sync-acceptance (push) Has been cancelled
Vagrant Ruby Tests / Vagrant unit tests on Ruby 3.1 (push) Has been cancelled
Vagrant Ruby Tests / Vagrant unit tests on Ruby 3.2 (push) Has been cancelled
Vagrant Ruby Tests / Vagrant unit tests on Ruby 3.3 (push) Has been cancelled
Vagrant Ruby Tests / Vagrant unit tests on Ruby 3.4 (push) Has been cancelled
[COMPLIANCE] Update Copyright and License Headers (#13752)
Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2025-12-04 17:07:40 +05:30

37 lines
1.4 KiB
Ruby

# Copyright IBM Corp. 2010, 2025
# SPDX-License-Identifier: BUSL-1.1
require "log4r"
module VagrantPlugins
module CFEngine
module Cap
module RedHat
module CFEngineInstall
def self.cfengine_install(machine, config)
logger = Log4r::Logger.new("vagrant::plugins::cfengine::cap_redhat_cfengine_install")
machine.communicate.tap do |comm|
logger.info("Adding the CFEngine repository to #{config.yum_repo_file}")
comm.sudo("mkdir -p #{File.dirname(config.yum_repo_file)} && (echo '[cfengine-repository]'; echo 'name=CFEngine Community Yum Repository'; echo 'baseurl=#{config.yum_repo_url}'; echo 'enabled=1'; echo 'gpgcheck=1') > #{config.yum_repo_file}")
logger.info("Installing CFEngine Community Yum Repository GPG KEY from #{config.repo_gpg_key_url}")
comm.sudo("GPGFILE=$(mktemp) && wget -O $GPGFILE #{config.repo_gpg_key_url} && rpm --import $GPGFILE; rm -f $GPGFILE")
if dnf?(machine)
comm.sudo("dnf -y install #{config.package_name}")
else
comm.sudo("yum -y install #{config.package_name}")
end
end
end
protected
def self.dnf?(machine)
machine.communicate.test("/usr/bin/which -s dnf")
end
end
end
end
end
end