{"action":"created","issue":{"url":"https://api.github.com/repos/hercules-team/augeasproviders_shellvar/issues/14","labels_url":"https://api.github.com/repos/hercules-team/augeasproviders_shellvar/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/hercules-team/augeasproviders_shellvar/issues/14/comments","events_url":"https://api.github.com/repos/hercules-team/augeasproviders_shellvar/issues/14/events","html_url":"https://github.com/hercules-team/augeasproviders_shellvar/issues/14","id":81468803,"number":14,"title":"Bulk updates requires a lot of studdering","user":{"login":"TomOnTime","id":1389289,"avatar_url":"https://avatars.githubusercontent.com/u/1389289?v=3","gravatar_id":"","url":"https://api.github.com/users/TomOnTime","html_url":"https://github.com/TomOnTime","followers_url":"https://api.github.com/users/TomOnTime/followers","following_url":"https://api.github.com/users/TomOnTime/following{/other_user}","gists_url":"https://api.github.com/users/TomOnTime/gists{/gist_id}","starred_url":"https://api.github.com/users/TomOnTime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TomOnTime/subscriptions","organizations_url":"https://api.github.com/users/TomOnTime/orgs","repos_url":"https://api.github.com/users/TomOnTime/repos","events_url":"https://api.github.com/users/TomOnTime/events{/privacy}","received_events_url":"https://api.github.com/users/TomOnTime/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-27T14:24:39Z","updated_at":"2015-05-27T19:58:59Z","closed_at":null,"body":"Problem: If one has to set a lot of variables in many files (for example, using each()), you have to repeat yourself a lot.\r\n\r\nFor example, this is the cleanest I've been able to write for setting many variables.  \r\n```\r\n  Shellvar {\r\n    ensure => present,\r\n    target => $ifile,\r\n  }\r\n\r\n  shellvar { \"${name} DEVICE\": variable => 'DEVICE', value  => $name}\r\n  shellvar { \"${name} NAME\": variable => 'NAME', value  => $name}\r\n  shellvar { \"${name} HWADDR\": variable => 'HWADDR', value => $hwaddress}\r\n  shellvar { \"${name} TEAM_MASTER\": variable => 'TEAM_MASTER', value => $team_master}\r\n  shellvar { \"${name} DEVICETYPE\": variable => 'DEVICETYPE', value  => 'TeamPort'}\r\n  shellvar { \"${name} ONBOOT\": variable => \"TYPE\", value => 'yes'}\r\n  shellvar { \"${name} TYPE\": variable => 'TYPE', value => 'Ethernet'}\r\n  shellvar { \"${name} NM_CONTROLLED\": value => 'NM_CONTROLLED', variable => 'no'}\r\n```\r\n\r\nThere are a few problems with this:\r\n\r\n  * The namevar repeats the variable name, which is error prone. They may get out of sync.\r\n  * Specifying `variable =>` and `value =>` again and again is very verbose. It hides meaning.\r\n  * It is slow. Each one of these will require starting up augeas, parsing the file, etc.\r\n  * You didn't notice that \"ONBOOT\" sets the wrong variable, or that NM_CONTROLLED reversed the value and the variable.\r\n\r\nProposed Solution: For mass updates, it would be more natural to have a function that takes a filename and a list of settings:\r\n\r\n```\r\n  shellvar_bulk( $ifile, [\r\n          \"DEVICE=$name\", \r\n          \"NAME=$name\", \r\n          \"HWADDR=$hwaddress\", \r\n          \"TEAM_MASTER=$TEAM_MASTER\",\r\n          'DEVICETYPE=TeamPort',\r\n          'ONBOOT=yes',\r\n          'TYPE=Ethernet',\r\n          'NM_CONTROLLED=no',\r\n     ])\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/hercules-team/augeasproviders_shellvar/issues/comments/106055313","html_url":"https://github.com/hercules-team/augeasproviders_shellvar/issues/14#issuecomment-106055313","issue_url":"https://api.github.com/repos/hercules-team/augeasproviders_shellvar/issues/14","id":106055313,"user":{"login":"raphink","id":650430,"avatar_url":"https://avatars.githubusercontent.com/u/650430?v=3","gravatar_id":"","url":"https://api.github.com/users/raphink","html_url":"https://github.com/raphink","followers_url":"https://api.github.com/users/raphink/followers","following_url":"https://api.github.com/users/raphink/following{/other_user}","gists_url":"https://api.github.com/users/raphink/gists{/gist_id}","starred_url":"https://api.github.com/users/raphink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raphink/subscriptions","organizations_url":"https://api.github.com/users/raphink/orgs","repos_url":"https://api.github.com/users/raphink/repos","events_url":"https://api.github.com/users/raphink/events{/privacy}","received_events_url":"https://api.github.com/users/raphink/received_events","type":"User","site_admin":false},"created_at":"2015-05-27T19:58:59Z","updated_at":"2015-05-27T19:58:59Z","body":"On the performance issue: since puppet 3.4, augeasproviders use a shared Augeas handler for all resources. Hence, Augeas is only started once, and only parses target files twice as most (one read to fill the tree, a second read to calculate the diff if changes were made, and one write to flush changes if any). All you need is to use puppet 3.4+. The only overhead to using separate resources currently is stuff done entirely in memory, so the gain wouldn't be great."}}