This page describes configuring VMs to install RPM packages from
an Artifact Registry Yum repository. Artifact Registry Yum repositories support
yum and dnf clients.
Before you begin
If the target Yum repository does not exist, create a new repository. You can create a private repository or a public repository that does not require authentication.
Prepare a VM to access a Yum repository
To prepare a VM to access a Yum repository, use the yum or dnf client tool:
Private repository
Choose the service account you will use to grant access.
- For Compute Engine VMs, this might be the default service account. Artifact Registry automatically retrieves Compute Engine VM service account credentials for any VM using a service account.
- For other VMs, create or choose a service account to act on behalf of your VM. You will need the location of the service account key file to configure the VM. You can view and create keys for existing accounts on the Service Accounts page.
Grant repository access permissions to your service account.
Prepare the VM to access the repository.
Compute Engine VM
Assign
cloud-platformAPI access scopes to the VM. For information about setting access scopes, see Changing the service account and access scopes for an instance.Update the package cache using the following command:
sudo yum makecacheInstall the Artifact Registry plugin on the VM, using the following command:
sudo yum install FORMAT-plugin-artifact-registryReplace the following:
FORMATwith one of the following:yum, if your operating system is Enterprise Linux 7 or earlierdnf, if your operating system is Enterprise Linux 8 or later
Other VM
Install the RPM signing key using the following command:
sudo rpm --import https://packages.cloud.google.com/yum/doc/rpm-package-key.gpgCreate a file named
/etc/yum.repos.d/artifact-registry-plugin.repowith the following contents:[ar-plugin] name=Artifact Registry Plugin baseurl=https://packages.cloud.google.com/yum/repos/FORMAT-plugin-artifact-registry-DISTRO-stable enabled=1 gpgcheck=1
Replace the following:
FORMATwith one of the following:yum, if your operating system is Enterprise Linux 7 or earlierdnf, if your operating system is Enterprise Linux 8 or later
DISTROwith the Red Hat Enterprise Linux major release in the formatelXwhereXis the release version. Examples of validDISTROvalues areel7andel8.
Update Yum using the following command:
sudo yum makecacheInstall the Artifact Registry plugin on the VM, using the following command:
yum install FORMAT-plugin-artifact-registryReplace
FORMATwith one of the following:yum, if your operating system is Enterprise Linux 7 or earlierdnf, if your operating system is Enterprise Linux 8 or later
Find the
#service_account_json = "/path/to/creds.json"line in theartifact-registry.conffile, then uncomment the line and add the path of your service account key.- For Enterprise Linux 7 or earlier operating systems, the path
to the configuration file is
/etc/yum/pluginconf.d/artifact-registry.conf. - For Enterprise Linux 8 or later operating systems, the path to
the configuration file is
/etc/dnf/plugins/artifact-registry.conf.
Config file entry:
service_account_json = "PATH_TO_SERVICE_ACCOUNT_KEY"
Replace
PATH_TO_SERVICE_ACCOUNT_KEYwith the path to your service account key JSON file.- For Enterprise Linux 7 or earlier operating systems, the path
to the configuration file is
Public repository
Configure public access to the repository.
Configure a VM to access a standard Yum repository
To configure a VM to access a Yum repository, use the yum or dnf client tool:
Generate the VM configuration command by running the
gcloud beta artifacts print-settings yumcommand:gcloud beta artifacts print-settings yum \ --repository=REPOSITORY \ --location=LOCATIONReplace the following:
REPOSITORYis the name of the Artifact Registry repository.-
LOCATIONis the regional location of the repository.
The output is similar to the following:
# To configure your package manager with this repository: # Update Yum: sudo yum makecache # Install the Yum credential helper: sudo yum install yum-plugin-artifact-registry # Configure your VM to access Artifact Registry packages using the following # command: sudo tee -a /etc/yum.repos.d/artifact-registry.repo << EOL [REPOSITORY] name=REPOSITORY baseurl=https://LOCATION-yum.s3nsregistry.fr/projects/PROJECT/REPOSITORY enabled=1 repo_gpgcheck=0 gpgcheck=0 EOL # Update Yum: sudo yum makecache
Configure the
yumclient tool to fetch packages from your repository using theteecommand from the output of theprint-settingscommand.For example, to install packages from the public
my-repoin the projectmy-projectand in the locationu-france-east1, use the following command:sudo tee -a /etc/yum.repos.d/artifact-registry.repo << EOL [my-repo] name=My Repository baseurl=https://u-france-east1-yum.s3nsregistry.fr/projects/my-project/my-repo enabled=1 repo_gpgcheck=0 gpgcheck=0 EOL
Update your repository sources with the following command:
sudo yum makecache
Yum can now connect to the repository.
If you create additional Yum repositories, create a .repo file for each one
in /etc/yum.repos.d/. Rerun sudo yum update to update repository sources.