0

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
Lakshman Diwaakar
  • 7,207
  • 6
  • 47
  • 81
  • Can you post the exact error you are getting and the part of the playbook/role that is giving the error? – ydaetskcoR Nov 10 '15 at 10:58
  • @ydaetskcoR I have uploaded a sample playbook. I tried the same playbook with many modules like service module for restarting the tomcat, where all work except copy module. The module works like a charm in ad-hoc but fails with a lame error "host not found". Other tasks in the play gets executed like "service, debug". Moreover, i cross checked copy.py in ansible, that doesn't contain any "module.failjson stating host not found". so quite confused. – Lakshman Diwaakar Nov 10 '15 at 11:16
  • I'm somewhat inclined to vote to close this question as "typo" - the answer given is undoubtedly the solution in this case, but it doesn't bear any connection to the question, and thus I am not sure how readers could learn from it for their own cases. – halfer Sep 24 '22 at 22:12

1 Answers1

0

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

halfer
  • 19,824
  • 17
  • 99
  • 186
Lakshman Diwaakar
  • 7,207
  • 6
  • 47
  • 81