如何在 aws beanstalk 文件 install_packages.config 中为 yum install 指定一个 repo?

How do I specify a repo for yum install in aws beanstalk file install_packages.config?

部署时我需要在我的 AWS beanstalk 上安装 sshpass。

我创建了一个新的克隆来检查我是否可以从 ssh shell 命令行执行此操作,发现除非我指定 epel 存储库,否则它找不到包:

$ sudo yum -y install sshpass
Failed to set locale, defaulting to C
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main                                                                                                                                  | 2.1 kB  00:00:00
amzn-updates                                                                                                                               | 2.5 kB  00:00:00
No package sshpass available.
Error: Nothing to do

但这行得通:

$ sudo yum --enablerepo=epel -y install sshpass
Failed to set locale, defaulting to C
Loaded plugins: priorities, update-motd, upgrade-helper
1070 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package sshpass.x86_64 0:1.06-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================
 Package                                Arch                                  Version                                   Repository                           Size
==================================================================================================================================================================
Installing:
 sshpass                                x86_64                                1.06-1.el6                                epel                                 20 k

Transaction Summary
==================================================================================================================================================================
Install  1 Package

Total download size: 20 k
Installed size: 34 k
Downloading packages:
sshpass-1.06-1.el6.x86_64.rpm                                                                                                              |  20 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : sshpass-1.06-1.el6.x86_64                                                                                                                      1/1
  Verifying  : sshpass-1.06-1.el6.x86_64                                                                                                                      1/1

Installed:
  sshpass.x86_64 0:1.06-1.el6

Complete!

那么我该如何在 .ebextensions/-1-packages/install-packages.config 文件中执行此操作? 语法在 AWS 示例中定义如下:

packages: 
  yum:
    libmemcached: [] 
    ruby-devel: []
    gcc: []
  rpm:
    epel: http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
  rubygems: 
    chef: '0.10.2'

但我不确定如何在我只想告诉它使用 epel 存储库的情况下实现它

packages:
  yum:
    ...
    ...
    sshpass: []

我猜上面的内容不会自动导致它使用 epel 存储库?

可能有更好的方法,但这个方法有效:

commands:
  24-sshpass:
    command: "yum --enablerepo=epel -y install sshpass"