Ansible: Bug report: ec2 module is broken with "ERROR! module is missing interpreter line"

Created on 14 Oct 2015  ·  3Comments  ·  Source: ansible/ansible

Issue Type:

Bug Report

Ansible Version:

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 Configuration:

Issue exists even with the github version of ansible.cfg

Environment:

MacOSX Yosemite 10.10.5

Summary:

In most recent devel usage of ec2 module is broken. Trying to use even the basic examples from the ec2_module -page produces message:

 fatal: [localhost]: FAILED! => {"failed": true, "msg": "ERROR! module is missing interpreter line"}

The error happens even before the module options are parsed.

The functionality has been broken since commit 18e2ee16ef0895831ead312550eb5de44c99524c . I couldn't decipher why that commit broke the ec2 module.

Steps To Reproduce:

- 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

Expected Results:

ec2 modules should function as before and allow creation of instances.
Actual Results:

Following error is printed and playbook execution ends.

fatal: [localhost -> localhost]: FAILED! => {"failed": true, "msg": "ERROR! module is missing interpreter line"}
bug

Most helpful comment

Just a note, you can get this error if you're missing the:

#!/usr/bin/python

hashbang at the top of your module file. Probably only relevant for people who are developing their own modules. But it tripped me up!

All 3 comments

Unable to replicate. This error is indicating the module does not have the required path, but it in fact does: https://github.com/ansible/ansible-modules-core/blob/devel/cloud/amazon/ec2.py#L1

Might be due to a path issue and/or setup issue. Does this happen with other modules?

OSX: 10.10.2

Tested 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

Tested Commit: 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

PLAYBOOK:

- 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

I finally solved the bug. I had ec2.ini in 'library' -directory and for some reason ansible was picking it when it looked for ec2 -module. Renaming the ec2.ini to ec2_dynamic_inventory.ini and executing 'export EC2_INI_PATH=library/ec2_dynamic_inventory.ini' fixed the problem.

Just a note, you can get this error if you're missing the:

#!/usr/bin/python

hashbang at the top of your module file. Probably only relevant for people who are developing their own modules. But it tripped me up!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bcoca picture bcoca  ·  90Comments

benapetr picture benapetr  ·  95Comments

jmnavarrol picture jmnavarrol  ·  54Comments

guenhter picture guenhter  ·  64Comments

gvenka008c picture gvenka008c  ·  58Comments