{"action":"created","issue":{"url":"https://api.github.com/repos/voxpupuli/puppet-corosync/issues/132","repository_url":"https://api.github.com/repos/voxpupuli/puppet-corosync","labels_url":"https://api.github.com/repos/voxpupuli/puppet-corosync/issues/132/labels{/name}","comments_url":"https://api.github.com/repos/voxpupuli/puppet-corosync/issues/132/comments","events_url":"https://api.github.com/repos/voxpupuli/puppet-corosync/issues/132/events","html_url":"https://github.com/voxpupuli/puppet-corosync/pull/132","id":71578095,"number":132,"title":"Adding rule property to pcs location","user":{"login":"GiooDev","id":8832896,"avatar_url":"https://avatars.githubusercontent.com/u/8832896?v=3","gravatar_id":"","url":"https://api.github.com/users/GiooDev","html_url":"https://github.com/GiooDev","followers_url":"https://api.github.com/users/GiooDev/followers","following_url":"https://api.github.com/users/GiooDev/following{/other_user}","gists_url":"https://api.github.com/users/GiooDev/gists{/gist_id}","starred_url":"https://api.github.com/users/GiooDev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GiooDev/subscriptions","organizations_url":"https://api.github.com/users/GiooDev/orgs","repos_url":"https://api.github.com/users/GiooDev/repos","events_url":"https://api.github.com/users/GiooDev/events{/privacy}","received_events_url":"https://api.github.com/users/GiooDev/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/voxpupuli/puppet-corosync/labels/enhancement","name":"enhancement","color":"0052cc"},{"url":"https://api.github.com/repos/voxpupuli/puppet-corosync/labels/needs-feedback","name":"needs-feedback","color":"5319e7"},{"url":"https://api.github.com/repos/voxpupuli/puppet-corosync/labels/needs-rebase","name":"needs-rebase","color":"207de5"},{"url":"https://api.github.com/repos/voxpupuli/puppet-corosync/labels/needs-work","name":"needs-work","color":"fbca04"},{"url":"https://api.github.com/repos/voxpupuli/puppet-corosync/labels/tests-fail","name":"tests-fail","color":"e11d21"},{"url":"https://api.github.com/repos/voxpupuli/puppet-corosync/labels/x.y.z:%20Y%20version%20bump","name":"x.y.z: Y version bump","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":24,"created_at":"2015-04-28T12:36:12Z","updated_at":"2016-09-06T14:31:35Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/voxpupuli/puppet-corosync/pulls/132","html_url":"https://github.com/voxpupuli/puppet-corosync/pull/132","diff_url":"https://github.com/voxpupuli/puppet-corosync/pull/132.diff","patch_url":"https://github.com/voxpupuli/puppet-corosync/pull/132.patch"},"body":"# Overview\r\nOn our infrastructure we need to add some rule to manage location constraints with pcs. But this feature wasn't supported by the puppetlabs-corosync module.\r\n\r\nHere is my Pull Request to add this functionnality.\r\n\r\n# How to do it manually\r\n\r\nTo add a rule, you need to execute the following commands :\r\n`/usr/sbin/pcs constraint location add location-sv-dummy sv-dummy1 node_name.domain INFINITY`\r\n`/usr/sbin/pcs constraint location sv-dummy1 rule score=-INFINITY #kind eq container`\r\n\r\nThat gives us this xml output from `pcs cluster cib` command:\r\n```xml\r\n      <rsc_location id=\"location-sv-dummy\" node=\"node_name.domain\" rsc=\"sv-dummy1\" score=\"INFINITY\"/>\r\n      <rsc_location id=\"location-sv-dummy1\" rsc=\"sv-dummy1\">\r\n        <rule id=\"location-sv-dummy1-rule\" score=\"-INFINITY\">\r\n          <expression attribute=\"#kind\" id=\"location-sv-dummy1-rule-expr\" operation=\"eq\" value=\"container\"/>\r\n        </rule>\r\n      </rsc_location>\r\n```\r\n\r\nAnd you should obtain the following output from `pcs constraint location show` command:\r\n```\r\n  Resource: sv-dummy1\r\n    Enabled on: node_name.domain (score:INFINITY)\r\n    Constraint: location-sv-dummy1\r\n      Rule: score=-INFINITY\r\n        Expression: #kind eq container\r\n```\r\n\r\nThis rule means that you deny (-INFINITY) to launch your resource on a container (like VM).\r\n\r\n# How to manage it with Puppet\r\n\r\nExample of how you can set your rule with the following Puppet code.\r\n\r\n```puppet\r\n    cs_location { 'location-sv-dummy':\r\n      primitive => 'sv-dummy1',\r\n      rule      => { 'score'      => '-INFINITY',\r\n                     'expression' => { 'attribute' => '#kind',\r\n                                       'operation' => 'eq',\r\n                                       'value'     => 'container'\r\n                     }\r\n                   }\r\n    }\r\n```\r\n\r\nBy default,  the rule => score is set to score=INFINITY (see pcs man page). You can also use score-attributes instead of score.\r\nThe expression determines the operation to execute for this rule.\r\n\r\nWhen you applied it, it works fine:\r\n```puppet\r\n    Debug: Cs_location[location-sv-dummy](provider=pcs): {}\r\n    Notice: /Stage[main]/Main/Cs_location[location-sv-dummy]/ensure: created\r\n    Debug: Executing '/usr/sbin/pcs constraint location add location-sv-dummy sv-dummy1 node_name.domain INFINITY'\r\n    Debug: Executing '/usr/sbin/pcs constraint location sv-dummy1 rule score=-INFINITY #kind eq container'\r\n    Debug: /Stage[main]/Main/Cs_location[location-sv-dummy]: The container Class[Main] will propagate my refresh event\r\n    Debug: Class[Main]: The container Stage[main] will propagate my refresh event\r\n```\r\n\r\n# Issues\r\n\r\nThere is still a problem with my code and I didn't find how to solve it yet. This problem appears when you apply for the second time your configuration.\r\n\r\nHere is the Puppet output for this issue :\r\n```puppet\r\n    Debug: Cs_location[location-sv-dummy](provider=pcs): {:name=>\"location-sv-dummy\", :ensure=>:present, :primitive=>\"sv-dummy1\", :node_name=>\"node_name.domain\", :score=>\"INFINITY\", :provider=>:pcs, :rule=>{}}\r\n    Notice: /Stage[main]/Main/Cs_location[location-sv-dummy]/rule: rule changed {} to '{\"score\"=>\"-INFINITY\", \"expression\"=>{\"attribute\"=>\"#kind\", \"operation\"=>\"eq\", \"value\"=>\"container\"}}'\r\n    Debug: Executing '/usr/sbin/pcs constraint location add location-sv-dummy sv-dummy1 node_name.domain INFINITY'\r\n    Debug: Executing '/usr/sbin/pcs constraint location sv-dummy1 rule score=-INFINITY #kind eq container'\r\n    Error: /Stage[main]/Main/Cs_location[location-sv-dummy]: Could not evaluate: Execution of '/usr/sbin/pcs constraint location sv-dummy1 rule score=-INFINITY #kind eq container' returned 1: \r\n```\r\n\r\nI suppose that the data obtains from the xml output are not correctly set on my rule variable but I didn't know how to solve it, so don't hesitate to send me your ideas if you can solve it ^^\r\n\r\nThanks for your help.\r\nJulien Georges <julien.georges@atos.net>"},"comment":{"url":"https://api.github.com/repos/voxpupuli/puppet-corosync/issues/comments/244968854","html_url":"https://github.com/voxpupuli/puppet-corosync/pull/132#issuecomment-244968854","issue_url":"https://api.github.com/repos/voxpupuli/puppet-corosync/issues/132","id":244968854,"user":{"login":"roidelapluie","id":291750,"avatar_url":"https://avatars.githubusercontent.com/u/291750?v=3","gravatar_id":"","url":"https://api.github.com/users/roidelapluie","html_url":"https://github.com/roidelapluie","followers_url":"https://api.github.com/users/roidelapluie/followers","following_url":"https://api.github.com/users/roidelapluie/following{/other_user}","gists_url":"https://api.github.com/users/roidelapluie/gists{/gist_id}","starred_url":"https://api.github.com/users/roidelapluie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roidelapluie/subscriptions","organizations_url":"https://api.github.com/users/roidelapluie/orgs","repos_url":"https://api.github.com/users/roidelapluie/repos","events_url":"https://api.github.com/users/roidelapluie/events{/privacy}","received_events_url":"https://api.github.com/users/roidelapluie/received_events","type":"User","site_admin":false},"created_at":"2016-09-06T14:31:35Z","updated_at":"2016-09-06T14:31:35Z","body":"see #356 "}}
{"actor":{"display_login":"roidelapluie"}}