{"action":"created","comment":{"url":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/comments/72464041","id":72464041,"diff_hunk":"@@ -160,73 +158,58 @@ def _create_bucket(connection, module, location):\n             changed = True\n         except S3CreateError as e:\n             module.fail_json(msg=e.message)\n-    \n+\n     # Versioning\n     versioning_status = bucket.get_versioning_status()\n-    if not versioning_status and versioning:\n-        try:\n-            bucket.configure_versioning(versioning)\n-            changed = True\n-            versioning_status = bucket.get_versioning_status()\n-        except S3ResponseError as e:\n-            module.fail_json(msg=e.message)\n-    elif not versioning_status and not versioning:\n-        # do nothing\n-        pass\n-    else:\n-        if versioning_status['Versioning'] == \"Enabled\" and not versioning:\n-            bucket.configure_versioning(versioning)\n-            changed = True\n-            versioning_status = bucket.get_versioning_status()\n-        elif ( (versioning_status['Versioning'] == \"Disabled\" and versioning) or (versioning_status['Versioning'] == \"Suspended\" and versioning) ):\n-            bucket.configure_versioning(versioning)\n-            changed = True\n-            versioning_status = bucket.get_versioning_status()\n-    \n+    if not versioning_status:\n+        if versioning:\n+            try:\n+                bucket.configure_versioning(versioning)\n+                changed = True\n+                versioning_status = bucket.get_versioning_status()\n+            except S3ResponseError as e:\n+                module.fail_json(msg=e.message)\n+    elif versioning_status['Versioning'] == \"Enabled\" and not versioning:\n+        bucket.configure_versioning(versioning)\n+        changed = True\n+        versioning_status = bucket.get_versioning_status()\n+    elif ( (versioning_status['Versioning'] == \"Disabled\" and versioning) or (versioning_status['Versioning'] == \"Suspended\" and versioning) ):\n+        bucket.configure_versioning(versioning)\n+        changed = True\n+        versioning_status = bucket.get_versioning_status()\n+\n     # Requester pays\n     requester_pays_status = get_request_payment_status(bucket)\n     if requester_pays_status != requester_pays:\n         if requester_pays:\n-            bucket.set_request_payment(payer='Requester')\n-            changed = True\n-            requester_pays_status = get_request_payment_status(bucket)\n+            payer='Requester'\n         else:\n-            bucket.set_request_payment(payer='BucketOwner')\n-            changed = True\n-            requester_pays_status = get_request_payment_status(bucket)\n+            payer='BucketOwner'\n+        bucket.set_request_payment(payer=payer)\n+        changed = True\n+        requester_pays_status = get_request_payment_status(bucket)\n \n-    # Policy        \n+    # Policy\n     try:\n         current_policy = bucket.get_policy()\n     except S3ResponseError as e:\n         if e.error_code == \"NoSuchBucketPolicy\":\n             current_policy = None\n         else:\n             module.fail_json(msg=e.message)\n-    \n-    if current_policy is not None and policy is not None:\n-        if policy is not None:\n-            policy = json.dumps(policy)\n-            \n-        if json.loads(current_policy) != json.loads(policy):\n+\n+    if policy is not None:\n+        compare_policy = json.loads(policy)\n+\n+        if current_policy is None or json.loads(current_policy) != compare_policy:\n             try:\n-                bucket.set_policy(policy)\n+                bucket.set_policy(load_policy)","path":"cloud/amazon/s3_bucket.py","position":134,"original_position":134,"commit_id":"b172a13fa61b134252e63ae3ed577bf3b3978954","original_commit_id":"b172a13fa61b134252e63ae3ed577bf3b3978954","user":{"login":"bcoca","id":836171,"avatar_url":"https://avatars.githubusercontent.com/u/836171?v=3","gravatar_id":"","url":"https://api.github.com/users/bcoca","html_url":"https://github.com/bcoca","followers_url":"https://api.github.com/users/bcoca/followers","following_url":"https://api.github.com/users/bcoca/following{/other_user}","gists_url":"https://api.github.com/users/bcoca/gists{/gist_id}","starred_url":"https://api.github.com/users/bcoca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcoca/subscriptions","organizations_url":"https://api.github.com/users/bcoca/orgs","repos_url":"https://api.github.com/users/bcoca/repos","events_url":"https://api.github.com/users/bcoca/events{/privacy}","received_events_url":"https://api.github.com/users/bcoca/received_events","type":"User","site_admin":false},"body":"fixing it, was typo","created_at":"2016-07-27T15:38:27Z","updated_at":"2016-07-27T15:38:27Z","html_url":"https://github.com/ansible/ansible-modules-extras/pull/2126#discussion_r72464041","pull_request_url":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/2126","_links":{"self":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/comments/72464041"},"html":{"href":"https://github.com/ansible/ansible-modules-extras/pull/2126#discussion_r72464041"},"pull_request":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/2126"}}},"pull_request":{"url":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/2126","id":68295150,"html_url":"https://github.com/ansible/ansible-modules-extras/pull/2126","diff_url":"https://github.com/ansible/ansible-modules-extras/pull/2126.diff","patch_url":"https://github.com/ansible/ansible-modules-extras/pull/2126.patch","issue_url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/2126","number":2126,"state":"open","locked":false,"title":"fixes and refactoring of s3_bucket","user":{"login":"bcoca","id":836171,"avatar_url":"https://avatars.githubusercontent.com/u/836171?v=3","gravatar_id":"","url":"https://api.github.com/users/bcoca","html_url":"https://github.com/bcoca","followers_url":"https://api.github.com/users/bcoca/followers","following_url":"https://api.github.com/users/bcoca/following{/other_user}","gists_url":"https://api.github.com/users/bcoca/gists{/gist_id}","starred_url":"https://api.github.com/users/bcoca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcoca/subscriptions","organizations_url":"https://api.github.com/users/bcoca/orgs","repos_url":"https://api.github.com/users/bcoca/repos","events_url":"https://api.github.com/users/bcoca/events{/privacy}","received_events_url":"https://api.github.com/users/bcoca/received_events","type":"User","site_admin":false},"body":"##### ISSUE TYPE\r\n\r\n - Bugfix Pull Request\r\n\r\n\r\n##### COMPONENT NAME\r\ns3_bucket\r\n\r\n##### ANSIBLE VERSION\r\n```\r\n2.2\r\n```\r\n\r\n##### SUMMARY\r\npolicy should now accept and handle correctly both data structures or JSON strings\r\nother minor fixes, removed unused vars, set correct type in args spec, clarified func name, etc\r\nrefactored code to make conditions clearer\r\n\r\nfixes https://github.com/ansible/ansible/issues/15603","created_at":"2016-04-28T21:39:59Z","updated_at":"2016-07-27T15:38:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"93d2b529c2ce7426c5dbc25736a3b617cf43f06e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/2126/commits","review_comments_url":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/2126/comments","review_comment_url":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/2126/comments","statuses_url":"https://api.github.com/repos/ansible/ansible-modules-extras/statuses/b172a13fa61b134252e63ae3ed577bf3b3978954","head":{"label":"bcoca:s3_bucket_fix_json_plus","ref":"s3_bucket_fix_json_plus","sha":"b172a13fa61b134252e63ae3ed577bf3b3978954","user":{"login":"bcoca","id":836171,"avatar_url":"https://avatars.githubusercontent.com/u/836171?v=3","gravatar_id":"","url":"https://api.github.com/users/bcoca","html_url":"https://github.com/bcoca","followers_url":"https://api.github.com/users/bcoca/followers","following_url":"https://api.github.com/users/bcoca/following{/other_user}","gists_url":"https://api.github.com/users/bcoca/gists{/gist_id}","starred_url":"https://api.github.com/users/bcoca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcoca/subscriptions","organizations_url":"https://api.github.com/users/bcoca/orgs","repos_url":"https://api.github.com/users/bcoca/repos","events_url":"https://api.github.com/users/bcoca/events{/privacy}","received_events_url":"https://api.github.com/users/bcoca/received_events","type":"User","site_admin":false},"repo":{"id":24656069,"name":"ansible-modules-extras","full_name":"bcoca/ansible-modules-extras","owner":{"login":"bcoca","id":836171,"avatar_url":"https://avatars.githubusercontent.com/u/836171?v=3","gravatar_id":"","url":"https://api.github.com/users/bcoca","html_url":"https://github.com/bcoca","followers_url":"https://api.github.com/users/bcoca/followers","following_url":"https://api.github.com/users/bcoca/following{/other_user}","gists_url":"https://api.github.com/users/bcoca/gists{/gist_id}","starred_url":"https://api.github.com/users/bcoca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcoca/subscriptions","organizations_url":"https://api.github.com/users/bcoca/orgs","repos_url":"https://api.github.com/users/bcoca/repos","events_url":"https://api.github.com/users/bcoca/events{/privacy}","received_events_url":"https://api.github.com/users/bcoca/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bcoca/ansible-modules-extras","description":"Ansible extra modules - these modules ship with ansible","fork":true,"url":"https://api.github.com/repos/bcoca/ansible-modules-extras","forks_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/forks","keys_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/teams","hooks_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/hooks","issue_events_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/issues/events{/number}","events_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/events","assignees_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/assignees{/user}","branches_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/branches{/branch}","tags_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/tags","blobs_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/git/refs{/sha}","trees_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/statuses/{sha}","languages_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/languages","stargazers_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/stargazers","contributors_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/contributors","subscribers_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/subscribers","subscription_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/subscription","commits_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/commits{/sha}","git_commits_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/git/commits{/sha}","comments_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/comments{/number}","issue_comment_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/issues/comments{/number}","contents_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/contents/{+path}","compare_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/merges","archive_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/downloads","issues_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/issues{/number}","pulls_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/pulls{/number}","milestones_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/milestones{/number}","notifications_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/labels{/name}","releases_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/releases{/id}","deployments_url":"https://api.github.com/repos/bcoca/ansible-modules-extras/deployments","created_at":"2014-09-30T21:18:45Z","updated_at":"2016-02-02T05:16:46Z","pushed_at":"2016-07-26T13:52:45Z","git_url":"git://github.com/bcoca/ansible-modules-extras.git","ssh_url":"git@github.com:bcoca/ansible-modules-extras.git","clone_url":"https://github.com/bcoca/ansible-modules-extras.git","svn_url":"https://github.com/bcoca/ansible-modules-extras","homepage":"","size":7619,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"devel"}},"base":{"label":"ansible:devel","ref":"devel","sha":"db979dde748cc3829cdcdee47f4526e06428fdde","user":{"login":"ansible","id":1507452,"avatar_url":"https://avatars.githubusercontent.com/u/1507452?v=3","gravatar_id":"","url":"https://api.github.com/users/ansible","html_url":"https://github.com/ansible","followers_url":"https://api.github.com/users/ansible/followers","following_url":"https://api.github.com/users/ansible/following{/other_user}","gists_url":"https://api.github.com/users/ansible/gists{/gist_id}","starred_url":"https://api.github.com/users/ansible/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansible/subscriptions","organizations_url":"https://api.github.com/users/ansible/orgs","repos_url":"https://api.github.com/users/ansible/repos","events_url":"https://api.github.com/users/ansible/events{/privacy}","received_events_url":"https://api.github.com/users/ansible/received_events","type":"Organization","site_admin":false},"repo":{"id":24474138,"name":"ansible-modules-extras","full_name":"ansible/ansible-modules-extras","owner":{"login":"ansible","id":1507452,"avatar_url":"https://avatars.githubusercontent.com/u/1507452?v=3","gravatar_id":"","url":"https://api.github.com/users/ansible","html_url":"https://github.com/ansible","followers_url":"https://api.github.com/users/ansible/followers","following_url":"https://api.github.com/users/ansible/following{/other_user}","gists_url":"https://api.github.com/users/ansible/gists{/gist_id}","starred_url":"https://api.github.com/users/ansible/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansible/subscriptions","organizations_url":"https://api.github.com/users/ansible/orgs","repos_url":"https://api.github.com/users/ansible/repos","events_url":"https://api.github.com/users/ansible/events{/privacy}","received_events_url":"https://api.github.com/users/ansible/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ansible/ansible-modules-extras","description":"Ansible extra modules - these modules ship with ansible","fork":false,"url":"https://api.github.com/repos/ansible/ansible-modules-extras","forks_url":"https://api.github.com/repos/ansible/ansible-modules-extras/forks","keys_url":"https://api.github.com/repos/ansible/ansible-modules-extras/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ansible/ansible-modules-extras/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ansible/ansible-modules-extras/teams","hooks_url":"https://api.github.com/repos/ansible/ansible-modules-extras/hooks","issue_events_url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/events{/number}","events_url":"https://api.github.com/repos/ansible/ansible-modules-extras/events","assignees_url":"https://api.github.com/repos/ansible/ansible-modules-extras/assignees{/user}","branches_url":"https://api.github.com/repos/ansible/ansible-modules-extras/branches{/branch}","tags_url":"https://api.github.com/repos/ansible/ansible-modules-extras/tags","blobs_url":"https://api.github.com/repos/ansible/ansible-modules-extras/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ansible/ansible-modules-extras/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ansible/ansible-modules-extras/git/refs{/sha}","trees_url":"https://api.github.com/repos/ansible/ansible-modules-extras/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ansible/ansible-modules-extras/statuses/{sha}","languages_url":"https://api.github.com/repos/ansible/ansible-modules-extras/languages","stargazers_url":"https://api.github.com/repos/ansible/ansible-modules-extras/stargazers","contributors_url":"https://api.github.com/repos/ansible/ansible-modules-extras/contributors","subscribers_url":"https://api.github.com/repos/ansible/ansible-modules-extras/subscribers","subscription_url":"https://api.github.com/repos/ansible/ansible-modules-extras/subscription","commits_url":"https://api.github.com/repos/ansible/ansible-modules-extras/commits{/sha}","git_commits_url":"https://api.github.com/repos/ansible/ansible-modules-extras/git/commits{/sha}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-extras/comments{/number}","issue_comment_url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/comments{/number}","contents_url":"https://api.github.com/repos/ansible/ansible-modules-extras/contents/{+path}","compare_url":"https://api.github.com/repos/ansible/ansible-modules-extras/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ansible/ansible-modules-extras/merges","archive_url":"https://api.github.com/repos/ansible/ansible-modules-extras/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ansible/ansible-modules-extras/downloads","issues_url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues{/number}","pulls_url":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls{/number}","milestones_url":"https://api.github.com/repos/ansible/ansible-modules-extras/milestones{/number}","notifications_url":"https://api.github.com/repos/ansible/ansible-modules-extras/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ansible/ansible-modules-extras/labels{/name}","releases_url":"https://api.github.com/repos/ansible/ansible-modules-extras/releases{/id}","deployments_url":"https://api.github.com/repos/ansible/ansible-modules-extras/deployments","created_at":"2014-09-25T20:28:42Z","updated_at":"2016-07-27T14:10:08Z","pushed_at":"2016-07-27T15:03:15Z","git_url":"git://github.com/ansible/ansible-modules-extras.git","ssh_url":"git@github.com:ansible/ansible-modules-extras.git","clone_url":"https://github.com/ansible/ansible-modules-extras.git","svn_url":"https://github.com/ansible/ansible-modules-extras","homepage":"","size":52260,"stargazers_count":654,"watchers_count":654,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1350,"mirror_url":null,"open_issues_count":657,"forks":1350,"open_issues":657,"watchers":654,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/2126"},"html":{"href":"https://github.com/ansible/ansible-modules-extras/pull/2126"},"issue":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/2126"},"comments":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/2126/comments"},"review_comments":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/2126/comments"},"review_comment":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/pulls/2126/commits"},"statuses":{"href":"https://api.github.com/repos/ansible/ansible-modules-extras/statuses/b172a13fa61b134252e63ae3ed577bf3b3978954"}}}}
{"actor":{"display_login":"bcoca"}}