{"action":"opened","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/19568","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/19568/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/19568/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/19568/events","html_url":"https://github.com/ansible/ansible/issues/19568","id":196720439,"number":19568,"title":"Ansible 2.2 - gc_storage module errors on new file to bucket","user":{"login":"CoryPulm","id":9952124,"avatar_url":"https://avatars.githubusercontent.com/u/9952124?v=3","gravatar_id":"","url":"https://api.github.com/users/CoryPulm","html_url":"https://github.com/CoryPulm","followers_url":"https://api.github.com/users/CoryPulm/followers","following_url":"https://api.github.com/users/CoryPulm/following{/other_user}","gists_url":"https://api.github.com/users/CoryPulm/gists{/gist_id}","starred_url":"https://api.github.com/users/CoryPulm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CoryPulm/subscriptions","organizations_url":"https://api.github.com/users/CoryPulm/orgs","repos_url":"https://api.github.com/users/CoryPulm/repos","events_url":"https://api.github.com/users/CoryPulm/events{/privacy}","received_events_url":"https://api.github.com/users/CoryPulm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-20T16:40:38Z","updated_at":"2016-12-20T16:40:38Z","closed_at":null,"body":"<!---\r\nVerify first that your issue/request is not already reported on GitHub.\r\nAlso test if the latest release, and master branch are affected too.\r\n-->\r\n\r\n##### ISSUE TYPE\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\n- gc_storage\r\n\r\n##### ANSIBLE VERSION\r\n```\r\n$ ansible --version\r\nansible 2.2.0.0\r\n  config file = /home/cory/panopta/infrastructure/src/ansible/ansible.cfg\r\n  configured module search path = Default w/o overrides\r\n```\r\n\r\n##### CONFIGURATION\r\nConfig file changes:\r\n```\r\n[defaults]\r\njinja2_extensions = jinja2.ext.do,jinja2.ext.i18n\r\nhost_key_checking = False\r\n```\r\n\r\n##### OS / ENVIRONMENT\r\nAnsible Host: Ubuntu 16.04.1 LTS\r\nAnsible Target: localhost but reaching to GC Storage API\r\n\r\n##### SUMMARY\r\nIt looks like the gc_storage module is somehow throwing an error on the first upload of a new file to GC Storage buckets. It throws an error but it _does_ upload the file anyway. Subsequent runs to upload the file once it exists in the bucket function as expected.\r\n\r\n##### STEPS TO REPRODUCE\r\nRun this, removed my info and replaced with variables. Normally this would be filled in\r\n```\r\nansible-playbook -i localhost gcp_config.yml -e \"gcp_config_bucket_name=$BUCKET project_id=$PROJECT envname=$ENVIRONMENT gs_access_key=$GS_KEY gs_secret_key=$GS_SECRET\" -vvvv\r\n```\r\n```yaml\r\n- name: upload template to GC Storage\r\n  gc_storage: bucket=\"{{gcp_config_bucket_name}}\" object=controlpanel.cfg src=/tmp/controlpanel.cfg mode=put force=yes gs_access_key=\"{{gs_access_key}}\" gs_secret_key=\"{{gs_secret_key}}\"\r\n```\r\n\r\n##### EXPECTED RESULTS\r\nUpload a file to GC Storage without error every time\r\n\r\n##### ACTUAL RESULTS\r\nThe file is uploaded properly every time, the first time however throws an error below. On subsequent runs, it seems to run fine.\r\n\r\n```\r\n(junkenv)cory@cory-ThinkPad-X1-Carbon-2nd:~/panopta/infrastructure/src/ansible$ ansible-playbook -i localhost gcp_config.yml -e \"project_id=$PROJECT envname=$ENVIRONMENT gs_access_key=$GS_KEY gs_secret_key=$GS_SECRET\" -vvvv\r\nUsing /home/cory/panopta/infrastructure/src/ansible/ansible.cfg as config file\r\n [WARNING]: Host file not found: localhost\r\n\r\n [WARNING]: provided hosts list is empty, only localhost is available\r\n\r\nLoading callback plugin default of type stdout, v2.0 from /home/cory/junkenv/local/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc\r\n\r\nPLAYBOOK: gcp_config.yml *******************************************************\r\n1 plays in gcp_config.yml\r\n\r\nPLAY [localhost] ***************************************************************\r\n\r\nTASK [upload template to GC Storage] *******************************************\r\ntask path: /home/cory/panopta/infrastructure/src/ansible/roles/controlpanel-lb/tasks/gcp.yml:6\r\nUsing module file /home/cory/junkenv/local/lib/python2.7/site-packages/ansible/modules/core/cloud/google/gc_storage.py\r\n<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: cory\r\n<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p \"` echo $HOME/.ansible/tmp/ansible-tmp-1482251197.78-85869852942481 `\" && echo ansible-tmp-1482251197.78-85869852942481=\"` echo $HOME/.ansible/tmp/ansible-tmp-1482251197.78-85869852942481 `\" ) && sleep 0'\r\n<127.0.0.1> PUT /tmp/tmpA3n_Ws TO /home/cory/.ansible/tmp/ansible-tmp-1482251197.78-85869852942481/gc_storage.py\r\n<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/cory/.ansible/tmp/ansible-tmp-1482251197.78-85869852942481/ /home/cory/.ansible/tmp/ansible-tmp-1482251197.78-85869852942481/gc_storage.py && sleep 0'\r\n<127.0.0.1> EXEC /bin/sh -c 'python /home/cory/.ansible/tmp/ansible-tmp-1482251197.78-85869852942481/gc_storage.py; rm -rf \"/home/cory/.ansible/tmp/ansible-tmp-1482251197.78-85869852942481/\" > /dev/null 2>&1 && sleep 0'\r\nAn exception occurred during task execution. The full traceback is:\r\nTraceback (most recent call last):\r\n  File \"/tmp/ansible_wbzVcO/ansible_module_gc_storage.py\", line 437, in <module>\r\n    main()\r\n  File \"/tmp/ansible_wbzVcO/ansible_module_gc_storage.py\", line 405, in main\r\n    handle_put(module, gs, bucket, obj, overwrite, src, expiry)\r\n  File \"/tmp/ansible_wbzVcO/ansible_module_gc_storage.py\", line 308, in handle_put\r\n    upload_gsfile(module, gs, bucket, obj, src, expiration)\r\n  File \"/tmp/ansible_wbzVcO/ansible_module_gc_storage.py\", line 244, in upload_gsfile\r\n    url = key.generate_url(expiry)\r\n  File \"/home/cory/junkenv/local/lib/python2.7/site-packages/boto/s3/key.py\", line 707, in generate_url\r\n    version_id)\r\n  File \"/home/cory/junkenv/local/lib/python2.7/site-packages/boto/s3/connection.py\", line 393, in generate_url\r\n    expires = int(time.time() + expires_in)\r\nTypeError: unsupported operand type(s) for +: 'float' and 'str'\r\n\r\nfatal: [localhost]: FAILED! => {\r\n    \"changed\": false, \r\n    \"failed\": true, \r\n    \"invocation\": {\r\n        \"module_name\": \"gc_storage\"\r\n    }, \r\n    \"module_stderr\": \"Traceback (most recent call last):\\n  File \\\"/tmp/ansible_wbzVcO/ansible_module_gc_storage.py\\\", line 437, in <module>\\n    main()\\n  File \\\"/tmp/ansible_wbzVcO/ansible_module_gc_storage.py\\\", line 405, in main\\n    handle_put(module, gs, bucket, obj, overwrite, src, expiry)\\n  File \\\"/tmp/ansible_wbzVcO/ansible_module_gc_storage.py\\\", line 308, in handle_put\\n    upload_gsfile(module, gs, bucket, obj, src, expiration)\\n  File \\\"/tmp/ansible_wbzVcO/ansible_module_gc_storage.py\\\", line 244, in upload_gsfile\\n    url = key.generate_url(expiry)\\n  File \\\"/home/cory/junkenv/local/lib/python2.7/site-packages/boto/s3/key.py\\\", line 707, in generate_url\\n    version_id)\\n  File \\\"/home/cory/junkenv/local/lib/python2.7/site-packages/boto/s3/connection.py\\\", line 393, in generate_url\\n    expires = int(time.time() + expires_in)\\nTypeError: unsupported operand type(s) for +: 'float' and 'str'\\n\", \r\n    \"module_stdout\": \"\", \r\n    \"msg\": \"MODULE FAILURE\"\r\n}\r\n\tto retry, use: --limit @/home/cory/panopta/infrastructure/src/ansible/gcp_config.retry\r\n\r\nPLAY RECAP *********************************************************************\r\nlocalhost                  : ok=0    changed=0    unreachable=0    failed=1   \r\n\r\n(junkenv)cory@cory-ThinkPad-X1-Carbon-2nd:~/panopta/infrastructure/src/ansible$ \r\n```\r\n"}}
{"actor":{"display_login":"CoryPulm"}}