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?
markuman
(Markus)
August 28, 2024, 11:12am
2
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?
akira6592
(Akira Yokochi)
August 28, 2024, 12:41pm
4
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 ?
akira6592
(Akira Yokochi)
August 28, 2024, 1:09pm
6
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
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.
techiechap
(Ashish Ashish)
August 28, 2024, 3:41pm
10
lineinfile can you check the spelling
1 Like
system
(system)
Closed
September 27, 2024, 3:42pm
11
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.