问题类型:
Bug Report
Ansible版本:
ansible 2.0.0 (devel 2963bba901) last updated 2015/10/14 15:07:35 (GMT +300)
lib/ansible/modules/core: (devel 95b10c9fdd) last updated 2015/10/14 10:52:54 (GMT +300)
lib/ansible/modules/extras: (devel 15480e3d04) last updated 2015/10/14 10:52:56 (GMT +300)
config file = /etc/ansible/ansible.cfg
configured module search path = None
Ansible配置:
即使使用ansible.cfg的github版本也存在问题
环境:
MacOSX优胜美地10.10.5
概括:
在最近的开发中,ec2模块的用法已损坏。 甚至尝试使用ec2_module -page的基本示例都会产生消息:
fatal: [localhost]: FAILED! => {"failed": true, "msg": "ERROR! module is missing interpreter line"}
即使在解析模块选项之前,也会发生该错误。
自提交18e2ee16ef0895831ead312550eb5de44c99524c以来,该功能已被破坏。 我无法解释为什么该提交破坏了ec2模块。
重现步骤:
- hosts: localhost
tasks:
- ec2:
key_name: mykey
instance_type: t2.micro
image: ami-123456
wait: yes
group: webserver
count: 3
vpc_subnet_id: subnet-29e63245
assign_public_ip: yes
预期成绩:
ec2模块应像以前一样运行,并允许创建实例。
实际结果:
打印以下错误,并且剧本执行结束。
fatal: [localhost -> localhost]: FAILED! => {"failed": true, "msg": "ERROR! module is missing interpreter line"}
无法复制。 该错误表明该模块没有必需的路径,但实际上它具有: https :
可能是由于路径问题和/或设置问题。 其他模块会发生这种情况吗?
OSX:10.10.2
经过测试的HEAD:
PLAY ***************************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [ec2 aws_secret_key=***** count=1 aws_access_key=****** group=All key_name=***** region=us-west-1 vpc_subnet_id=subnet-64e9d522 instance_type=t2.micro assign_public_ip=True image=ami-df6a8b9b wait=True] ***
changed: [localhost] => {"changed": true, "instance_ids": ["i-249c1196"], "instances": [{"ami_launch_index": "0", "architecture": "x86_64", "block_device_mapping": {"/dev/sda1": {"delete_on_termination": true, "status": "attached", "volume_id": "vol-c611fe3e"}}, "dns_name": "ec2-54-193-42-241.us-west-1.compute.amazonaws.com", "ebs_optimized": false, "groups": {"sg-f2953597": "All"}, "hypervisor": "xen", "id": "i-249c1196", "image_id": "ami-df6a8b9b", "instance_type": "t2.micro", "kernel": null, "key_name": "*****", "launch_time": "2015-10-20T05:02:16.000Z", "placement": "us-west-1a", "private_dns_name": "ip-172-31-10-161.us-west-1.compute.internal", "private_ip": "172.31.10.161", "public_dns_name": "ec2-54-193-42-241.us-west-1.compute.amazonaws.com", "public_ip": "54.193.42.241", "ramdisk": null, "region": "us-west-1", "root_device_name": "/dev/sda1", "root_device_type": "ebs", "state": "running", "state_code": 16, "tags": {}, "tenancy": "default", "virtualization_type": "hvm"}], "tagged_instances": []}
PLAY RECAP *********************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0
经过测试的提交:18e2ee16ef0895831ead312550eb5de44c99524c
PLAY ***************************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [ec2 aws_secret_key=***** count=1 aws_access_key=*****group=All key_name=***** region=us-west-1 vpc_subnet_id=subnet-64e9d522 instance_type=t2.micro assign_public_ip=True image=ami-df6a8b9b wait=True] ***
changed: [localhost] => {"changed": true, "instance_ids": ["i-9d911c2f"], "instances": [{"ami_launch_index": "0", "architecture": "x86_64", "block_device_mapping": {"/dev/sda1": {"delete_on_termination": true, "status": "attached", "volume_id": "vol-7468878c"}}, "dns_name": "ec2-54-193-61-87.us-west-1.compute.amazonaws.com", "ebs_optimized": false, "groups": {"sg-f2953597": "All"}, "hypervisor": "xen", "id": "i-9d911c2f", "image_id": "ami-df6a8b9b", "instance_type": "t2.micro", "kernel": null, "key_name": "*****", "launch_time": "2015-10-20T05:21:45.000Z", "placement": "us-west-1a", "private_dns_name": "ip-172-31-5-245.us-west-1.compute.internal", "private_ip": "172.31.5.245", "public_dns_name": "ec2-54-193-61-87.us-west-1.compute.amazonaws.com", "public_ip": "54.193.61.87", "ramdisk": null, "region": "us-west-1", "root_device_name": "/dev/sda1", "root_device_type": "ebs", "state": "running", "state_code": 16, "tags": {}, "tenancy": "default", "virtualization_type": "hvm"}], "tagged_instances": []}
PLAY RECAP *********************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0
手册:
- hosts: localhost
connection: local
tasks:
- ec2:
aws_access_key: '*****'
aws_secret_key: '*****'
region: us-west-1
key_name: *****
instance_type: t2.micro
image: ami-df6a8b9b
wait: yes
group: All
count: 1
vpc_subnet_id: subnet-64e9d522
assign_public_ip: yes
我终于解决了这个错误。 我在“库”-目录中有ec2.ini,由于某种原因,ansible在寻找ec2-module时选择了它。 将ec2.ini重命名为ec2_dynamic_inventory.ini并执行“导出EC2_INI_PATH = library / ec2_dynamic_inventory.ini”解决了该问题。
请注意,如果缺少以下内容,则会出现此错误:
#!/usr/bin/python
在模块文件顶部的hashbang。 可能仅与正在开发自己的模块的人员相关。 但这让我绊倒了!
最有用的评论
请注意,如果缺少以下内容,则会出现此错误:
在模块文件顶部的hashbang。 可能仅与正在开发自己的模块的人员相关。 但这让我绊倒了!