{"id":16272321,"url":"https://github.com/ventz/pgsvr","last_synced_at":"2025-07-01T22:33:19.462Z","repository":{"id":8607926,"uuid":"10247349","full_name":"ventz/pgsvr","owner":"ventz","description":"pgsvr - Puppet Git Sync via REST","archived":false,"fork":false,"pushed_at":"2013-10-15T23:06:12.000Z","size":313,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-27T09:50:29.450Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ventz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-05-23T15:49:43.000Z","updated_at":"2020-06-29T02:11:15.000Z","dependencies_parsed_at":"2022-09-19T00:31:40.284Z","dependency_job_id":null,"html_url":"https://github.com/ventz/pgsvr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ventz/pgsvr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ventz%2Fpgsvr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ventz%2Fpgsvr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ventz%2Fpgsvr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ventz%2Fpgsvr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ventz","download_url":"https://codeload.github.com/ventz/pgsvr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ventz%2Fpgsvr/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263046862,"owners_count":23405277,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T18:17:17.703Z","updated_at":"2025-07-01T22:33:19.397Z","avatar_url":"https://github.com/ventz.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"pgsvr - Puppet Git Sync via REST\n================================\nVersion: 0.0.8\n\nVentz Petkov\nventz@vpetkov.net\n\n\nPLEASE NOTE\n-----------\n* This is still a BETA - it works well, but it is FAR from complete.\n* To use this \"as is\", it requires an r10k for git based environments: (https://github.com/acidprime/r10k)\n* You can change one line and make it to work with just git or any other framework or custom written deploy/sync script.\n\n\nShort Summary\n-------------\nPGSVR lets you configure a post-receive hook with your git\nserver/github/any other system, that signals over REST so that an r10k\nrun can happen.\n\nIt's a simply a fancy way to have a \"git push\" become \"instant files\" on your\npuppet server.\n\nWhen you have r10k (highly recommended), you also get dynamic environments\nfor free - so that each git branch becomes a puppet environment. You\nalso get the other features that r10k provides, like deploying modules\nfrom github/puppet forge by just specifying a line in Puppetfile.\n\nDon't have r10k? Not sure what it is, don't have time, or don't want to bother with it? No problem! By changing one line, you can have your \"git push\" simply end up mirroring a repo (syncing it) and then cloning it out into your puppet directory.\n\nThe goal of this is to provide you with a framework to translate a\nREST call to a \"something\" on your puppet server.\n\n\nQuick Setup and PGSVR Components\n--------------------------------\nThis is rather simple. Don't let the length of this readme scare you!\n\n* You need r10k - \"dynamic puppet environments\" tied into Git.\n\nThis can be obtained with one command:\n\n    puppet module install zack/r10k\n\n* You need to deploy for your dynamic environments.\n\nCreate a \"deploy_r10k\" module with an init.pp which contains:\n\n    class { 'r10k':\n        remote =\u003e 'git@github.com:someuser/puppet.git',\n    }\n\nAnd apply your module:\n\n    puppet apply deploy_r10k/manifests/init.pp\n\nPlease make sure that you DO NOT add the \"include r10k::prerun_command\" bit.\nThe whole point of PGSVR is to do this intelligently and only as needed.\n\n* Set a shell for your puppet user.\n\nThis is needed so that we can execute a \"sudo\" call for an r10k run:\n\n    chsh -s /bin/bash puppet\n\n* Edit your sudo-ers file (visudo)\n\nFor Ubuntu:\n\n    Defaults env_keep = \"http_proxy https_proxy\"\n    www-data    ALL= NOPASSWD: * /usr/local/bin/r10k\n\nFor RHEL/Centos:\n\n    Defaults env_keep = \"http_proxy https_proxy\"\n    apache2    ALL= NOPASSWD: * /usr/local/bin/r10k\n\n* You need 2 perl modules (Dancer and Plack)\n* An Apache server with a virtual config (I provide the site config - look through it)\n* A cgi-root (I create it under /var/www/pgsvr with the apache config) to drop the app itself. Make sure it's owned by your web user.\n* Create some \"tokens\" and configure the proxy variables. A token is a\nunique string basically.\n\n* That's it! Now skip down to the \"How to Test it\" section.\n\n\nTo get it working (detailed version), you need to:\n--------------------------------------------------\n* Have a \"dynamic git puppet environment\"\nYou commit to git, and it picks up the branch and then creates the\nappropriate puppet environment\n\nSomething like this in /etc/puppet/puppet.conf on the master:\n\n    environment = master\n    manifest    = $confdir/environments/$environment/manifests/site.pp\n    modulepath  = $confdir/modules:$confdir/environments/$environment/modules:$confdir/environments/$environment/dist:$confdir/environments/$environment/site\n\nThis can be obtained with one command:\n\n    puppet module install zack/r10k\n\n* You need to deploy for your dynamic environments.\n\nCreate a \"deploy_r10k\" module with an init.pp which contains:\n\n    class { 'r10k':\n        remote =\u003e 'git@github.com:someuser/puppet.git',\n    }\n\nAnd apply your module:\n\n    puppet apply deploy_r10k/manifests/init.pp\n\nPlease make sure that you DO NOT add the \"include r10k::prerun_command\" bit.\nThe whole point of PGSVR is to do this intelligently and only as needed.\n\n* Set a shell for your puppet user.\n\nUse bash for example:\n\n    chsh -s /bin/bash puppet\n\n* Edit your sudo-ers file (visudo)\n\nFor Ubuntu:\n\n    Defaults env_keep = \"http_proxy https_proxy\"\n    www-data    ALL= NOPASSWD: * /usr/local/bin/r10k\n\nFor RHEL/Centos:\n\n    Defaults env_keep = \"http_proxy https_proxy\"\n    apache2    ALL= NOPASSWD: * /usr/local/bin/r10k\n\n* /etc/puppet/environments need to be owned by 'puppet' and group by apache (www-data on ubuntu)\n\n* Take the 'pgsvr' repo and grab the 'pgsvr' apache config, and\nenable it as a virtual host.\n\n* Take 'pgsvr' folder (inside the 'app' folder) and drop it in /var/www, and make sure everything is owned by your web user.\n\n* You will need to install 2 Perl modules:\n    * Dancer (ubuntu: libdancer-perl) -\u003e REST framework in Perl\n    * Plack (ubuntu: libplack-perl) -\u003e Interface for Perl webapp to interface with Apache/other web servers\n\n* Go into the /var/www/pgsvr/bin/app.pl and create yourself an 'user\nand token' (see line about MD5 part). In reality, ANYTHING can be used\nas a token. It's just used for a super rudimentary way of\n\"authenticating\".\n\n* If you use a proxy, please enter it in the apache virtual config file. The variables are passed through sudo to the app.\n\n\nHow to Test it:\n---------------\n* Make sure /etc/puppet/environments is empty\n* You can 'curl' call your rest service: curl -i -H \"Accept:\napplication/xml\" http://puppet.domain.tld/sync/$user/$token\n\nWhere $user is the 'user' you created\n\n* Now check if /etc/puppet/environments filled up -- that is, assuming you have checked in a git repo ;)\n\n\nBackground - What is this/How did it come about?\n------------------------------------------------\nIf you are using puppet with git (github or your own server/repo), you\nhave realized really quickly that there are two 'hacky' ways to do it:\nkeep the git server/repo on the puppet server or glue some magic in\nvia SSH from the git server to the puppet server\n\n####Partial Solution:\nUse r10k. You push your code to your git server, and the\nr10k module on on your puppet master grabs it every X minutes (20 by\ndefault, but you can configure cron down to 1).\n\nStill, that's NOT good enough! Can you imagine having to tell people\nto wait a whole minute!\n\n####Solution: PGSVR\nYou set it up on your puppet server, and you configure github (or any\ngit server) to have a post-receive hook that simply signals your\npuppet server. This will initialize a r10k run (or anything else). Simple huh? Yep - simple but effective.\n\n\n\nTODO:\n-----\n* Create a rest call to read a file of users/tokens\n* Create a config file for the http(s)-proxy variables\n* Create real authentication, and add to config\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fventz%2Fpgsvr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fventz%2Fpgsvr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fventz%2Fpgsvr/lists"}