Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

template module failes with "Failed to get information on remote file " #35274

Closed
rdxmb opened this issue Jan 24, 2018 · 12 comments
Closed

template module failes with "Failed to get information on remote file " #35274

rdxmb opened this issue Jan 24, 2018 · 12 comments
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@rdxmb
Copy link

rdxmb commented Jan 24, 2018

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Module: template

ANSIBLE VERSION
ansible 2.4.2.0
  config file = /home/marc/repos/docker-swarm/ansible.cfg
  configured module search path = [u'/usr/share/ansible']
  ansible python module location = /home/marc/.local/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]
CONFIGURATION ansible.cfg
~/repos/docker-swarm$[master !] grep -v '#' ansible.cfg 
[privilege_escalation]
become=True
become_method=sudo
become_user=root
become_ask_pass=False
[defaults]
library        = /usr/share/ansible
remote_tmp     = $HOME/.ansible/tmp
pattern        = *
forks          = 5
poll_interval  = 15
ask_pass      = False
transport      = smart
remote_port    = 22
module_lang    = C
gathering = smart 
roles_path = roles:/tmp/galaxy_roles
host_key_checking = False
timeout = 50 
action_plugins     = /usr/share/ansible_plugins/action_plugins
callback_plugins   = /usr/share/ansible_plugins/callback_plugins
connection_plugins = /usr/share/ansible_plugins/connection_plugins
lookup_plugins     = /usr/share/ansible_plugins/lookup_plugins
vars_plugins       = /usr/share/ansible_plugins/vars_plugins
filter_plugins     = /usr/share/ansible_plugins/filter_plugins
[ssh_connection]
ssh_args = -o ForwardAgent=yes
OS / ENVIRONMENT

local: Ubuntu 17.10 / Alpine 3.6 (problems exists with both environments)
remote: Ubuntu 16.04 TLS

SUMMARY

On one host the task with the template module fails with
"msg": "Failed to get information on remote file

STEPS TO REPRODUCE
# cat roles/etc_hosts/templates/mbr.intern.j2 
# {{ ansible_managed }}

127.0.0.1       localhost
127.0.1.1       {{ ansible_hostname }}.mbr.intern {{ ansible_hostname }}

192.168.253.101 docker1.mbr.intern docker1
192.168.253.102 docker2.mbr.intern docker2
192.168.253.110 docker3.mbr.intern docker3
192.168.253.100 nfs.mbr.intern nfs
192.168.253.99  vip.mbr.intern vip

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

# cat site.yml 
---
- name: prepare the remote-hosts for using ansible
  hosts: all
  gather_facts: no
  # do not gather_facts for python2 is probably not installed yet 
  pre_tasks:
    - name: install python2 via raw module
      raw: dpkg -s {{ item }} || apt-get install -y {{ item }}
      args:
        executable: /bin/bash
      with_items:
        - python2.7
        - python-simplejson
        - aptitude


- name: run
  hosts: all
  gather_facts: yes
  roles:      
      - etc_hosts  
           
# -----------------------------------------------------------------

# cat mbr/inventory 
[dc1]
docker1   ansible_ssh_host=192.168.253.101
docker2   ansible_ssh_host=192.168.253.102
docker3   ansible_ssh_host=192.168.253.110
nfs       ansible_ssh_host=192.168.253.100

# cat roles/etc_hosts/tasks/main.yml 
---
- name: generate /etc/hosts for this domain
  template:
    src: "mbr.intern.j2"
    dest: /etc/hosts

# cat roles/etc_hosts/templates/mbr.intern.j2 
# {{ ansible_managed }}

127.0.0.1       localhost
127.0.1.1       {{ ansible_hostname }}.mbr.intern {{ ansible_hostname }}

192.168.253.101 docker1.mbr.intern docker1
192.168.253.102 docker2.mbr.intern docker2
192.168.253.110 docker3.mbr.intern docker3
192.168.253.100 nfs.mbr.intern nfs
192.168.253.99  vip.mbr.intern vip

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

