{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/14578","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/14578/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/14578/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/14578/events","html_url":"https://github.com/ansible/ansible/issues/14578","id":134889489,"number":14578,"title":"Issues in template module","user":{"login":"ajaymahto","id":17176008,"avatar_url":"https://avatars.githubusercontent.com/u/17176008?v=3","gravatar_id":"","url":"https://api.github.com/users/ajaymahto","html_url":"https://github.com/ajaymahto","followers_url":"https://api.github.com/users/ajaymahto/followers","following_url":"https://api.github.com/users/ajaymahto/following{/other_user}","gists_url":"https://api.github.com/users/ajaymahto/gists{/gist_id}","starred_url":"https://api.github.com/users/ajaymahto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajaymahto/subscriptions","organizations_url":"https://api.github.com/users/ajaymahto/orgs","repos_url":"https://api.github.com/users/ajaymahto/repos","events_url":"https://api.github.com/users/ajaymahto/events{/privacy}","received_events_url":"https://api.github.com/users/ajaymahto/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.0","name":"affects_2.0","color":"5319e7"},{"url":"https://api.github.com/repos/ansible/ansible/labels/bug_report","name":"bug_report","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2016-02-19T15:16:10Z","updated_at":"2016-09-15T08:43:08Z","closed_at":null,"body":"#### Issue Type:\r\n\r\n - Bug Report\r\n\r\n#### Ansible Version:\r\n```\r\nansible 2.0.0.2\r\n  config file = /home/ubuntu/ansible-monlog/ansible.cfg\r\n  configured module search path = Default w/o overrides\r\n```\r\n#### Ansible Configuration:\r\n\r\nDefault\r\n\r\n#### Environment:\r\n\r\n- Ansible host : Ubuntu\r\n- Client : Centos\r\n\r\n#### Summary:\r\n\r\nSame task returns different errors, sometimes even when the file is transferred successfully.\r\n\r\n#### Steps To Reproduce:\r\n\r\n```\r\n- name: Send hostfile to icinga masters\r\n  template: src={{ PROJECT_ROOT }}/roles/icinga-client/templates/etc/icinga2/repository.d/hosts/remote_host.conf\r\n            dest=/etc/icinga2/repository.d/hosts/{{ ansible_fqdn }}.conf\r\n  delegate_to: \"{{ item }}\"\r\n  with_items: groups['icinga_master']\r\n```\r\n\r\n#### Expected Results:\r\n\r\nThe template should have been copied properly.\r\n\r\n```\r\nchanged: [10.41.3.201 -> 10.41.3.237] => (item=10.41.3.237) => {\"changed\": true, \"checksum\": \"28b5693f20272daad55d23fda71a86a172d2874c\", \"dest\": \"/etc/icinga2/repository.d/hosts/mysql-1-os-ggn1.conf\", \"gid\": 113, \"group\": \"nagios\", \"item\": \"10.41.3.237\", \"md5sum\": \"f5a973eae88012bd58fc3d3b2d749145\", \"mode\": \"0644\", \"owner\": \"nagios\", \"size\": 3453, \"src\": \"/home/ubuntu/.ansible/tmp/ansible-tmp-1455893288.76-105139992058230/source\", \"state\": \"file\", \"uid\": 106}\r\nchanged: [10.41.3.201 -> 10.41.3.238] => (item=10.41.3.238) => {\"changed\": true, \"checksum\": \"28b5693f20272daad55d23fda71a86a172d2874c\", \"dest\": \"/etc/icinga2/repository.d/hosts/mysql-1-os-ggn1.conf\", \"gid\": 0, \"group\": \"root\", \"item\": \"10.41.3.238\", \"md5sum\": \"f5a973eae88012bd58fc3d3b2d749145\", \"mode\": \"0755\", \"owner\": \"root\", \"size\": 3453, \"src\": \"/home/ubuntu/.ansible/tmp/ansible-tmp-1455893290.05-232604810544822/source\", \"state\": \"file\", \"uid\": 0\r\n```\r\n#### Actual Results:\r\n- Templates successfully copied to destination, but still get error messages. Doesn't happen always though.\r\n-  Fails for some hosts, while runs successfully for others.\r\n\r\n**Output:**\r\n```\r\n[WARNING]: Calculating checksum failed unusually, please report this to the list so it can be fixed command: rc=flag; [ -r /etc/icinga2/repository.d/hosts/mysql-2\r\n-icinga-ggn1.conf ] || rc=2; [ -f /etc/icinga2/repository.d/hosts/mysql-2-icinga-ggn1.conf ] || rc=1; [ -d /etc/icinga2/repository.d/hosts/mysql-2-icinga-ggn1.conf ] &&\r\nrc=3; python -V 2>/dev/null || rc=4; [ x\"$rc\" != \"xflag\" ] && echo \"${rc}  \"/etc/icinga2/repository.d/hosts/mysql-2-icinga-ggn1.conf && exit 0; (python -c 'import\r\nhashlib; BLOCKSIZE = 65536; hasher = hashlib.sha1(); afile = open(\"'/etc/icinga2/repository.d/hosts/mysql-2-icinga-ggn1.conf'\", \"rb\") buf = afile.read(BLOCKSIZE) while\r\nlen(buf) > 0:         hasher.update(buf)         buf = afile.read(BLOCKSIZE) afile.close() print(hasher.hexdigest())' 2>/dev/null) || (python -c 'import sha; BLOCKSIZE\r\n= 65536; hasher = sha.sha(); afile = open(\"'/etc/icinga2/repository.d/hosts/mysql-2-icinga-ggn1.conf'\", \"rb\") buf = afile.read(BLOCKSIZE) while len(buf) > 0:\r\nhasher.update(buf)         buf = afile.read(BLOCKSIZE) afile.close() print(hasher.hexdigest())' 2>/dev/null) || (echo '0  '/etc/icinga2/repository.d/hosts/mysql-2\r\n-icinga-ggn1.conf) ---- output: {'stdout_lines': [], 'stdout': u'', 'stderr': u'', 'rc': 255} ----\r\n\r\n [WARNING]: Calculating checksum failed unusually, please report this to the list so it can be fixed command: rc=flag; [ -r /etc/icinga2/repository.d/hosts/mysql-1\r\n-icinga-ggn1.conf ] || rc=2; [ -f /etc/icinga2/repository.d/hosts/mysql-1-icinga-ggn1.conf ] || rc=1; [ -d /etc/icinga2/repository.d/hosts/mysql-1-icinga-ggn1.conf ] &&\r\nrc=3; python -V 2>/dev/null || rc=4; [ x\"$rc\" != \"xflag\" ] && echo \"${rc}  \"/etc/icinga2/repository.d/hosts/mysql-1-icinga-ggn1.conf && exit 0; (python -c 'import\r\nhashlib; BLOCKSIZE = 65536; hasher = hashlib.sha1(); afile = open(\"'/etc/icinga2/repository.d/hosts/mysql-1-icinga-ggn1.conf'\", \"rb\") buf = afile.read(BLOCKSIZE) while\r\nlen(buf) > 0:         hasher.update(buf)         buf = afile.read(BLOCKSIZE) afile.close() print(hasher.hexdigest())' 2>/dev/null) || (python -c 'import sha; BLOCKSIZE\r\n= 65536; hasher = sha.sha(); afile = open(\"'/etc/icinga2/repository.d/hosts/mysql-1-icinga-ggn1.conf'\", \"rb\") buf = afile.read(BLOCKSIZE) while len(buf) > 0:\r\nhasher.update(buf)         buf = afile.read(BLOCKSIZE) afile.close() print(hasher.hexdigest())' 2>/dev/null) || (echo '0  '/etc/icinga2/repository.d/hosts/mysql-1\r\n-icinga-ggn1.conf) ---- output: {'stdout_lines': [], 'stdout': u'', 'stderr': u'', 'rc': 255} ----\r\n\r\n\r\nfatal: [10.41.3.228]: UNREACHABLE! => {\"changed\": true, \"msg\": \"All items completed\", \"results\": [{\"_ansible_delegated_vars\": {\"ansible_host\": \"10.41.3.237\"}, \"_ansible_no_log\": false, \"changed\": true, \"checksum\": \"1e9982073913e9353f7885cc6fade547a9f532a8\", \"dest\": \"/etc/icinga2/repository.d/hosts/mysql-2-icinga-ggn1.conf\", \"gid\": 0, \"group\": \"root\", \"invocation\": {\"module_args\": {\"backup\": false, \"content\": null, \"delimiter\": null, \"dest\": \"/etc/icinga2/repository.d/hosts/mysql-2-icinga-ggn1.conf\", \"directory_mode\": null, \"follow\": true, \"force\": true, \"group\": null, \"mode\": null, \"original_basename\": \"remote_host.conf\", \"owner\": null, \"regexp\": null, \"remote_src\": null, \"selevel\": null, \"serole\": null, \"setype\": null, \"seuser\": null, \"src\": \"/home/ubuntu/.ansible/tmp/ansible-tmp-1455894341.84-135673956691330/source\", \"validate\": null}}, \"item\": \"10.41.3.237\", \"md5sum\": \"8071f4c3e459f82ec63daa25f35a0609\", \"mode\": \"0644\", \"owner\": \"root\", \"size\": 1455, \"src\": \"/home/ubuntu/.ansible/tmp/ansible-tmp-1455894341.84-135673956691330/source\", \"state\": \"file\", \"uid\": 0}, {\"item\": \"10.41.3.238\", \"msg\": \"ERROR! SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue\", \"unreachable\": true}]}\r\nfatal: [10.41.3.201]: UNREACHABLE! => {\"changed\": true, \"msg\": \"All items completed\", \"results\": [{\"_ansible_delegated_vars\": {\"ansible_host\": \"10.41.3.237\"}, \"_ansible_no_log\": false, \"changed\": true, \"checksum\": \"28b5693f20272daad55d23fda71a86a172d2874c\", \"dest\": \"/etc/icinga2/repository.d/hosts/mysql-1-os-ggn1.conf\", \"gid\": 0, \"group\": \"root\", \"invocation\": {\"module_args\": {\"backup\": false, \"content\": null, \"delimiter\": null, \"dest\": \"/etc/icinga2/repository.d/hosts/mysql-1-os-ggn1.conf\", \"directory_mode\": null, \"follow\": true, \"force\": true, \"group\": null, \"mode\": null, \"original_basename\": \"remote_host.conf\", \"owner\": null, \"regexp\": null, \"remote_src\": null, \"selevel\": null, \"serole\": null, \"setype\": null, \"seuser\": null, \"src\": \"/home/ubuntu/.ansible/tmp/ansible-tmp-1455894341.86-135468164559285/source\", \"validate\": null}}, \"item\": \"10.41.3.237\", \"md5sum\": \"f5a973eae88012bd58fc3d3b2d749145\", \"mode\": \"0644\", \"owner\": \"root\", \"size\": 3453, \"src\": \"/home/ubuntu/.ansible/tmp/ansible-tmp-1455894341.86-135468164559285/source\", \"state\": \"file\", \"uid\": 0}, {\"item\": \"10.41.3.238\", \"msg\": \"ERROR! SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue\", \"unreachable\": true}]}\r\nfatal: [10.41.3.202]: UNREACHABLE! => {\"changed\": false, \"msg\": \"All items completed\", \"results\": [{\"item\": \"10.41.3.237\", \"msg\": \"ERROR! SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue\", \"unreachable\": true}, {\"item\": \"10.41.3.238\", \"msg\": \"ERROR! SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh\", \"unreachable\": true}]}\r\nfatal: [10.41.3.203]: UNREACHABLE! => {\"changed\": false, \"msg\": \"All items completed\", \"results\": [{\"item\": \"10.41.3.237\", \"msg\": \"ERROR! SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue\", \"unreachable\": true}, {\"item\": \"10.41.3.238\", \"msg\": \"ERROR! SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh\", \"unreachable\": true}]}\r\nfatal: [10.41.3.227]: UNREACHABLE! => {\"changed\": true, \"msg\": \"All items completed\", \"results\": [{\"_ansible_delegated_vars\": {\"ansible_host\": \"10.41.3.237\"}, \"_ansible_no_log\": false, \"changed\": true, \"checksum\": \"0f3216b4b5251562a94a7a400f8710dd002d93a1\", \"dest\": \"/etc/icinga2/repository.d/hosts/mysql-1-icinga-ggn1.conf\", \"gid\": 0, \"group\": \"root\", \"invocation\": {\"module_args\": {\"backup\": false, \"content\": null, \"delimiter\": null, \"dest\": \"/etc/icinga2/repository.d/hosts/mysql-1-icinga-ggn1.conf\", \"directory_mode\": null, \"follow\": true, \"force\": true, \"group\": null, \"mode\": null, \"original_basename\": \"remote_host.conf\", \"owner\": null, \"regexp\": null, \"remote_src\": null, \"selevel\": null, \"serole\": null, \"setype\": null, \"seuser\": null, \"src\": \"/home/ubuntu/.ansible/tmp/ansible-tmp-1455894341.82-185851853100711/source\", \"validate\": null}}, \"item\": \"10.41.3.237\", \"md5sum\": \"8f7c264118bc297187938cc27ca37df6\", \"mode\": \"0644\", \"owner\": \"root\", \"size\": 1455, \"src\": \"/home/ubuntu/.ansible/tmp/ansible-tmp-1455894341.82-185851853100711/source\", \"state\": \"file\", \"uid\": 0}, {\"item\": \"10.41.3.238\", \"msg\": \"ERROR! SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue\", \"unreachable\": true}]}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/247270958","html_url":"https://github.com/ansible/ansible/issues/14578#issuecomment-247270958","issue_url":"https://api.github.com/repos/ansible/ansible/issues/14578","id":247270958,"user":{"login":"ktrimu","id":22212904,"avatar_url":"https://avatars.githubusercontent.com/u/22212904?v=3","gravatar_id":"","url":"https://api.github.com/users/ktrimu","html_url":"https://github.com/ktrimu","followers_url":"https://api.github.com/users/ktrimu/followers","following_url":"https://api.github.com/users/ktrimu/following{/other_user}","gists_url":"https://api.github.com/users/ktrimu/gists{/gist_id}","starred_url":"https://api.github.com/users/ktrimu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktrimu/subscriptions","organizations_url":"https://api.github.com/users/ktrimu/orgs","repos_url":"https://api.github.com/users/ktrimu/repos","events_url":"https://api.github.com/users/ktrimu/events{/privacy}","received_events_url":"https://api.github.com/users/ktrimu/received_events","type":"User","site_admin":false},"created_at":"2016-09-15T08:43:08Z","updated_at":"2016-09-15T08:43:08Z","body":"Hello,\r\nI'm facing same issue with ansible 2.0.2.0, it's working perfectly without become:yes.\r\n\r\n[ansibleuser@litqa-rhel65-t001 tgo-automation]$ ansible -m template -u remoteuser -kK -a \"src=test123 dest=/tmp/\" testnode.internal.net\r\n/usr/lib64/python2.6/site-packages/cryptography/__init__.py:26: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of cryptography will drop support for Python 2.6\r\n  DeprecationWarning\r\nSSH password:\r\nSUDO password[defaults to SSH password]:\r\ntestnode.internal.net | FAILED! => {\r\n    \"changed\": false,\r\n    \"failed\": true,\r\n    \"msg\": \"SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh\"\r\n}\r\n[ansibleuser@litqa-rhel65-t001 automation]$\r\n\r\nAny help is much appreciated."}}
{"actor":{"display_login":"ktrimu"}}