通过“用户数据”(Amazon Linux)通过cloud-init启用EPEL

问题描述 投票:0回答:3

我正在尝试通过“用户数据”功能(使用p7zip)在AWS中启动基于Amazon Linux的EC2实例后安装cloud-init软件包:

#cloud-config
repo_update: true
repo_upgrade: all

packages:
 - p7zip

但是,由于p7zip在正常的回购中不可用并且需要启用EPEL,因此它似乎没有正确地获取包。

我的问题是:使用cloud-init,如何在初始化EC2实例时获取包之前启用EPEL?

amazon-ec2 yum user-data cloud-init epel
3个回答
1
投票
#cloud-config
# vim: syntax=yaml
#
# Add yum repository configuration to the system
#
# The following example adds the file /etc/yum.repos.d/epel_testing.repo
# which can then subsequently be used by yum for later operations.
yum_repos:
    # The name of the repository
    epel-testing:
        # Any repository configuration options
        # See: man yum.conf
        #
        # This one is required!
        baseurl: http://download.fedoraproject.org/pub/epel/testing/5/$basearch
        enabled: false
        failovermethod: priority
        gpgcheck: true
        gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
        name: Extra Packages for Enterprise Linux 5 - Testing

1
投票

对于更新版本的Amazon Linux,您需要将以下内容添加到cloud-config文件中:

yum_repos:
    epel_custom:
        name: Extra Packages for Enterprise Linux 6 - $basearch
        baseurl: http://download.fedoraproject.org/pub/epel/6/$basearch
        mirrorlist: https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
        failovermethod: priority
        enabled: true
        gpgcheck: true
        gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 

Here是一个工作云配置文件的示例,可以在启动时用作userdata


0
投票

以下部分将启用EPEL与GPG。请注意,密钥是在初始引导时导入的。

#cloud-config
bootcmd:
  - [ cloud-init-per, once, gpg-key-epel, rpm, "--import", "https://archive.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7" ]
yum_repos:
  epel:
    name: EPEL
    mirrorlist: https://mirrors.fedoraproject.org/mirrorlist?repo=epel-7&arch=$basearch
    enabled: true
    gpgcheck: true
repo_update: true
repo_upgrade: all

来自https://github.com/trajano/terraform-docker-swarm-aws/blob/master/common.cloud-config

© www.soinside.com 2019 - 2024. All rights reserved.