{"action":"created","comment":{"url":"https://api.github.com/repos/crowbar/crowbar-core/pulls/comments/68756842","id":68756842,"diff_hunk":"@@ -0,0 +1,50 @@\n+# Copyright (c) 2016 SUSE Linux GmbH.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+#     http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+#\n+\n+module CrowbarRoleRecipe\n+  # Helper to decide whether a role should be run for a node, depending on the\n+  # state of the node.\n+  def self.node_state_valid_for_role(node, barclamp, role)\n+    if node.key? barclamp\n+      states_for_role = if node[barclamp].key? \"element_states\"\n+        # if nil, then this means all states are valid\n+        node[barclamp][\"element_states\"][role]\n+      else\n+        [\"all\"]\n+      end\n+\n+      valid = states_for_role.nil? ||\n+        states_for_role.include?(\"all\") ||\n+        states_for_role.include?(node[:state])\n+\n+      unless valid\n+        Chef::Log.info(\"Skipping role \\\"#{role}\\\" because node is in state \\\"#{node[:state]}\\\". \" \\\n+          \"Role \\\"#{role}\\\" only applies in the following states: #{states_for_role.join(\", \")}.\")\n+      end\n+    else\n+      # Generally speaking, if we don't even have attributes related to the\n+      # barclamp, then it means the role should not even be there.\n+      # There's one exception, though: when bootstrapping the admin server,\n+      # this happens for a couple of roles.\n+      valid = [\"crowbar\", \"deployer-client\"].include? role\n+\n+      unless valid\n+        Chef::Log.info(\"Skipping role \\\"#{role}\\\" because node does not have applied proposal for #{role} in its runlist.\")\n+      end\n+    end\n+\n+    valid","path":"chef/cookbooks/utils/libraries/role_recipe.rb","position":48,"original_position":48,"commit_id":"1e58d81317c22768d04cf6d2027fd9e2d6bb1e20","original_commit_id":"1e58d81317c22768d04cf6d2027fd9e2d6bb1e20","user":{"login":"MaximilianMeister","id":5364817,"avatar_url":"https://avatars.githubusercontent.com/u/5364817?v=3","gravatar_id":"","url":"https://api.github.com/users/MaximilianMeister","html_url":"https://github.com/MaximilianMeister","followers_url":"https://api.github.com/users/MaximilianMeister/followers","following_url":"https://api.github.com/users/MaximilianMeister/following{/other_user}","gists_url":"https://api.github.com/users/MaximilianMeister/gists{/gist_id}","starred_url":"https://api.github.com/users/MaximilianMeister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaximilianMeister/subscriptions","organizations_url":"https://api.github.com/users/MaximilianMeister/orgs","repos_url":"https://api.github.com/users/MaximilianMeister/repos","events_url":"https://api.github.com/users/MaximilianMeister/events{/privacy}","received_events_url":"https://api.github.com/users/MaximilianMeister/received_events","type":"User","site_admin":false},"body":"... and finally add a\r\n```ruby\r\nreturn false\r\n```","created_at":"2016-06-28T13:35:07Z","updated_at":"2016-06-28T13:35:07Z","html_url":"https://github.com/crowbar/crowbar-core/pull/514#discussion_r68756842","pull_request_url":"https://api.github.com/repos/crowbar/crowbar-core/pulls/514","_links":{"self":{"href":"https://api.github.com/repos/crowbar/crowbar-core/pulls/comments/68756842"},"html":{"href":"https://github.com/crowbar/crowbar-core/pull/514#discussion_r68756842"},"pull_request":{"href":"https://api.github.com/repos/crowbar/crowbar-core/pulls/514"}}},"pull_request":{"url":"https://api.github.com/repos/crowbar/crowbar-core/pulls/514","id":75308121,"html_url":"https://github.com/crowbar/crowbar-core/pull/514","diff_url":"https://github.com/crowbar/crowbar-core/pull/514.diff","patch_url":"https://github.com/crowbar/crowbar-core/pull/514.patch","issue_url":"https://api.github.com/repos/crowbar/crowbar-core/issues/514","number":514,"state":"open","locked":false,"title":"chef: Add CrowbarRoleRecipe.node_state_valid_for_role helper","user":{"login":"vuntz","id":1758783,"avatar_url":"https://avatars.githubusercontent.com/u/1758783?v=3","gravatar_id":"","url":"https://api.github.com/users/vuntz","html_url":"https://github.com/vuntz","followers_url":"https://api.github.com/users/vuntz/followers","following_url":"https://api.github.com/users/vuntz/following{/other_user}","gists_url":"https://api.github.com/users/vuntz/gists{/gist_id}","starred_url":"https://api.github.com/users/vuntz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vuntz/subscriptions","organizations_url":"https://api.github.com/users/vuntz/orgs","repos_url":"https://api.github.com/users/vuntz/repos","events_url":"https://api.github.com/users/vuntz/events{/privacy}","received_events_url":"https://api.github.com/users/vuntz/received_events","type":"User","site_admin":false},"body":"This is used in role recipes to decide whether the role should be run or\r\nnot. This will allow us to stop rebuilding the run_list based on the\r\nstate of the nodes, since we move the logic in the role recipes.","created_at":"2016-06-27T13:09:11Z","updated_at":"2016-06-28T13:35:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9165ba15ae4326b62d4ce71c45f456a870e850f0","assignee":{"login":"jsuchome","id":910000,"avatar_url":"https://avatars.githubusercontent.com/u/910000?v=3","gravatar_id":"","url":"https://api.github.com/users/jsuchome","html_url":"https://github.com/jsuchome","followers_url":"https://api.github.com/users/jsuchome/followers","following_url":"https://api.github.com/users/jsuchome/following{/other_user}","gists_url":"https://api.github.com/users/jsuchome/gists{/gist_id}","starred_url":"https://api.github.com/users/jsuchome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsuchome/subscriptions","organizations_url":"https://api.github.com/users/jsuchome/orgs","repos_url":"https://api.github.com/users/jsuchome/repos","events_url":"https://api.github.com/users/jsuchome/events{/privacy}","received_events_url":"https://api.github.com/users/jsuchome/received_events","type":"User","site_admin":false},"assignees":[{"login":"jsuchome","id":910000,"avatar_url":"https://avatars.githubusercontent.com/u/910000?v=3","gravatar_id":"","url":"https://api.github.com/users/jsuchome","html_url":"https://github.com/jsuchome","followers_url":"https://api.github.com/users/jsuchome/followers","following_url":"https://api.github.com/users/jsuchome/following{/other_user}","gists_url":"https://api.github.com/users/jsuchome/gists{/gist_id}","starred_url":"https://api.github.com/users/jsuchome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsuchome/subscriptions","organizations_url":"https://api.github.com/users/jsuchome/orgs","repos_url":"https://api.github.com/users/jsuchome/repos","events_url":"https://api.github.com/users/jsuchome/events{/privacy}","received_events_url":"https://api.github.com/users/jsuchome/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/crowbar/crowbar-core/pulls/514/commits","review_comments_url":"https://api.github.com/repos/crowbar/crowbar-core/pulls/514/comments","review_comment_url":"https://api.github.com/repos/crowbar/crowbar-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/crowbar/crowbar-core/issues/514/comments","statuses_url":"https://api.github.com/repos/crowbar/crowbar-core/statuses/1e58d81317c22768d04cf6d2027fd9e2d6bb1e20","head":{"label":"vuntz:role-recipes-part2","ref":"role-recipes-part2","sha":"1e58d81317c22768d04cf6d2027fd9e2d6bb1e20","user":{"login":"vuntz","id":1758783,"avatar_url":"https://avatars.githubusercontent.com/u/1758783?v=3","gravatar_id":"","url":"https://api.github.com/users/vuntz","html_url":"https://github.com/vuntz","followers_url":"https://api.github.com/users/vuntz/followers","following_url":"https://api.github.com/users/vuntz/following{/other_user}","gists_url":"https://api.github.com/users/vuntz/gists{/gist_id}","starred_url":"https://api.github.com/users/vuntz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vuntz/subscriptions","organizations_url":"https://api.github.com/users/vuntz/orgs","repos_url":"https://api.github.com/users/vuntz/repos","events_url":"https://api.github.com/users/vuntz/events{/privacy}","received_events_url":"https://api.github.com/users/vuntz/received_events","type":"User","site_admin":false},"repo":{"id":41142179,"name":"crowbar-core","full_name":"vuntz/crowbar-core","owner":{"login":"vuntz","id":1758783,"avatar_url":"https://avatars.githubusercontent.com/u/1758783?v=3","gravatar_id":"","url":"https://api.github.com/users/vuntz","html_url":"https://github.com/vuntz","followers_url":"https://api.github.com/users/vuntz/followers","following_url":"https://api.github.com/users/vuntz/following{/other_user}","gists_url":"https://api.github.com/users/vuntz/gists{/gist_id}","starred_url":"https://api.github.com/users/vuntz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vuntz/subscriptions","organizations_url":"https://api.github.com/users/vuntz/orgs","repos_url":"https://api.github.com/users/vuntz/repos","events_url":"https://api.github.com/users/vuntz/events{/privacy}","received_events_url":"https://api.github.com/users/vuntz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vuntz/crowbar-core","description":"Core deployment for Crowbar","fork":true,"url":"https://api.github.com/repos/vuntz/crowbar-core","forks_url":"https://api.github.com/repos/vuntz/crowbar-core/forks","keys_url":"https://api.github.com/repos/vuntz/crowbar-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vuntz/crowbar-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vuntz/crowbar-core/teams","hooks_url":"https://api.github.com/repos/vuntz/crowbar-core/hooks","issue_events_url":"https://api.github.com/repos/vuntz/crowbar-core/issues/events{/number}","events_url":"https://api.github.com/repos/vuntz/crowbar-core/events","assignees_url":"https://api.github.com/repos/vuntz/crowbar-core/assignees{/user}","branches_url":"https://api.github.com/repos/vuntz/crowbar-core/branches{/branch}","tags_url":"https://api.github.com/repos/vuntz/crowbar-core/tags","blobs_url":"https://api.github.com/repos/vuntz/crowbar-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vuntz/crowbar-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vuntz/crowbar-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/vuntz/crowbar-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vuntz/crowbar-core/statuses/{sha}","languages_url":"https://api.github.com/repos/vuntz/crowbar-core/languages","stargazers_url":"https://api.github.com/repos/vuntz/crowbar-core/stargazers","contributors_url":"https://api.github.com/repos/vuntz/crowbar-core/contributors","subscribers_url":"https://api.github.com/repos/vuntz/crowbar-core/subscribers","subscription_url":"https://api.github.com/repos/vuntz/crowbar-core/subscription","commits_url":"https://api.github.com/repos/vuntz/crowbar-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/vuntz/crowbar-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/vuntz/crowbar-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/vuntz/crowbar-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/vuntz/crowbar-core/contents/{+path}","compare_url":"https://api.github.com/repos/vuntz/crowbar-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vuntz/crowbar-core/merges","archive_url":"https://api.github.com/repos/vuntz/crowbar-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vuntz/crowbar-core/downloads","issues_url":"https://api.github.com/repos/vuntz/crowbar-core/issues{/number}","pulls_url":"https://api.github.com/repos/vuntz/crowbar-core/pulls{/number}","milestones_url":"https://api.github.com/repos/vuntz/crowbar-core/milestones{/number}","notifications_url":"https://api.github.com/repos/vuntz/crowbar-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vuntz/crowbar-core/labels{/name}","releases_url":"https://api.github.com/repos/vuntz/crowbar-core/releases{/id}","deployments_url":"https://api.github.com/repos/vuntz/crowbar-core/deployments","created_at":"2015-08-21T07:34:19Z","updated_at":"2016-02-09T13:19:08Z","pushed_at":"2016-06-28T11:34:17Z","git_url":"git://github.com/vuntz/crowbar-core.git","ssh_url":"git@github.com:vuntz/crowbar-core.git","clone_url":"https://github.com/vuntz/crowbar-core.git","svn_url":"https://github.com/vuntz/crowbar-core","homepage":null,"size":106279,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"master"}},"base":{"label":"crowbar:master","ref":"master","sha":"68fc5e31a4db8c60b482023ce6f1bff73329a958","user":{"login":"crowbar","id":2910205,"avatar_url":"https://avatars.githubusercontent.com/u/2910205?v=3","gravatar_id":"","url":"https://api.github.com/users/crowbar","html_url":"https://github.com/crowbar","followers_url":"https://api.github.com/users/crowbar/followers","following_url":"https://api.github.com/users/crowbar/following{/other_user}","gists_url":"https://api.github.com/users/crowbar/gists{/gist_id}","starred_url":"https://api.github.com/users/crowbar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crowbar/subscriptions","organizations_url":"https://api.github.com/users/crowbar/orgs","repos_url":"https://api.github.com/users/crowbar/repos","events_url":"https://api.github.com/users/crowbar/events{/privacy}","received_events_url":"https://api.github.com/users/crowbar/received_events","type":"Organization","site_admin":false},"repo":{"id":39003227,"name":"crowbar-core","full_name":"crowbar/crowbar-core","owner":{"login":"crowbar","id":2910205,"avatar_url":"https://avatars.githubusercontent.com/u/2910205?v=3","gravatar_id":"","url":"https://api.github.com/users/crowbar","html_url":"https://github.com/crowbar","followers_url":"https://api.github.com/users/crowbar/followers","following_url":"https://api.github.com/users/crowbar/following{/other_user}","gists_url":"https://api.github.com/users/crowbar/gists{/gist_id}","starred_url":"https://api.github.com/users/crowbar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crowbar/subscriptions","organizations_url":"https://api.github.com/users/crowbar/orgs","repos_url":"https://api.github.com/users/crowbar/repos","events_url":"https://api.github.com/users/crowbar/events{/privacy}","received_events_url":"https://api.github.com/users/crowbar/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crowbar/crowbar-core","description":"Core deployment for Crowbar","fork":false,"url":"https://api.github.com/repos/crowbar/crowbar-core","forks_url":"https://api.github.com/repos/crowbar/crowbar-core/forks","keys_url":"https://api.github.com/repos/crowbar/crowbar-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crowbar/crowbar-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crowbar/crowbar-core/teams","hooks_url":"https://api.github.com/repos/crowbar/crowbar-core/hooks","issue_events_url":"https://api.github.com/repos/crowbar/crowbar-core/issues/events{/number}","events_url":"https://api.github.com/repos/crowbar/crowbar-core/events","assignees_url":"https://api.github.com/repos/crowbar/crowbar-core/assignees{/user}","branches_url":"https://api.github.com/repos/crowbar/crowbar-core/branches{/branch}","tags_url":"https://api.github.com/repos/crowbar/crowbar-core/tags","blobs_url":"https://api.github.com/repos/crowbar/crowbar-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crowbar/crowbar-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crowbar/crowbar-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/crowbar/crowbar-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crowbar/crowbar-core/statuses/{sha}","languages_url":"https://api.github.com/repos/crowbar/crowbar-core/languages","stargazers_url":"https://api.github.com/repos/crowbar/crowbar-core/stargazers","contributors_url":"https://api.github.com/repos/crowbar/crowbar-core/contributors","subscribers_url":"https://api.github.com/repos/crowbar/crowbar-core/subscribers","subscription_url":"https://api.github.com/repos/crowbar/crowbar-core/subscription","commits_url":"https://api.github.com/repos/crowbar/crowbar-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/crowbar/crowbar-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/crowbar/crowbar-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/crowbar/crowbar-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/crowbar/crowbar-core/contents/{+path}","compare_url":"https://api.github.com/repos/crowbar/crowbar-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crowbar/crowbar-core/merges","archive_url":"https://api.github.com/repos/crowbar/crowbar-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crowbar/crowbar-core/downloads","issues_url":"https://api.github.com/repos/crowbar/crowbar-core/issues{/number}","pulls_url":"https://api.github.com/repos/crowbar/crowbar-core/pulls{/number}","milestones_url":"https://api.github.com/repos/crowbar/crowbar-core/milestones{/number}","notifications_url":"https://api.github.com/repos/crowbar/crowbar-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crowbar/crowbar-core/labels{/name}","releases_url":"https://api.github.com/repos/crowbar/crowbar-core/releases{/id}","deployments_url":"https://api.github.com/repos/crowbar/crowbar-core/deployments","created_at":"2015-07-13T09:31:28Z","updated_at":"2016-04-10T12:47:20Z","pushed_at":"2016-06-28T11:34:17Z","git_url":"git://github.com/crowbar/crowbar-core.git","ssh_url":"git@github.com:crowbar/crowbar-core.git","clone_url":"https://github.com/crowbar/crowbar-core.git","svn_url":"https://github.com/crowbar/crowbar-core","homepage":null,"size":120563,"stargazers_count":6,"watchers_count":6,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":28,"mirror_url":null,"open_issues_count":43,"forks":28,"open_issues":43,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/crowbar/crowbar-core/pulls/514"},"html":{"href":"https://github.com/crowbar/crowbar-core/pull/514"},"issue":{"href":"https://api.github.com/repos/crowbar/crowbar-core/issues/514"},"comments":{"href":"https://api.github.com/repos/crowbar/crowbar-core/issues/514/comments"},"review_comments":{"href":"https://api.github.com/repos/crowbar/crowbar-core/pulls/514/comments"},"review_comment":{"href":"https://api.github.com/repos/crowbar/crowbar-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/crowbar/crowbar-core/pulls/514/commits"},"statuses":{"href":"https://api.github.com/repos/crowbar/crowbar-core/statuses/1e58d81317c22768d04cf6d2027fd9e2d6bb1e20"}}}}
{"actor":{"display_login":"MaximilianMeister"}}