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

clouds.yaml is searched on remote host, not on the machine where ansible is running #40056

Closed
mircea-vutcovici opened this issue May 13, 2018 · 6 comments
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. cloud inventory Inventory category module This issue/PR relates to a module. openstack support:community This issue/PR relates to code supported by the Ansible community. traceback This issue/PR includes a traceback.

Comments

@mircea-vutcovici
Copy link

mircea-vutcovici commented May 13, 2018

ISSUE TYPE
  • Bug Report
COMPONENT NAME

os_client_config

ANSIBLE VERSION
ansible 2.5.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/mvutcovi/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.15 (default, May  2 2018, 14:12:52) [GCC 8.0.1 20180324 (Red Hat 8.0.1-0.20)]
CONFIGURATION

$ ansible-config dump --only-changed
$

OS / ENVIRONMENT

Fedora 28, kernel 4.16.7-300.fc28.x86_64

SUMMARY

Thew clouds.yaml on the remote host and it will not be searched in the current folder of the ansible playbook, but remotely, on the host where the module is running. This is not explicitly documented and it might not be the desired behavior. I think the same issue is affecting #37784
This is affecting all Openstack modules, not only os_client_config.
As a workaround, you can copy the clouds.yaml file into one of the following folders on the host where the module is running: ~/, ~/.config/openstack, /etc/openstack

Bellow is an excerpt of the output of sudo strace -f -e file -p $(pgrep sshd) 2>&1 | less which shows that the clouds.yaml is searched on the remote host.

[pid  2063] stat("/home/mvutcovi/clouds.yaml", 0x7ffdd5c3a550) = -1 ENOENT (No such file or directory)
[...]
[pid  2063] stat("/home/mvutcovi/clouds.yml", 0x7ffdd5c3a550) = -1 ENOENT (No such file or directory)
[pid  2063] stat("/home/mvutcovi/clouds.json", 0x7ffdd5c3a550) = -1 ENOENT (No such file or directory)
[pid  2063] stat("/home/mvutcovi/.config/openstack/clouds.yaml", 0x7ffdd5c3a550) = -1 ENOENT (No such file or directory)
[pid  2063] stat("/home/mvutcovi/.config/openstack/clouds.yml", 0x7ffdd5c3a550) = -1 ENOENT (No such file or directory)
[pid  2063] stat("/home/mvutcovi/.config/openstack/clouds.json", 0x7ffdd5c3a550) = -1 ENOENT (No such file or directory)
[pid  2063] stat("/home/mvutcovi/.config/openstack/clouds.yaml", 0x7ffdd5c3a550) = -1 ENOENT (No such file or directory)
[pid  2063] stat("/home/mvutcovi/.config/openstack/clouds.yml", 0x7ffdd5c3a550) = -1 ENOENT (No such file or directory)
[pid  2063] stat("/home/mvutcovi/.config/openstack/clouds.json", 0x7ffdd5c3a550) = -1 ENOENT (No such file or directory)
[pid  2063] stat("/etc/xdg/openstack/clouds.yaml", 0x7ffdd5c3a550) = -1 ENOENT (No such file or directory)
[pid  2063] stat("/etc/xdg/openstack/clouds.yml", 0x7ffdd5c3a550) = -1 ENOENT (No such file or directory)
[pid  2063] stat("/etc/xdg/openstack/clouds.json", 0x7ffdd5c3a550) = -1 ENOENT (No such file or directory)
[pid  2063] stat("/etc/openstack/clouds.yaml", 0x7ffdd5c3a550) = -1 ENOENT (No such file or directory)
[pid  2063] stat("/etc/openstack/clouds.yml", 0x7ffdd5c3a550) = -1 ENOENT (No such file or directory)
[pid  2063] stat("/etc/openstack/clouds.json", 0x7ffdd5c3a550) = -1 ENOENT (No such file or directory)
STEPS TO REPRODUCE
  1. Create the following files

test_os.yml

---
- hosts: localhost
  tasks:
    - name: Get list of clouds from OpenStack client config
      os_client_config:
        clouds: mircea_stack
    - debug: var=openstack.clouds

clouds.yaml

---
clouds:
  mircea_stack:
    auth:
      auth_url: http://10.0.0.107:5000/v2.0
      project_name: mirceaproject
      username: admin
      password: XXXXXXXXXX
    region_name: ""
  1. run: ansible-playbook test_os.yml -i ,localhost
EXPECTED RESULTS

When I copy clouds.yaml on remote host:

[mvutcovi@mvutcovi-lap ansible-playbooks]$ ansible-playbook test_os.yml -i ,localhost 

PLAY [localhost] **************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************************************************
ok: [localhost]

TASK [Get list of clouds from OpenStack client config] ************************************************************************************************************************************************************
ok: [localhost]

