我试图通过Ansible在EC2实例上安装Apache。我的剧本是这样的:通过Ansible安装Apache
# Configure and deploy Apache
- hosts: localhost
connection: local
remote_user: ec2-user
gather_facts: false
roles:
- ec2_apache
- apache
的“ec2_apache的角色规定的EC2实例和Apache中的第一个任务/ main.yml看起来是这样的:
- name: confirm using the latest Apache server
become: yes
become_method: sudo
yum:
name: httpd
state: latest
不过,我得到以下错误:
"module_stderr": "sudo: a password is required\n"
我也看看:How to switch a user per task or set of tasks?但它似乎并没有解决我的问题。
因为Ec2实例的配置在一个角色中,并且Apache的安装位于另一个角色中,我是否以某种方式提高了安全性?
当您在实例中使用'sudo'作为'ec2-user'时,您是否需要密码? – ydaetskcoR
不,如果我进入新创建的实例,我可以做一个基本的'sudo ls/etc'这就是我难倒了。我通过在线和通过StackOverflow找到的所有示例都没有涉及创建EC2,然后安装某个软件或至少安装在不同的角色中。 –