https://github.com/ema/pets Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code + Explore + All features + Documentation + GitHub Skills + Blog * Solutions + By Plan + Enterprise + Teams + Compare all + By Solution + CI/CD & Automation + DevOps + DevSecOps + Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles + Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} ema / pets Public * Notifications * Fork 0 * Star 47 A configuration management system for Pets, not Cattle License MIT license 47 stars 0 forks Star Notifications * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights ema/pets This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 1 branch 0 tags Code * Clone HTTPS GitHub CLI [https://github.com/e] Use Git or checkout with SVN using the web URL. [gh repo clone ema/pe] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @ema ema README: mention APT/YUM support ... f4d0664 Oct 31, 2022 README: mention APT/YUM support f4d0664 Git stats * 82 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .github/workflows sample_pet LICENSE Makefile README.adoc design.png file.go file_test.go go.mod go.sum main.go main_test.go manpage.adoc package.go package_test.go parser.go planner.go planner_test.go util.go validator.go View code PETS Example Design overview Configuration directives README.adoc PETS badge A Configuration Management System for computers that are Pets, not Cattle. This is for people who need to administer a handful of machines, all fairly different from each other and all Very Important. Those systems are not Cattle! They're actually a bit more than Pets. They're almost Family. For example: a laptop, workstation, and that personal tiny server in Sweden. They are all named after something dear. pets works on Linux systems, both Debian-like (APT) and RedHat-like (YUM). Example One example is worth a thousand words! Give user "ema" sudo rights with pets. Create a file with the following contents under $HOME/pets /, run pets as root, done. The file can be called whatever you want. Note that pets will install the sudo package for you if missing. # pets: destfile=/etc/sudoers.d/ema, owner=root, group=root, mode=0440 # pets: package=sudo # pets: pre=/usr/sbin/visudo -cf ema ALL=(ALL:ALL) NOPASSWD:ALL Design overview The idea behind Pets is that Configuration Management of individual hosts shouldn't be harder than administering the system by hand. Other configuration management tools typically focus on usage scenarios involving complex relationships between multiple, fairly homogeneous systems: for example, setting up a bunch of application servers behind a load-balancer, or configuring a database and its replicas. For that you need a templating language, some way to store and share information about the various systems, and a way to either push the changes to all hosts or pull them from a central location. All that complexity can discourage from using a configuration management tool to begin with: why bother with Chef syntax and ERB templates if you just need to edit a few files? Pets instead focuses on the individual, local machine. No need to ssh anywhere, no puppetmaster to configure, nada. It works by reading your regular, static configuration files (say muttrc) with added pets modelines, inspired by the concept of vim modelines. Pets can copy your configuration files to the right place, fix permissions, install packages, and run commands upon file update. Following from this basic idea, here are the design decisions: * Runs locally on a single machine * One directory holds the full configuration of the system * No variables, no templates, just plain static config files * No dependencies between different components (eg: updating file A if and after file B was updated) * A single one-shot program reading the configuration directory and applying changes * Changes are applied only if basic syntax checks pass * Main interaction mechanism inspired by vim modelines Here's the initial design document in all its beauty. Ignore the "watcher" part, that was before I settled on a one-shot approach. design Configuration directives Here's an example of custom sshd_config: # pets: destfile=/etc/ssh/sshd_config, owner=root, group=root, mode=0644 # pets: package=ssh # pets: package=openssh-client-dbgsym # pets: pre=/usr/sbin/sshd -t -f # pets: post=/bin/systemctl reload ssh.service # # Warning! This file has been generated by pets(1). Any manual modification # will be lost. Port 22 Protocol 2 HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_dsa_key HostKey /etc/ssh/ssh_host_ecdsa_key HostKey /etc/ssh/ssh_host_ed25519_key # Change to yes to enable challenge-response passwords (beware issues with # some PAM modules and threads) ChallengeResponseAuthentication no # Change to no to disable tunnelled clear text passwords PasswordAuthentication no X11Forwarding yes # Allow client to pass locale environment variables AcceptEnv LANG LC_* Subsystem sftp /usr/lib/openssh/sftp-server UsePAM yes That's it! All supported configuration directives are showcased in the example above: * destfile (mandatory) -- where to install this file. This is the only mandatory directive. * owner -- the file owner, passed to chown(1) * group -- the group this file belongs to, passed to chgrp(1) * mode -- octal mode for chmod(1) * package -- which package to install before creating the file. This directive can be specificed more than once to install multiple packages. * pre -- validation command. This must succeed for the file to be created / updated. * post -- apply command. Usually something like reloading a service. Configuration directives are passed as key/value arguments, either on multiple lines or separated by commas. # pets: package=ssh, pre=/usr/sbin/sshd -t -f The example above and the one below are equivalent # pets: package=ssh # pets: pre=/usr/sbin/sshd -t -f About A configuration management system for Pets, not Cattle Resources Readme License MIT license Stars 47 stars Watchers 1 watching Forks 0 forks Releases No releases published Packages 0 No packages published Languages * Go 99.3% * Makefile 0.7% Footer (c) 2022 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.