TASK [debug] ******************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "openstack.clouds": [
        {
            "api_timeout": null, 
            "application_catalog_api_version": "1", 
            "auth": {
                "auth_url": "http://10.0.0.107:5000/v2.0", 
                "password": "XXXXXXXX", 
                "project_name": "mirceaproject", 
                "username": "admin"
            }, 
            "auth_type": "password", 
            "baremetal_api_version": "1", 
            "cacert": null, 
            "cert": null, 
            "compute_api_version": "2", 
            "container_api_version": "1", 
            "container_infra_api_version": "1", 
            "database_api_version": "1.0", 
            "disable_vendor_agent": {}, 
            "dns_api_version": "2", 
            "floating_ip_source": "neutron", 
            "identity_api_version": "2.0", 
            "image_api_use_tasks": false, 
            "image_api_version": "2", 
            "image_format": "qcow2", 
            "interface": "public", 
            "key": null, 
            "key_manager_api_version": "v1", 
            "message": "", 
            "metering_api_version": "2", 
            "name": "mircea_stack", 
            "network_api_version": "2", 
            "networks": [], 
            "object_store_api_version": "1", 
            "orchestration_api_version": "1", 
            "region_name": "", 
            "secgroup_source": "neutron", 
            "status": "active", 
            "verify": true, 
            "volume_api_version": "2", 
            "workflow_api_version": "2"
        }
    ]
}

PLAY RECAP ********************************************************************************************************************************************************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0   

[mvutcovi@mvutcovi-lap ansible-playbooks]$ 

I expected one of the following:

  • the clouds.yaml file to be searched in the playbook folder
  • or to have a message stating that clouds.yaml was not found on remote machine and the list of search folders: ~/, ~/.config/openstack, /etc/openstack
ACTUAL RESULTS

The error message is very confusing as it is not mentioning that clouds.yaml is not found.

[mvutcovi@mvutcovi-lap ansible-playbooks]$ ansible-playbook test_os.yml -i ,localhost 

PLAY [localhost] **************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************************************************
ok: [localhost]

TASK [Get list of clouds from OpenStack client config] ************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Shared connection to localhost closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_5zz1pI/ansible_module_os_client_config.py\", line 82, in <module>\r\n    main()\r\n  File \"/tmp/ansible_5zz1pI/ansible_module_os_client_config.py\", line 72, in main\r\n    for cloud in config.get_all_clouds():\r\n  File \"/usr/lib/python2.7/site-packages/os_client_config/config.py\", line 801, in get_all_clouds\r\n    cloud, region_name=region['name']))\r\n  File \"/usr/lib/python2.7/site-packages/os_client_config/config.py\", line 1074, in get_one_cloud\r\n    auth_plugin = loader.load_from_options(**config['auth'])\r\n  File \"/usr/lib/python2.7/site-packages/keystoneauth1/loading/base.py\", line 162, in load_from_options\r\n    raise exceptions.MissingRequiredOptions(missing_required)\r\nkeystoneauth1.exceptions.auth_plugins.MissingRequiredOptions: Auth plugin requires parameters which were not given: auth_url\r\n", "msg": "MODULE FAILURE", "rc": 1}
	to retry, use: --limit @/home/mvutcovi/openstack-notes/ansible-playbooks/test_os.retry

PLAY RECAP ********************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1   

[mvutcovi@mvutcovi-lap ansible-playbooks]$ 
@ansibot
Copy link
Contributor

ansibot commented May 13, 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
Copy link
Contributor

ansibot commented May 13, 2018

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. cloud inventory Inventory category needs_triage Needs a first human triage before being processed. openstack support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels May 13, 2018
@ansibot
Copy link
Contributor

ansibot commented May 13, 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 module This issue/PR relates to a module. support:community This issue/PR relates to code supported by the Ansible community. and removed support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels May 13, 2018
@webknjaz
Copy link
Member

-label needs_triage

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label May 15, 2018
@ansibot ansibot added the traceback This issue/PR includes a traceback. label May 31, 2018
@gtema
Copy link
Contributor

gtema commented Jul 13, 2018

Well, this is the design of Ansible - module is executed on the target host. This is same for each and every module, unless you target localhost explicitly. So in order for you to proceed just change your target.

It is not a bug from my POV

@Shrews
Copy link
Contributor

Shrews commented Aug 8, 2018

This isn't a bug as it is, indeed, how ansible works. You'd have to explicitly copy the clouds.yaml file over to the target host if you intend to use it (alternatively, specify the auth params in the playbook manually). I agree that the error message is not intuitive.

notabug

@ansibot ansibot closed this as completed Aug 8, 2018
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. cloud inventory Inventory category module This issue/PR relates to a module. openstack support:community This issue/PR relates to code supported by the Ansible community. traceback This issue/PR includes a traceback.
Projects
None yet
Development

No branches or pull requests

5 participants