Search code examples
ansibleansible-awx

Host not found error while executing copy module


Ansible version :1.9.4, 1.9.3, 1.9.1,

Using ec2, so specifying pem key in ansible.cfg

I have used Ansible for while, but this error is strange.

Copy module works fine when executing in ad-hoc like the snippet below. The below line is just an example.

Ansible instance123 -m copy - a "src= dest= mode =" 

But gives "host not found" while executing the same module in playbook.

The playbook:

  ---
 - hosts: all
   sudo: yes
   tasks:
    - name: copy
      copy: src=./ansible.cfg dest=/home/ubuntu/ mode=0644

I checked command module both in playbooks and trying it in ad-hoc also. That works fine. I found that version 1.8.2 had this error, and I tried all state versions of 1.9.


Solution

  • The culprit was a var named inventory_hostname. So this was the var that was conflicting.