3

我使用 beanstalk 设置了 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 文件的引用,这让我怀疑配置文件是否被拾取。

我真的很感激任何帮助来解决这个问题。

4

1 回答 1

1
command: echo Defaults:root \!requiretty

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

echo Defaults:root \!requiretty >> /etc/sudoers 
于 2015-04-20T18:01:53.313 回答