{"id":13621176,"url":"https://github.com/ema/pets","last_synced_at":"2026-01-16T11:35:09.773Z","repository":{"id":62386287,"uuid":"555256294","full_name":"ema/pets","owner":"ema","description":"A configuration management system for Pets, not Cattle","archived":false,"fork":false,"pushed_at":"2023-06-03T11:49:42.000Z","size":742,"stargazers_count":462,"open_issues_count":4,"forks_count":7,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-15T01:38:40.565Z","etag":null,"topics":["configuration","linux"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ema.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-10-21T08:22:10.000Z","updated_at":"2025-01-25T20:59:24.000Z","dependencies_parsed_at":"2024-02-24T09:45:42.517Z","dependency_job_id":null,"html_url":"https://github.com/ema/pets","commit_stats":{"total_commits":131,"total_committers":3,"mean_commits":"43.666666666666664","dds":"0.17557251908396942","last_synced_commit":"7db9c24ee88fc1a02bcaf7a4534f391fe72eb352"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ema/pets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ema%2Fpets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ema%2Fpets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ema%2Fpets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ema%2Fpets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ema","download_url":"https://codeload.github.com/ema/pets/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ema%2Fpets/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478349,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["configuration","linux"],"created_at":"2024-08-01T21:01:03.290Z","updated_at":"2026-01-16T11:35:09.741Z","avatar_url":"https://github.com/ema.png","language":"Go","readme":"= PETS\n\nimage:https://github.com/ema/pets/actions/workflows/go.yml/badge.svg[link=\"https://github.com/ema/pets/actions/workflows/go.yml\"]\n\nA Configuration Management System for computers that are Pets, not Cattle.\n\nThis is for people who need to administer a handful of machines, all fairly\ndifferent from each other and all Very Important. Those systems are not Cattle!\nThey're actually a bit more than Pets. They're almost Family. For example: a\nlaptop, workstation, and that personal tiny server in Sweden. They are all\nnamed after something dear.\n\npets works on Linux systems. The following distro families are supported:\n\n- Debian-like (APT)\n- RedHat-like (YUM)\n- Alpine (APK)\n- Arch Linux (Pacman, yay)\n\n== Summary\n\nPets is the first configuration management system driven by comments embedded\nin the config files themselves, rather than by a domain-specific language\n(DSL). For example, say you want to ensure that user \"ema\" has sudo rights.\nCreate a file with the following contents under `$HOME/pets/`, run `pets` as\nroot, done. The file can be called whatever you want. Note that pets will\ninstall the `sudo` package for you if missing.\n\n----\n# pets: destfile=/etc/sudoers.d/ema, owner=root, group=root, mode=0440\n# pets: package=sudo\n# pets: pre=/usr/sbin/visudo -cf\n\nema ALL=(ALL:ALL) NOPASSWD:ALL\n----\n\n== Usage\n\nBuild and install pets with:\n\n----\n$ go install github.com/ema/pets@latest\n----\n\nThe following options are supported:\n\n----\n$ pets -h\nUsage of ./pets:\n  -conf-dir string\n        Pets configuration directory (default \"/home/ema/pets\")\n  -debug\n        Show debugging output\n  -dry-run\n        Only show changes without applying them\n----\n\nLet's say you've decided to put your configuration files under `/etc/pets`. The\nsystem can then be used with:\n\n----\n# pets -conf-dir /etc/pets\n----\n\nSee https://github.com/ema/pets/tree/master/sample_pet[sample_pet] for a basic\nexample of what your `/etc/pets` can look like. Note that directory structure\nis arbitrary, you can have as many directories as you want, call them what you\nwant, and so on.\n\n== Design overview\n\nThe idea behind Pets is that Configuration Management of individual hosts\nshouldn't be harder than administering the system by hand. Other configuration\nmanagement tools typically focus on usage scenarios involving complex\nrelationships between multiple, fairly homogeneous systems: for example,\nsetting up a bunch of application servers behind a load-balancer, or\nconfiguring a database and its replicas. For that you need a templating\nlanguage, some way to store and share information about the various systems,\nand a way to either push the changes to all hosts or pull them from a central\nlocation. All that complexity can discourage from using a configuration\nmanagement tool to begin with: why bother with Chef syntax and ERB templates if\nyou just need to edit a few files?\n\nPets instead focuses on the individual, local machine. No need to ssh anywhere,\nno puppetmaster to configure, nada. It works by reading your regular, static\nconfiguration files (say muttrc) with added pets modelines, inspired by the\nconcept of vim modelines. Pets can copy your configuration files to the right\nplace, fix permissions, install packages, and run commands upon file update.\n\nFollowing from this basic idea, here are the design decisions:\n\n- Runs locally on a single machine\n- One directory holds the full configuration of the system\n- No variables, no templates, just plain static config files\n- No dependencies between different components (eg: updating file A if and\n  after file B was updated)\n- A single one-shot program reading the configuration directory and applying\n  changes\n- Changes are applied only if basic syntax checks pass\n- Main interaction mechanism inspired by vim modelines\n\nHere's the initial design document in all its beauty. Ignore the \"watcher\"\npart, that was before I settled on a one-shot approach.\n\nimage::design.png[]\n\n== Configuration directives\n\n- destfile -- where to install this file. One of either *destfile* or *symlink* must be specified.\n- symlink -- create a symbolic link to this file, instead of copying it like *destfile* would.\n- owner -- the file owner, passed to chown(1)\n- group -- the group this file belongs to, passed to chgrp(1)\n- mode -- octal mode for chmod(1)\n- package -- which package to install before creating the file. This\n  directive can be specificed more than once to install multiple packages.\n- pre -- validation command. This must succeed for the file to be\n  created / updated.\n- post -- apply command. Usually something like reloading a service.\n\nConfiguration directives are passed as key/value arguments, either on multiple\nlines or separated by commas.\n\n----\n# pets: package=ssh, pre=/usr/sbin/sshd -t -f\n----\n\nThe example above and the one below are equivalent\n\n----\n# pets: package=ssh\n# pets: pre=/usr/sbin/sshd -t -f\n----\n\n== Examples\n\n=== Firewall\n\nSay you want to configure the local firewall to drop all incoming traffic\nexcept for ssh? Here's an example that does the following:\n\n- Installs `ferm` if missing\n- Validates the configuration with `/usr/sbin/ferm -n`\n- If the configuration is valid, copies it under `/etc/ferm/ferm.conf`\n- Reloads the firewall rules with `systemctl reload`\n\n----\n# pets: destfile=/etc/ferm/ferm.conf, owner=root, group=root, mode=644\n# pets: package=ferm\n# pets: pre=/usr/sbin/ferm -n\n# pets: post=/bin/systemctl reload ferm.service\n\ndomain (ip ip6) {\n    table filter {\n        chain INPUT {\n            policy DROP;\n\n            # connection tracking\n            mod state state INVALID DROP;\n            mod state state (ESTABLISHED RELATED) ACCEPT;\n\n            # allow local packets\n            interface lo ACCEPT;\n\n            # respond to ping\n            proto icmp ACCEPT;\n\n            # allow SSH connections\n            proto tcp dport ssh ACCEPT;\n        }\n\n        chain OUTPUT {\n            policy ACCEPT;\n        }\n\n        chain FORWARD {\n            policy DROP;\n        }\n    }\n}\n----\n\n=== SSH Server\n\n----\n# pets: destfile=/etc/ssh/sshd_config, owner=root, group=root, mode=0644\n# pets: package=ssh\n# pets: package=openssh-client-dbgsym\n# pets: pre=/usr/sbin/sshd -t -f\n# pets: post=/bin/systemctl reload ssh.service\n#\n# Warning! This file has been generated by pets(1). Any manual modification\n# will be lost.\n\nPort 22\nProtocol 2\nHostKey /etc/ssh/ssh_host_rsa_key\nHostKey /etc/ssh/ssh_host_dsa_key\nHostKey /etc/ssh/ssh_host_ecdsa_key\nHostKey /etc/ssh/ssh_host_ed25519_key\n\n# Change to yes to enable challenge-response passwords (beware issues with\n# some PAM modules and threads)\nChallengeResponseAuthentication no\n\n# Change to no to disable tunnelled clear text passwords\nPasswordAuthentication no\n\nX11Forwarding yes\n\n# Allow client to pass locale environment variables\nAcceptEnv LANG LC_*\n\nSubsystem sftp /usr/lib/openssh/sftp-server\n\nUsePAM yes\n----\n\n== Reception\nPets was featured https://news.ycombinator.com/item?id=33414338[on Hacker News]\nand https://lobste.rs/s/jc2oru/configuration_management_system_for[on\nLobsters].\n\nThe author of Chef started\nhttps://twitter.com/adamhjk/status/1587169750249271296[an interesting Twitter\nthread] about Pets too.\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fema%2Fpets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fema%2Fpets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fema%2Fpets/lists"}