EXPECTED RESULTS
PLAY RECAP **********************************************************************************************************************************************************************************************************************************
docker1                    : ok=3    changed=1    unreachable=0    failed=0   
docker2                    : ok=3    changed=1    unreachable=0    failed=0   
docker3                    : ok=3    changed=1    unreachable=0    failed=0
nfs                        : ok=3    changed=1    unreachable=0    failed=0   
ACTUAL RESULTS
PLAY RECAP **********************************************************************************************************************************************************************************
docker1                    : ok=3    changed=1    unreachable=0    failed=0   
docker2                    : ok=3    changed=1    unreachable=0    failed=0   
docker3                    : ok=2    changed=1    unreachable=0    failed=1   
nfs                        : ok=3    changed=1    unreachable=0    failed=0   

The debug output can be found here:
https://raw.githubusercontent.com/rdxmb/ansible_debug/master/ansible.log

@ansibot
Copy link
Contributor

ansibot commented Jan 24, 2018

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bug_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Jan 24, 2018
@rdxmb
Copy link
Author

rdxmb commented Jan 24, 2018

if you need any further information, please let me know

@rdxmb
Copy link
Author

rdxmb commented Jan 24, 2018

ok, the real step to reproduce this is:

  • on your remote system, run
touch /usr/local/bin/file
chmod +x /usr/local/bin/file

run your ansible-playbook.

So the solution for that is (on your remote machine):
rm /usr/local/bin/file

Issue closed ...

@rdxmb rdxmb closed this as completed Jan 24, 2018
@mitpwd
Copy link

mitpwd commented Jan 25, 2018

Hi rdxmd,

You just commented how to reproduce the issue. What is the fix?

@rdxmb
Copy link
Author

rdxmb commented Jan 25, 2018

So the solution for that is (on your remote machine):
rm /usr/local/bin/file

:)

@mitpwd
Copy link

mitpwd commented Jan 25, 2018

It did not fix the issue with me.

We had an issue on a MacOS client, but not on CentOS 7.
Both used Python 2.7, one 2.7.10, one 2.7.5.

We can still reproduce the issue on the MacOS.

@mitpwd
Copy link

mitpwd commented Jan 25, 2018

Searching through the search engine, it appears the error (Failed to get information on remote file) message is too 'generic', it does not tell me in 'Linux' known errors what is not possible.

We walked through the playbook manually and all worked fine.

@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Jan 27, 2018
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@MBoretto
Copy link

MBoretto commented Apr 5, 2018

Any news concerning the fix?

@gaozhidf
Copy link

gaozhidf commented Apr 9, 2018

ansbile 2.5, server and client are Ubuntu 16.04

fixed problem when I install python2.7 on the client - Ubuntu

@gitqlt
Copy link

gitqlt commented Apr 18, 2018

ansible 2.5.0
server and client are: Ubuntu 16.04, Python2.7.12

Cannot create (or replace) file, when become to unprivileged user. It seems that allow_world_readable_tmpfiles = True is ineffective.
Even with pipelining = True, the same problem exists with a temporary file: the user cannot read/execute the temporary file

chmod u+x /root/.ansible/tmp/...
-rwx------ 1 root root 76768 Apr 19 00:57 /root/.ansible/tmp/...

comment better in #16052 (comment)

@Pax-nl
Copy link

Pax-nl commented May 31, 2018

Ran into the same issue today.

error: FAILED! => {"failed": true, "msg": "Failed to get information on remote file
ansible: 2.4.4.0
ubuntu: 17.10 server clean install only ssh-server.

The default python on this clean Ubuntu server install is python3 and there is no symlink configured for python without a version number.

$ python --version
The program 'python' can be found in the following packages:
 * python-minimal
 * python3
Try: sudo apt install <selected package>

so no python by default, tried this command to fix this:

$ sudo update-alternatives --config python
update-alternatives: error: no alternatives for python

still no default python, found fix for alternatives issue:

$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
update-alternatives: using /usr/bin/python3 to provide /usr/bin/python (python) in auto mode

which gave me:

$ python --version
Python 3.5.2

and now the playbook runs fine:

10.0.xx.xx                 : ok=5    changed=4    unreachable=0    failed=0

In retrospect I think I could have solved this also by adding this to my hosts file:

ansible_python_interpreter=/usr/bin/python3

@gitqlt
Copy link

gitqlt commented Jun 2, 2018

@paxpacis This issue is closed. I commented in
#16052 (comment)

@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests

8 participants