# AttributeError: 'NoneType' object has no attribute 'run'

**URL:** <https://forum.ansible.com/t/attributeerror-nonetype-object-has-no-attribute-run/21805>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [June 18, 2016, 12:40am UTC](https://forum.ansible.com/t/attributeerror-nonetype-object-has-no-attribute-run/21805 "2016-06-18T00:40:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Barry\_Kaplan](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@Barry\_Kaplan](https://forum.ansible.com/u/Barry_Kaplan)\
**Post date:** [June 18, 2016, 12:40am UTC](https://forum.ansible.com/t/attributeerror-nonetype-object-has-no-attribute-run/21805/1 "2016-06-18T00:40:30Z")

</div>

ansible 2.1.0.0, python 2.7

I am getting this error when trying to create an ec2 instance. It does not matter if the instance already exists or not, so I assume its more of a parsing error. This task works correctly with 1.9. I don’t really see how to debug this. Any ideas?

This this task:

`

- name: Create ES instance  
tags: [instance]  
ec2:  
image: “{{ ubuntu\_image.results[0].ami\_id }}”  
region: “{{ec2\_region}}”  
vpc\_subnet\_id: “{{env\_subnet.private | select\_subnet\_id(es\_instance\_type, item)}}”  
instance\_type: “{{es\_instance\_type}}”  
instance\_profile\_name: “{{instance\_iam\_profile\_name}}”  
assign\_public\_ip: false  
group: “{{security\_groups}}”  
volumes:
- device\_name: /dev/sda1  
volume\_type: gp2  
volume\_size: 12  
delete\_on\_termination: true  
instance\_tags:  
Name: “{{env\_prefix}}es-{{item}}”  
es: “group”  
env: “{{env}}”  
managed\_by: ansible  
exact\_count: 1  
count\_tag:  
Name: “{{env\_prefix}}es-{{item}}”  
key\_name: “{{aws\_key\_name}}”  
wait: yes  
register: ec2\_es  
with\_sequence: start={{es\_instance\_start}} count={{es\_instance\_count}}

`

Yields this error:

`  
TASK [Create ES instance] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /Users/bkaplan/si/ops/ansible/playbooks/hosts/aws/es-cluster.yml:87  
An exception occurred during task execution. The full traceback is:  
Traceback (most recent call last):  
File “/Users/bkaplan/si/thirdparty/ansible/lib/ansible/executor/task\_executor.py”, line 93, in run  
items = self.\_get\_loop\_items()  
File “/Users/bkaplan/si/thirdparty/ansible/lib/ansible/executor/task\_executor.py”, line 195, in \_get\_loop\_items  
items = self.\_shared\_loader\_obj.lookup\_loader.get(self.\_task.loop, loader=self.\_loader, templar=templar).run(terms=loop\_terms, variables=self.\_job\_vars, wantlist=True)  
AttributeError: ‘NoneType’ object has no attribute 'run

fatal: [localhost]: FAILED! =\> {“failed”: true, “msg”: “Unexpected failure during module execution.”, “stdout”: “”}  
`

---

<div class="post-metadata">

**Author:** ![Barry\_Kaplan](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@Barry\_Kaplan](https://forum.ansible.com/u/Barry_Kaplan)\
**Post date:** [June 18, 2016, 12:43am UTC](https://forum.ansible.com/t/attributeerror-nonetype-object-has-no-attribute-run/21805/2 "2016-06-18T00:43:48Z")

</div>

Same error with v2.1.1.0-0.1.rc1

---

<div class="post-metadata">

**Author:** ![Barry\_Kaplan](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@Barry\_Kaplan](https://forum.ansible.com/u/Barry_Kaplan)\
**Post date:** [June 18, 2016, 1:05am UTC](https://forum.ansible.com/t/attributeerror-nonetype-object-has-no-attribute-run/21805/3 "2016-06-18T01:05:12Z")

</div>

This seems to be related to with\_sequence. But it’s hard to imagine something so basic not working.

`

- debug: var=item  
with\_sequence: start=1 end=2

`

Yields

`  
TASK [debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /Users/bkaplan/si/ops/ansible/playbooks/hosts/aws/es-cluster.yml:90  
An exception occurred during task execution. The full traceback is:  
Traceback (most recent call last):  
File “/Users/bkaplan/si/thirdparty/ansible/lib/ansible/executor/task\_executor.py”, line 93, in run  
items = self.\_get\_loop\_items()  
File “/Users/bkaplan/si/thirdparty/ansible/lib/ansible/executor/task\_executor.py”, line 195, in \_get\_loop\_items  
items = self.\_shared\_loader\_obj.lookup\_loader.get(self.\_task.loop, loader=self.\_loader, templar=templar).run(terms=loop\_terms, variables=self.\_job\_vars, wantlist=True)  
AttributeError: ‘NoneType’ object has no attribute ‘run’

fatal: [localhost]: FAILED! =\> {“failed”: true, “msg”: “Unexpected failure during module execution.”, “stdout”: “”}  
`

---

<div class="post-metadata">

**Author:** ![Barry\_Kaplan](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@Barry\_Kaplan](https://forum.ansible.com/u/Barry_Kaplan)\
**Post date:** [June 18, 2016, 1:37am UTC](https://forum.ansible.com/t/attributeerror-nonetype-object-has-no-attribute-run/21805/4 "2016-06-18T01:37:50Z")

</div>

The problem seems to be task\_executor.py#195 for this bit

`  
self.\_shared\_loader\_obj.lookup\_loader.get(self.\_task.loop, loader=self.\_loader, templar=templar)

`

The result of that expression is None

---

<div class="post-metadata">

**Author:** ![Barry\_Kaplan](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@Barry\_Kaplan](https://forum.ansible.com/u/Barry_Kaplan)\
**Post date:** [June 18, 2016, 1:43am UTC](https://forum.ansible.com/t/attributeerror-nonetype-object-has-no-attribute-run/21805/5 "2016-06-18T01:43:36Z")

</div>

Ok, user error (as I expected). I had copied in a version of sequence.py into my locals plugins/lookup\_plugins directory that fixed this bug [https://github.com/ansible/ansible/issues/11422](https://github.com/ansible/ansible/issues/11422) waiting for it be merged into 1.9. But I forgot to delete after. Now with\_sequence works with 2.1.x for me.
