{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/37183","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/37183/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/37183/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/37183/events","html_url":"https://github.com/ansible/ansible/issues/37183","id":303475270,"node_id":"MDU6SXNzdWUzMDM0NzUyNzA=","number":37183,"title":"uri: Unexpected return code","user":{"login":"pkaramol","id":2778429,"node_id":"MDQ6VXNlcjI3Nzg0Mjk=","avatar_url":"https://avatars2.githubusercontent.com/u/2778429?v=4","gravatar_id":"","url":"https://api.github.com/users/pkaramol","html_url":"https://github.com/pkaramol","followers_url":"https://api.github.com/users/pkaramol/followers","following_url":"https://api.github.com/users/pkaramol/following{/other_user}","gists_url":"https://api.github.com/users/pkaramol/gists{/gist_id}","starred_url":"https://api.github.com/users/pkaramol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pkaramol/subscriptions","organizations_url":"https://api.github.com/users/pkaramol/orgs","repos_url":"https://api.github.com/users/pkaramol/repos","events_url":"https://api.github.com/users/pkaramol/events{/privacy}","received_events_url":"https://api.github.com/users/pkaramol/received_events","type":"User","site_admin":false},"labels":[{"id":562292166,"node_id":"MDU6TGFiZWw1NjIyOTIxNjY=","url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.4","name":"affects_2.4","color":"ededed","default":false},{"id":785271699,"node_id":"MDU6TGFiZWw3ODUyNzE2OTk=","url":"https://api.github.com/repos/ansible/ansible/labels/bug","name":"bug","color":"fbca04","default":true},{"id":496359346,"node_id":"MDU6TGFiZWw0OTYzNTkzNDY=","url":"https://api.github.com/repos/ansible/ansible/labels/module","name":"module","color":"1d76db","default":false},{"id":593252542,"node_id":"MDU6TGFiZWw1OTMyNTI1NDI=","url":"https://api.github.com/repos/ansible/ansible/labels/net_tools","name":"net_tools","color":"fbca04","default":false},{"id":636352796,"node_id":"MDU6TGFiZWw2MzYzNTI3OTY=","url":"https://api.github.com/repos/ansible/ansible/labels/support:core","name":"support:core","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-03-08T13:15:03Z","updated_at":"2018-07-12T06:51:06Z","closed_at":null,"author_association":"NONE","body":"##### ISSUE TYPE\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\n<!---\r\nName of the module, plugin, task or feature\r\nDo not include extra details here, e.g. \"vyos_command\" not \"the network module vyos_command\" or the full path\r\n-->\r\nuri\r\n\r\n##### ANSIBLE VERSION\r\n<!--- Paste verbatim output from \"ansible --version\" between quotes below -->\r\n```\r\nansible 2.4.3.0\r\n  config file = /home/pkara/Workspace/pkara-namespace/pkara-ansible-rancher/terraform/ansible/ansible.cfg\r\n  configured module search path = [u'/home/pkara/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /usr/lib/python2.7/dist-packages/ansible\r\n  executable location = /usr/bin/ansible\r\n  python version = 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 20160609]\r\n\r\n```\r\n\r\nHowever for remote machine, since it is an `ubuntu xenial`:\r\n\r\n```\r\nansible_python_interpreter=/usr/bin/python3\r\n```\r\n \r\n\r\n\r\n##### CONFIGURATION\r\n<!---\r\nIf using Ansible 2.4 or above, paste the results of \"ansible-config dump --only-changed\"\r\nOtherwise, mention any settings you have changed/added/removed in ansible.cfg\r\n(or using the ANSIBLE_* environment variables).\r\n-->\r\n\r\n```\r\n(master)*$ ansible-config dump --only-changed\r\nANSIBLE_NOCOWS(/home/pkara/Workspace/pkara-namespace/pkara-ansible-rancher/terraform/ansible/ansible.cfg) = True\r\nDEFAULT_FORKS(/home/pkara/Workspace/pkara-namespace/pkara-ansible-rancher/terraform/ansible/ansible.cfg) = 50\r\nDEFAULT_GATHERING(/home/pkara/Workspace/pkara-namespace/pkara-ansible-rancher/terraform/ansible/ansible.cfg) = explicit\r\nDEFAULT_ROLES_PATH(/home/pkara/Workspace/pkara-namespace/pkara-ansible-rancher/terraform/ansible/ansible.cfg) = [u'/home/pkara/Workspace/pkara-namespace/pkara-ansible-rancher/terraform/ansible/roles']\r\nDEFAULT_VAULT_PASSWORD_FILE(/home/pkara/Workspace/pkara-namespace/pkara-ansible-rancher/terraform/ansible/ansible.cfg) = /home/pkara/Workspace/pkara-namespace/pkara-ansible-rancher/terraform/ansible/.vault\r\nHOST_KEY_CHECKING(/home/pkara/Workspace/pkara-namespace/pkara-ansible-rancher/terraform/ansible/ansible.cfg) = False\r\nRETRY_FILES_ENABLED(/home/pkara/Workspace/pkara-namespace/pkara-ansible-rancher/terraform/ansible/ansible.cfg) = False\r\n```\r\n\r\n##### OS / ENVIRONMENT\r\n\r\n```\r\n$ lsb_release -a\r\nNo LSB modules are available.\r\nDistributor ID:\tUbuntu\r\nDescription:\tUbuntu 16.04.4 LTS\r\nRelease:\t16.04\r\nCodename:\txenial\r\n```\r\n\r\n```\r\n$ uname -a\r\nLinux pkara-pc01 4.13.0-36-generic #40~16.04.1-Ubuntu SMP Fri Feb 16 23:25:58 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux\r\n```\r\n\r\n##### SUMMARY\r\nThe `uri` module returns unexpected value. (not informing me that the target is actually redirecting me)\r\n\r\n##### STEPS TO REPRODUCE\r\n<!---\r\nFor bugs, show exactly how to reproduce the problem, using a minimal test-case.\r\nFor new features, show how the feature would be used.\r\n-->\r\n\r\n<!--- Paste example playbooks or commands between quotes below -->\r\n```yaml\r\n\r\n- name:  Get server status code\r\n    uri:\r\n      url: \"http://{{ my_server_fqdn }}\"\r\n      validate_certs: no\r\n    register: rv_server_response\r\n    failed_when: false\r\n```\r\n\r\n<!--- You can also paste gist.github.com links for larger files -->\r\n\r\n##### EXPECTED RESULTS\r\n`curl` (**and** the browser) report redirect, however the information from the `uri` module is kind of misleading:\r\n\r\n```\r\n$ curl http://<my_server_fqdn>\r\n<html>\r\n<head><title>301 Moved Permanently</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>301 Moved Permanently</h1></center>\r\n<hr><center>nginx/1.10.3 (Ubuntu)</center>\r\n</body>\r\n</html>\r\n```\r\n\r\n\r\n##### ACTUAL RESULTS\r\nDespite the fact that the modules have been installed, the task **always** comes back as changed.\r\n\r\ndebug output:\r\n\r\n```\r\nok: [server] => {\r\n    \"msg\": {\r\n        \"changed\": false, \r\n        \"content\": \"\", \r\n        \"failed\": false, \r\n        \"failed_when_result\": false, \r\n        \"msg\": \"Status code was not [200]: Request failed: <urlopen error EOF occurred in violation of protocol (_ssl.c:645)>\", \r\n        \"redirected\": false, \r\n        \"status\": -1, \r\n        \"url\": \"http://<my_server_fqdn>\"\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/404408253","html_url":"https://github.com/ansible/ansible/issues/37183#issuecomment-404408253","issue_url":"https://api.github.com/repos/ansible/ansible/issues/37183","id":404408253,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNDQwODI1Mw==","user":{"login":"RogierSchuring","id":21055883,"node_id":"MDQ6VXNlcjIxMDU1ODgz","avatar_url":"https://avatars2.githubusercontent.com/u/21055883?v=4","gravatar_id":"","url":"https://api.github.com/users/RogierSchuring","html_url":"https://github.com/RogierSchuring","followers_url":"https://api.github.com/users/RogierSchuring/followers","following_url":"https://api.github.com/users/RogierSchuring/following{/other_user}","gists_url":"https://api.github.com/users/RogierSchuring/gists{/gist_id}","starred_url":"https://api.github.com/users/RogierSchuring/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RogierSchuring/subscriptions","organizations_url":"https://api.github.com/users/RogierSchuring/orgs","repos_url":"https://api.github.com/users/RogierSchuring/repos","events_url":"https://api.github.com/users/RogierSchuring/events{/privacy}","received_events_url":"https://api.github.com/users/RogierSchuring/received_events","type":"User","site_admin":false},"created_at":"2018-07-12T06:51:06Z","updated_at":"2018-07-12T06:51:06Z","author_association":"NONE","body":"This is STILL an issue in Ansible 2.5.1. Any idea when this will be fixed?\r\n\r\n```\r\nFAILED - RETRYING: Wait for API to become available. (99 retries left).Result was: {\r\n    \"attempts\": 2,\r\n    \"changed\": false,\r\n    \"content\": \"\",\r\n    \"invocation\": {\r\n        \"module_args\": {\r\n            \"attributes\": null,\r\n            \"backup\": null,\r\n            \"body\": null,\r\n            \"body_format\": \"raw\",\r\n            \"client_cert\": null,\r\n            \"client_key\": null,\r\n            \"content\": null,\r\n            \"creates\": null,\r\n            \"delimiter\": null,\r\n            \"dest\": null,\r\n            \"directory_mode\": null,\r\n            \"follow\": false,\r\n            \"follow_redirects\": \"safe\",\r\n            \"force\": false,\r\n            \"force_basic_auth\": false,\r\n            \"group\": null,\r\n            \"headers\": {},\r\n            \"http_agent\": \"ansible-httpget\",\r\n            \"method\": \"GET\",\r\n            \"mode\": null,\r\n            \"owner\": null,\r\n            \"regexp\": null,\r\n            \"remote_src\": null,\r\n            \"removes\": null,\r\n            \"return_content\": true,\r\n            \"selevel\": null,\r\n            \"serole\": null,\r\n            \"setype\": null,\r\n            \"seuser\": null,\r\n            \"src\": null,\r\n            \"status_code\": [\r\n                \"401\"\r\n            ],\r\n            \"timeout\": 30,\r\n            \"unsafe_writes\": null,\r\n            \"url\": \"https://localhost:9200/\",\r\n            \"url_password\": null,\r\n            \"url_username\": null,\r\n            \"use_proxy\": true,\r\n            \"validate_certs\": false\r\n        }\r\n    },\r\n    \"msg\": \"Status code was -1 and not [401]: Request failed: <urlopen error [Errno 111] Connection refused>\",\r\n    \"redirected\": false,\r\n    \"retries\": 101,\r\n    \"status\": -1,\r\n    \"url\": \"https://localhost:9200/\"\r\n}\r\n```\r\n\r\n"}}
{"actor":{"display_login":"RogierSchuring"}}