amazon-web-services - AWS Beanstalk - 无法使用配置文件运行命令

标签 amazon-web-services config amazon-elastic-beanstalk

我使用 beantalk 安装了 Tomcat 7。我试图通过将命令放在 .config(yaml) 文件中来在该环境中运行以下命令,如下所示:

iptables -I INPUT -p icmp --icmp-type echo-request -m recent --set
iptables -I INPUT -p icmp --icmp-type echo-request -m recent --update --seconds 20 --hitcount 5 -j DROP

配置文件 命令:

sudodisable:
command: echo Defaults:root \!requiretty
ipbasedthrotllingcommand1:
command: sudo iptables -I INPUT -p icmp --icmp-type echo-request -m recent --set
ipbasedthrotllingcommand2:
command: sudo iptables -I INPUT -p icmp --icmp-type echo-request -m recent --update --seconds 20 --hitcount 5 -j DROP

这是我的推论:

1) 我听从了这个帖子中的建议 --> https://forums.aws.amazon.com/message.jspa?messageID=395894并将上面显示的内容放入我的 .config 文件并上传我的 .war 只是为了得到以下错误

2013-03-03 20:52:39,165 DEBUG Not setting a reboot trigger as scheduling support is not available
2013-03-03 20:52:39,185 INFO Running configSets: deque()
2013-03-03 20:52:39,187 INFO Running configSet Infra-EmbeddedPreBuild
2013-03-03 20:52:39,187 INFO Running config prebuild_0_My_First_Elastic_Beanstalk_Application_sudofix__ebextensions_testit_config
2013-03-03 20:52:39,187 DEBUG No packages specified
2013-03-03 20:52:39,188 DEBUG No groups specified
2013-03-03 20:52:39,188 DEBUG No users specified
2013-03-03 20:52:39,188 DEBUG No sources specified
2013-03-03 20:52:39,188 DEBUG No files specified
2013-03-03 20:52:39,188 DEBUG Running command ipbasedthrotllingcommand1
2013-03-03 20:52:39,188 DEBUG No test for command ipbasedthrotllingcommand1
2013-03-03 20:52:39,204 ERROR Command ipbasedthrotllingcommand1 (sudo iptables -I INPUT -p icmp --icmp-type echo-request -m recent --set) failed
2013-03-03 20:52:39,205 DEBUG Command ipbasedthrotllingcommand1 output: sudo: sorry, you must have a tty to run sudo
2013-03-03 20:52:39,205 ERROR Error encountered during build of prebuild_0_My_First_Elastic_Beanstalk_Application_sudofix__ebextensions_testit_config: Command ipbasedthrotllingcommand1 failed
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/cfnbootstrap/construction.py", line 505, in run_config
CloudFormationCarpenter(config, self._auth_config).build(worklog)
File "/usr/lib/python2.6/site-packages/cfnbootstrap/construction.py", line 241, in build
changes = CommandTool().apply(self._config.commands)
File "/usr/lib/python2.6/site-packages/cfnbootstrap/command_tool.py", line 103, in apply
raise ToolError("Command %s failed" % name)
ToolError: Command ipbasedthrotllingcommand1 failed
2013-03-03 20:52:39,206 ERROR Unhandled exception during build: Command ipbasedthrotllingcommand1 failed
Traceback (most recent call last):
File "/opt/aws/bin/cfn-init", line 135, in <module>
worklog.build(detail.metadata, configSets)
File "/usr/lib/python2.6/site-packages/cfnbootstrap/construction.py", line 117, in build
Contractor(metadata).build(configSets, self)
File "/usr/lib/python2.6/site-packages/cfnbootstrap/construction.py", line 496, in build
self.run_config(config, worklog)
File "/usr/lib/python2.6/site-packages/cfnbootstrap/construction.py", line 505, in run_config
CloudFormationCarpenter(config, self._auth_config).build(worklog)
File "/usr/lib/python2.6/site-packages/cfnbootstrap/construction.py", line 241, in build
changes = CommandTool().apply(self._config.commands)
File "/usr/lib/python2.6/site-packages/cfnbootstrap/command_tool.py", line 103, in apply
raise ToolError("Command %s failed" % name)
ToolError: Command ipbasedthrotllingcommand1 failed
2013-03-03 20:53:26,362 DEBUG CloudFormation client initialized with endpoint https://cloudformation.us-west-1.amazonaws.com
2013-03-03 20:53:26,362 DEBUG Describing resource AWSEBAutoScalingGroup in stack arn:aws:cloudformation:us-west-1:726941363581:stack/awseb-e-jiipcgeknm-stack/3bb8eac0-842f-11e2-b50d-50690881bc86
2013-03-03 20:53:26,577 DEBUG Not setting a reboot trigger as scheduling support is not available
2013-03-03 20:53:26,593 INFO Running configSets: deque()
2013-03-03 20:53:26,595 INFO Running configSet InfoTask-TailLogs
2013-03-03 20:53:26,596 INFO Running config InfoTask-TailLogs
2013-03-03 20:53:26,596 DEBUG No packages specified
2013-03-03 20:53:26,596 DEBUG No groups specified
2013-03-03 20:53:26,596 DEBUG No users specified
2013-03-03 20:53:26,596 DEBUG No sources specified
2013-03-03 20:53:26,596 DEBUG No files specified
2013-03-03 20:53:26,597 DEBUG Running command taillogs
2013-03-03 20:53:26,597 DEBUG No test for command taillogs

2) 如果我在没有 sudo 的情况下运行 iptables 命令,我根本看不到它们被执行。基本上,我什至没有在我的日志文件中看到对 .config 文件的引用,这让我怀疑配置文件是否被提取。

如果能帮我解决这个问题,我将不胜感激。

最佳答案

command: echo Defaults:root \!requiretty

错了。根据您链接到的文档,它应该是:

echo Defaults:root \!requiretty >> /etc/sudoers 

关于amazon-web-services - AWS Beanstalk - 无法使用配置文件运行命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15195279/

相关文章:

linux - 相当于 Amazon S3 存储桶上的 "du"命令

javascript - 为 AWS LEX 编写条件 AWS Lambda 函数

scala - 类型安全配置 : Load additional config from path external to packaged scala application

c# - asp.net razor 新项目无法与 mysql 建立成员关系

amazon-web-services - 如何检查 AWS Batch 作业的内存和 CPU 使用率

python - Djangocollectstatic 无法在 S3 的生产环境中工作,但相同的设置在本地工作

python - 在python中解析icinga conf文件

asp.net - 额外的文件夹附加到我在 AWS 上的 Web 根目录

configuration - 将环境属性与弹性 beantalk 配置文件中的文件一起使用

node.js - EB CLI 初始化问题...无效凭证错误 : Credential must have exactly 5 slash-delimited elements