ansible / ansible

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com.
https://www.ansible.com/
GNU General Public License v3.0
62.69k stars 23.87k forks source link

Fact caching fails for hosts that contain / character with file based cache plugins #41413

Open ryanpetrello opened 6 years ago

ryanpetrello commented 6 years ago
SUMMARY

Hosts that contain the / character in their name will cause fact gathering to fail when using file-based plugins, such as jsonfile.

ISSUE TYPE
COMPONENT NAME

gather_facts

ANSIBLE VERSION
ansible 2.5.4
  config file = None
  configured module search path = [u'/home/ryanpetrello/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ryanpetrello/venvs/tmp-f30da7ecd0904ce6/lib/python2.7/site-packages/ansible
  executable location = /home/ryanpetrello/venvs/tmp-f30da7ecd0904ce6/bin/ansible
  python version = 2.7.14 (default, Mar 14 2018, 16:45:33) [GCC 8.0.1 20180222 (Red Hat 8.0.1-0.16)]
CONFIGURATION
$ ansible-config dump --only-changed
(empty)
OS / ENVIRONMENT

Fedora 28

STEPS TO REPRODUCE
$ cat gather.yml
- hosts: all
  gather_facts: true
$ cat inv
[all]
foo/bar ansible_ssh_host=localhost ansible_connection=local
EXPECTED RESULTS

Facts for the foo/bar host to be cached on the local file system.

ACTUAL RESULTS
$ mkdir `pwd`/facts
$ ANSIBLE_CACHE_PLUGIN=jsonfile ANSIBLE_CACHE_PLUGIN_CONNECTION=`pwd`/facts ansible-playbook -i inv gather.yml

PLAY [all] ******************************************************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************************************
 [WARNING]: error in 'jsonfile' cache plugin while trying to write to /home/ryanpetrello/venvs/tmp-f30da7ecd0904ce6/facts/foo/bar : [Errno 2] No such file or
directory: u'/home/ryanpetrello/venvs/tmp-f30da7ecd0904ce6/facts/foo/bar'

ok: [foo/bar]

PLAY RECAP ******************************************************************************************************************************************************
foo/bar                    : ok=1    changed=0    unreachable=0    failed=0
ansibot commented 6 years ago

Files identified in the description: None

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 commented 5 years ago

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 commented 4 years ago

Files identified in the description:

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

click here for bot help