{"action":"created","comment":{"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/pulls/comments/40778116","id":40778116,"diff_hunk":"@@ -45,26 +50,96 @@ EOF\n \n sudo chmod 644 $lconf\n \n+# Creating rabbitmq systemd stop script\n+cat << EOF | sudo tee /usr/local/bin/kill-rabbit > /dev/null\n+#! /usr/bin/env bash\n+for proc in \"\\$(/usr/bin/ps aux | /usr/bin/grep rabbitmq | /usr/bin/grep -v grep | /usr/bin/awk '{ print \\$2 }')\"; do\n+    /usr/bin/kill \\${proc}\n+done\n+EOF\n+sudo chmod 500 /usr/local/bin/kill-rabbit\n+\n configure_systemd_service \"rabbitmq\"\n \n ctx logger info \"Configuring File Descriptors Limit...\"\n deploy_blueprint_resource \"components/rabbitmq/config/rabbitmq_ulimit.conf\" \"/etc/security/limits.d/rabbitmq.conf\"\n sudo systemctl daemon-reload\n \n+ctx logger info \"Chowning RabbitMQ logs path...\"\n+sudo chown rabbitmq:rabbitmq ${RABBITMQ_LOG_BASE}\n+\n ctx logger info \"Starting RabbitMQ Server in Daemonized mode...\"\n sudo systemctl start cloudify-rabbitmq.service\n \n ctx logger info \"Enabling RabbitMQ Plugins...\"\n-sudo rabbitmq-plugins enable rabbitmq_management >/dev/null\n-sudo rabbitmq-plugins enable rabbitmq_tracing >/dev/null\n-\n-\n-# enable guest user access where cluster not on localhost\n-ctx logger info \"Enabling RabbitMQ user access...\"\n-echo \"[{rabbit, [{loopback_users, []}]}].\" | sudo tee --append /etc/rabbitmq/rabbitmq.config >/dev/null\n-\n-ctx logger info \"Chowning RabbitMQ logs path...\"\n-sudo chown rabbitmq:rabbitmq ${RABBITMQ_LOG_BASE}\n+run_command_with_retries \"sudo rabbitmq-plugins enable rabbitmq_management\"\n+run_command_with_retries \"sudo rabbitmq-plugins enable rabbitmq_tracing\"\n+\n+ctx logger info \"Disabling RabbitMQ guest user\"\n+run_command_with_retries \"sudo rabbitmqctl clear_permissions guest\"\n+run_command_with_retries \"sudo rabbitmqctl delete_user guest\"\n+\n+ctx logger info \"Creating new RabbitMQ user and setting permissions\"\n+run_command_with_retries sudo rabbitmqctl add_user ${RABBITMQ_USERNAME} ${RABBITMQ_PASSWORD}\n+run_noglob_command_with_retries sudo rabbitmqctl set_permissions ${RABBITMQ_USERNAME} '.*' '.*' '.*'\n+\n+# Deploy certificates (if applicable)\n+# TODO: Validate that cert is in PEM format based on openssl command?\n+if [[ \"${RABBITMQ_CERT_PRIVATE}\" =~ \"BEGIN RSA PRIVATE KEY\" ]]; then\n+  ctx logger info \"Found private certificate for rabbitmq.\"\n+  echo \"${RABBITMQ_CERT_PRIVATE}\" | sudo tee /etc/rabbitmq/rabbit-priv.pem >/dev/null\n+  # Only allow owner to see rabbit private cert\n+  sudo chmod 400 /etc/rabbitmq/rabbit-priv.pem\n+  sudo chown rabbitmq. /etc/rabbitmq/rabbit-priv.pem\n+else\n+  if [[ -z \"${RABBITMQ_CERT_PRIVATE}\" ]]; then\n+    ctx logger info \"No private certificate found.\"\n+  else\n+    ctx logger warn \"Private certificate did not appear to be in PEM format.\"\n+  fi\n+fi\n+# TODO: Validate that cert is in PEM format based on openssl command?\n+if [[ \"${RABBITMQ_CERT_PUBLIC}\" =~ \"BEGIN CERTIFICATE\" ]]; then\n+  ctx logger info \"Found public certificate for rabbitmq.\"\n+  echo \"${RABBITMQ_CERT_PUBLIC}\" | sudo tee /etc/rabbitmq/rabbit-pub.pem >/dev/null\n+  # Allow other users to see public cert\n+  sudo chmod 444 /etc/rabbitmq/rabbit-pub.pem\n+  sudo chown rabbitmq. /etc/rabbitmq/rabbit-pub.pem\n+else\n+  if [[ -z \"${RABBITMQ_CERT_PUBLIC}\" ]]; then\n+    ctx logger info \"No public certificate found.\"\n+  else\n+    ctx logger warn \"Public certificate did not appear to be in PEM format.\"\n+  fi\n+  if [[ -f /etc/rabbitmq/rabbit-priv.pem ]]; then\n+    ctx logger error \"Private certificate was provided but public certificate was invalid.\"\n+  fi\n+fi\n+\n+# Configure rabbit\n+if [[ -f /etc/rabbitmq/rabbit-priv.pem ]] && [[ -f /etc/rabbitmq/rabbit-pub.pem ]]; then\n+  echo \"[","path":"new/components/rabbitmq/scripts/create.sh","position":94,"original_position":94,"commit_id":"253cc21edd07dcf2f90268d6c5638a09d74dd8fd","original_commit_id":"253cc21edd07dcf2f90268d6c5638a09d74dd8fd","user":{"login":"geokala","id":8859114,"avatar_url":"https://avatars.githubusercontent.com/u/8859114?v=3","gravatar_id":"","url":"https://api.github.com/users/geokala","html_url":"https://github.com/geokala","followers_url":"https://api.github.com/users/geokala/followers","following_url":"https://api.github.com/users/geokala/following{/other_user}","gists_url":"https://api.github.com/users/geokala/gists{/gist_id}","starred_url":"https://api.github.com/users/geokala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geokala/subscriptions","organizations_url":"https://api.github.com/users/geokala/orgs","repos_url":"https://api.github.com/users/geokala/repos","events_url":"https://api.github.com/users/geokala/events{/privacy}","received_events_url":"https://api.github.com/users/geokala/received_events","type":"User","site_admin":false},"body":"It probably wants commenting, and likely the certificate deployment wants turning into functions so that logic to check that they're actually being created as PEM formatted SSL certs exists. Otherwise, the only easier way would actually be to remove any checks I think?","created_at":"2015-09-30T10:12:57Z","updated_at":"2015-09-30T10:12:57Z","html_url":"https://github.com/cloudify-cosmo/cloudify-manager-blueprints/pull/131#discussion_r40778116","pull_request_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/pulls/131","_links":{"self":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/pulls/comments/40778116"},"html":{"href":"https://github.com/cloudify-cosmo/cloudify-manager-blueprints/pull/131#discussion_r40778116"},"pull_request":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/pulls/131"}}},"pull_request":{"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/pulls/131","id":46259121,"html_url":"https://github.com/cloudify-cosmo/cloudify-manager-blueprints/pull/131","diff_url":"https://github.com/cloudify-cosmo/cloudify-manager-blueprints/pull/131.diff","patch_url":"https://github.com/cloudify-cosmo/cloudify-manager-blueprints/pull/131.patch","issue_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/issues/131","number":131,"state":"open","locked":false,"title":"CFY-3224-Support-rabbitmq-security","user":{"login":"geokala","id":8859114,"avatar_url":"https://avatars.githubusercontent.com/u/8859114?v=3","gravatar_id":"","url":"https://api.github.com/users/geokala","html_url":"https://github.com/geokala","followers_url":"https://api.github.com/users/geokala/followers","following_url":"https://api.github.com/users/geokala/following{/other_user}","gists_url":"https://api.github.com/users/geokala/gists{/gist_id}","starred_url":"https://api.github.com/users/geokala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geokala/subscriptions","organizations_url":"https://api.github.com/users/geokala/orgs","repos_url":"https://api.github.com/users/geokala/repos","events_url":"https://api.github.com/users/geokala/events{/privacy}","received_events_url":"https://api.github.com/users/geokala/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-29T10:18:40Z","updated_at":"2015-09-30T10:12:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b47701c698f9f2f34bb6018fd079014b7a069185","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/pulls/131/commits","review_comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/pulls/131/comments","review_comment_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/issues/131/comments","statuses_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/statuses/253cc21edd07dcf2f90268d6c5638a09d74dd8fd","head":{"label":"geokala:CFY-3224-Support-rabbitmq-security","ref":"CFY-3224-Support-rabbitmq-security","sha":"253cc21edd07dcf2f90268d6c5638a09d74dd8fd","user":{"login":"geokala","id":8859114,"avatar_url":"https://avatars.githubusercontent.com/u/8859114?v=3","gravatar_id":"","url":"https://api.github.com/users/geokala","html_url":"https://github.com/geokala","followers_url":"https://api.github.com/users/geokala/followers","following_url":"https://api.github.com/users/geokala/following{/other_user}","gists_url":"https://api.github.com/users/geokala/gists{/gist_id}","starred_url":"https://api.github.com/users/geokala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geokala/subscriptions","organizations_url":"https://api.github.com/users/geokala/orgs","repos_url":"https://api.github.com/users/geokala/repos","events_url":"https://api.github.com/users/geokala/events{/privacy}","received_events_url":"https://api.github.com/users/geokala/received_events","type":"User","site_admin":false},"repo":{"id":40010060,"name":"cloudify-manager-blueprints","full_name":"geokala/cloudify-manager-blueprints","owner":{"login":"geokala","id":8859114,"avatar_url":"https://avatars.githubusercontent.com/u/8859114?v=3","gravatar_id":"","url":"https://api.github.com/users/geokala","html_url":"https://github.com/geokala","followers_url":"https://api.github.com/users/geokala/followers","following_url":"https://api.github.com/users/geokala/following{/other_user}","gists_url":"https://api.github.com/users/geokala/gists{/gist_id}","starred_url":"https://api.github.com/users/geokala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geokala/subscriptions","organizations_url":"https://api.github.com/users/geokala/orgs","repos_url":"https://api.github.com/users/geokala/repos","events_url":"https://api.github.com/users/geokala/events{/privacy}","received_events_url":"https://api.github.com/users/geokala/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/geokala/cloudify-manager-blueprints","description":"","fork":true,"url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints","forks_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/forks","keys_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/keys{/key_id}","collaborators_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/teams","hooks_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/hooks","issue_events_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/issues/events{/number}","events_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/events","assignees_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/assignees{/user}","branches_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/branches{/branch}","tags_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/tags","blobs_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/git/refs{/sha}","trees_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/git/trees{/sha}","statuses_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/statuses/{sha}","languages_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/languages","stargazers_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/stargazers","contributors_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/contributors","subscribers_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/subscribers","subscription_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/subscription","commits_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/commits{/sha}","git_commits_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/git/commits{/sha}","comments_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/comments{/number}","issue_comment_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/issues/comments{/number}","contents_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/contents/{+path}","compare_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/compare/{base}...{head}","merges_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/merges","archive_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/downloads","issues_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/issues{/number}","pulls_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/pulls{/number}","milestones_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/milestones{/number}","notifications_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/labels{/name}","releases_url":"https://api.github.com/repos/geokala/cloudify-manager-blueprints/releases{/id}","created_at":"2015-07-31T14:49:36Z","updated_at":"2015-07-31T14:49:37Z","pushed_at":"2015-09-29T12:31:14Z","git_url":"git://github.com/geokala/cloudify-manager-blueprints.git","ssh_url":"git@github.com:geokala/cloudify-manager-blueprints.git","clone_url":"https://github.com/geokala/cloudify-manager-blueprints.git","svn_url":"https://github.com/geokala/cloudify-manager-blueprints","homepage":null,"size":986,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cloudify-cosmo:master","ref":"master","sha":"f04f98bd7476d21d5271edffbfe9f158df72e304","user":{"login":"cloudify-cosmo","id":6260555,"avatar_url":"https://avatars.githubusercontent.com/u/6260555?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudify-cosmo","html_url":"https://github.com/cloudify-cosmo","followers_url":"https://api.github.com/users/cloudify-cosmo/followers","following_url":"https://api.github.com/users/cloudify-cosmo/following{/other_user}","gists_url":"https://api.github.com/users/cloudify-cosmo/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudify-cosmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudify-cosmo/subscriptions","organizations_url":"https://api.github.com/users/cloudify-cosmo/orgs","repos_url":"https://api.github.com/users/cloudify-cosmo/repos","events_url":"https://api.github.com/users/cloudify-cosmo/events{/privacy}","received_events_url":"https://api.github.com/users/cloudify-cosmo/received_events","type":"Organization","site_admin":false},"repo":{"id":24557021,"name":"cloudify-manager-blueprints","full_name":"cloudify-cosmo/cloudify-manager-blueprints","owner":{"login":"cloudify-cosmo","id":6260555,"avatar_url":"https://avatars.githubusercontent.com/u/6260555?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudify-cosmo","html_url":"https://github.com/cloudify-cosmo","followers_url":"https://api.github.com/users/cloudify-cosmo/followers","following_url":"https://api.github.com/users/cloudify-cosmo/following{/other_user}","gists_url":"https://api.github.com/users/cloudify-cosmo/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudify-cosmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudify-cosmo/subscriptions","organizations_url":"https://api.github.com/users/cloudify-cosmo/orgs","repos_url":"https://api.github.com/users/cloudify-cosmo/repos","events_url":"https://api.github.com/users/cloudify-cosmo/events{/privacy}","received_events_url":"https://api.github.com/users/cloudify-cosmo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudify-cosmo/cloudify-manager-blueprints","description":"","fork":false,"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints","forks_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/forks","keys_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/teams","hooks_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/hooks","issue_events_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/issues/events{/number}","events_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/events","assignees_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/assignees{/user}","branches_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/branches{/branch}","tags_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/tags","blobs_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/languages","stargazers_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/stargazers","contributors_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/contributors","subscribers_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/subscribers","subscription_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/subscription","commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/contents/{+path}","compare_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/merges","archive_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/downloads","issues_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/issues{/number}","pulls_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/labels{/name}","releases_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/releases{/id}","created_at":"2014-09-28T10:35:22Z","updated_at":"2015-09-06T02:20:25Z","pushed_at":"2015-09-30T08:00:41Z","git_url":"git://github.com/cloudify-cosmo/cloudify-manager-blueprints.git","ssh_url":"git@github.com:cloudify-cosmo/cloudify-manager-blueprints.git","clone_url":"https://github.com/cloudify-cosmo/cloudify-manager-blueprints.git","svn_url":"https://github.com/cloudify-cosmo/cloudify-manager-blueprints","homepage":null,"size":5443,"stargazers_count":3,"watchers_count":3,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":3,"forks":17,"open_issues":3,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/pulls/131"},"html":{"href":"https://github.com/cloudify-cosmo/cloudify-manager-blueprints/pull/131"},"issue":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/issues/131"},"comments":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/issues/131/comments"},"review_comments":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/pulls/131/comments"},"review_comment":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/pulls/131/commits"},"statuses":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager-blueprints/statuses/253cc21edd07dcf2f90268d6c5638a09d74dd8fd"}}}}