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

877 views
Skip to first unread message

Barry Kaplan

unread,
Jun 17, 2016, 8:40:31 PM6/17/16
to Ansible Project
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": ""}



Barry Kaplan

unread,
Jun 17, 2016, 8:43:48 PM6/17/16
to Ansible Project
Same error with v2.1.1.0-0.1.rc1

Barry Kaplan

unread,
Jun 17, 2016, 9:05:12 PM6/17/16
to Ansible Project
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

Barry Kaplan

unread,
Jun 17, 2016, 9:37:50 PM6/17/16
to Ansible Project
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

Barry Kaplan

unread,
Jun 17, 2016, 9:43:36 PM6/17/16
to Ansible Project
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 waiting for it be merged into 1.9. But I forgot to delete after. Now with_sequence works with 2.1.x for me.
Reply all
Reply to author
Forward
0 new messages