amazon.aws
amazon.aws copied to clipboard
ec2 instance issue
SUMMARY
Module errors out
ISSUE TYPE
- Bug Report
COMPONENT NAME
ec2 instance
ANSIBLE VERSION
ansible 2.10.2
config file = /home/user/ansible-aws/ansible.cfg
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/yser/.local/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.6.8 (default, Aug 18 2020, 08:33:21) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
CONFIGURATION
ANSIBLE_SSH_ARGS(/home/user/ansible-aws/ansible.cfg) = -o ControlMaster=auto -o ControlPersist=180s -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
DEFAULT_BECOME(/home/user/ansible-aws/ansible.cfg) = True
DEFAULT_BECOME_ASK_PASS(/home/user/ansible-aws/ansible.cfg) = False
DEFAULT_BECOME_METHOD(/home/user/ansible-aws/ansible.cfg) = sudo
DEFAULT_BECOME_USER(/home/user/ansible-aws/ansible.cfg) = root
DEFAULT_FORKS(/home/user/ansible-aws/ansible.cfg) = 100
DEFAULT_INVENTORY_PLUGIN_PATH(/home/user/ansible-aws/ansible.cfg) = ['/home/user/ansible-aws/plugins/inventory,plugins']
DEFAULT_MANAGED_STR(/home/user/ansible-aws/ansible.cfg) = Ansible Managed Please Contact IT
DEFAULT_REMOTE_USER(/home/user/ansible-aws/ansible.cfg) = root
DEFAULT_ROLES_PATH(/home/user/ansible-aws/ansible.cfg) = ['/home/user/ansible-aws/roles']
DEFAULT_SCP_IF_SSH(/home/user/ansible-aws/ansible.cfg) = True
HOST_KEY_CHECKING(/home/user/ansible-aws/ansible.cfg) = False
INTERPRETER_PYTHON(/home/user/ansible-aws/ansible.cfg) = auto
RETRY_FILES_ENABLED(/home/user/ansible-aws/ansible.cfg) = False
RETRY_FILES_SAVE_PATH(/home/user/ansible-aws/ansible.cfg) = /tmp
OS / ENVIRONMENT
redhat
STEPS TO REPRODUCE
- name: Create EC2 Instance
community.aws.ec2_instance:
aws_access_key: "{{ systems_access_key }}"
aws_secret_key: "{{ systems_secret_key }}"
instance_type: "{{ instance_type }}"
image:
id: "{{ ami_id }}"
key_name: "{{ keypair }}"
security_group: "{{ security_group }}"
region: "{{ aws_region }}"
volumes:
- device_name: /dev/sda1
volume_type: gp2
volume_size: "{{ disk_size }}"
encrypted: true
delete_on_termination: true
name: "{{ item }}"
tags:
Name: "{{ item }}"
Project: "{{ instance_purpose }}"
wait:
wait_timeout: 720
become: false
register: instance_built
with_items:
- "{{ hostname_list }}"
EXPECTED RESULTS
module works
ACTUAL RESULTS
The full traceback is:
Traceback (most recent call last):
File "/home/feisa/.ansible/tmp/ansible-tmp-1605717970.8448534-1398807-231291796849703/AnsiballZ_ec2_instance.py", line 102, in <module>
_ansiballz_main()
File "/home/feisa/.ansible/tmp/ansible-tmp-1605717970.8448534-1398807-231291796849703/AnsiballZ_ec2_instance.py", line 94, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/home/feisa/.ansible/tmp/ansible-tmp-1605717970.8448534-1398807-231291796849703/AnsiballZ_ec2_instance.py", line 40, in invoke_module
runpy.run_module(mod_name='ansible_collections.community.aws.plugins.modules.ec2_instance', init_globals=None, run_name='__main__', alter_sys=True)
File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmp/ansible_community.aws.ec2_instance_payload_gr__bo3s/ansible_community.aws.ec2_instance_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_instance.py", line 1840, in <module>
File "/tmp/ansible_community.aws.ec2_instance_payload_gr__bo3s/ansible_community.aws.ec2_instance_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_instance.py", line 1793, in main
File "/tmp/ansible_community.aws.ec2_instance_payload_gr__bo3s/ansible_community.aws.ec2_instance_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/cloud.py", line 156, in retry_func
File "/tmp/ansible_community.aws.ec2_instance_payload_gr__bo3s/ansible_community.aws.ec2_instance_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/cloud.py", line 143, in retry_func
File "/tmp/ansible_community.aws.ec2_instance_payload_gr__bo3s/ansible_community.aws.ec2_instance_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_instance.py", line 1447, in get_default_subnet
TypeError: 'NoneType' object is not subscriptable
failed: [localhost] (item=aws-utilx001) => {
"ansible_loop_var": "item",
"changed": false,
"item": "aws-utilx001",
"module_stderr": "Traceback (most recent call last):\n File \"/home/feisa/.ansible/tmp/ansible-tmp-1605717970.8448534-1398807-231291796849703/AnsiballZ_ec2_instance.py\", line 102, in <module>\n _ansiballz_main()\n File \"/home/feisa/.ansible/tmp/ansible-tmp-1605717970.8448534-1398807-231291796849703/AnsiballZ_ec2_instance.py\", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/feisa/.ansible/tmp/ansible-tmp-1605717970.8448534-1398807-231291796849703/AnsiballZ_ec2_instance.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.community.aws.plugins.modules.ec2_instance', init_globals=None, run_name='__main__', alter_sys=True)\n File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\n mod_name, mod_spec, pkg_name, script_name)\n File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_community.aws.ec2_instance_payload_gr__bo3s/ansible_community.aws.ec2_instance_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_instance.py\", line 1840, in <module>\n File \"/tmp/ansible_community.aws.ec2_instance_payload_gr__bo3s/ansible_community.aws.ec2_instance_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_instance.py\", line 1793, in main\n File \"/tmp/ansible_community.aws.ec2_instance_payload_gr__bo3s/ansible_community.aws.ec2_instance_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/cloud.py\", line 156, in retry_func\n File \"/tmp/ansible_community.aws.ec2_instance_payload_gr__bo3s/ansible_community.aws.ec2_instance_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/cloud.py\", line 143, in retry_func\n File \"/tmp/ansible_community.aws.ec2_instance_payload_gr__bo3s/ansible_community.aws.ec2_instance_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_instance.py\", line 1447, in get_default_subnet\nTypeError: 'NoneType' object is not subscriptable\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
Files identified in the description:
If these files are inaccurate, please update the component name
section of the description or use the !component
bot command.
cc @Shaps @jillr @s-hertel @tremble @wimnat click here for bot help
@feisa kindly use amazon.aws.ec2 Module instead of ec_instance
Thank you for the bug report @feisa. It seems network configuration key is missing, however, the module should raise an exeption and handle it.
This issue must be move to amazon.aws since the ec2_instance
module is located there now.
cc @alinabuzachis @tremble
Files identified in the description: None
If these files are inaccurate, please update the component name
section of the description or use the !component
bot command.
Files identified in the description:
- [
plugins/modules/ec2_instance.py
](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/modules/ec2_instance.py)
If these files are inaccurate, please update the component name
section of the description or use the !component
bot command.
cc @ryansb click here for bot help
Please name your issue more specifically, that will help when people are searching to see if an issue has already been reported