Playbook not running

Hi All,

Getting this error when attempting to run a playbook :

ERROR! couldn’t resolve module/action ‘lineinefile’. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in ‘/root/ansible-aws-playbooks/nonprod_inventory-playbook.yml’: line 20, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: Create inventory file for nonprod group
  ^ here

Playbook section with error :

- name: Create inventory file for nonprod group
  lineinefile:
    path: ./inventory.ini
    create: yes
    line: "{{ instance.public_dns_name }} ansible_host={{ instance.public_ip_address }}"
  loop: "{{ec2_info.instances }}"
  when: ec2_info.instance | length > 0

This is using the AWS modules & Ansible community.

Syntax checker suggests the YAML format is correct.

Any ideas?

Have you tried the full qualified module name? ansible.builtin.lineinfile:.

Furthermore, before start managing a static inventory based on created EC2 instances, have you tried the EC2 dynamic inventory?

https://docs.ansible.com/ansible/latest/collections/amazon/aws/docsite/aws_ec2_guide.html

Hi Markus,

I’ve tried the FQMN, should have put that in the post.

I’ve not tried Ec2 dynamic inventory but this does seem like it would be a better idea.

I’ll take a look at that.

In the meantime any other ideas?

Hello @Jake.Cuz

Did you change the DEFAULT_MODULE_PATH setting?

Could you show us ansible-config dump --only-changed result?

Hi Akira,

CONFIG_FILE() = /root/ansible-aws-playbooks/ansible.cfg
DEFAULT_HOST_LIST(/root/ansible-aws-playbooks/ansible.cfg) = [‘/root/ansible-aws-playbooks/inventory’]
HOST_KEY_CHECKING(/root/ansible-aws-playbooks/ansible.cfg) = False

I’ve not changed the default_module_path setting.

This however has highlighted I need to move that file as I’ve left it in the wrong place.

Is common practice to put it in /etc/ansible ?

Thank you for the information.

If DEFAULT_MODULE_PATH is still the default, I don’t know what the cause is…

I usually put ansible.cfg on project top.

lineinefile
lineinfile

If no one else has mentioned it. It’s a typo.

5 Likes

This was obviously it :rofl:

2 Likes

I have to hand it to you though, that is probably one of the toughest to spot, psychologically, that I’ve seen.

Your head thinks it’s fine because of the “ine” in line, or at least mine does.

lineinfile can you check the spelling

1 Like