{"id":16243578,"url":"https://github.com/flyte/confp","last_synced_at":"2025-03-19T17:32:27.071Z","repository":{"id":28947351,"uuid":"119714103","full_name":"flyte/confp","owner":"flyte","description":"Builds configuration files using Jinja2 template with data pulled from Redis, etcd, Terraform or environment variables.","archived":false,"fork":false,"pushed_at":"2022-01-21T19:03:37.000Z","size":87,"stargazers_count":11,"open_issues_count":3,"forks_count":3,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-02-28T20:24:42.038Z","etag":null,"topics":["backend","configuration","configuration-management","devops","docker","environment","environment-variables","environment-vars","etcd","jinja2","jinja2-templates","python","redis"],"latest_commit_sha":null,"homepage":"","language":"Python","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/flyte.png","metadata":{"files":{"readme":"README.md","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}},"created_at":"2018-01-31T16:38:07.000Z","updated_at":"2023-02-03T14:55:52.000Z","dependencies_parsed_at":"2022-08-07T14:01:00.060Z","dependency_job_id":null,"html_url":"https://github.com/flyte/confp","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyte%2Fconfp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyte%2Fconfp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyte%2Fconfp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyte%2Fconfp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flyte","download_url":"https://codeload.github.com/flyte/confp/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244010927,"owners_count":20383333,"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":["backend","configuration","configuration-management","devops","docker","environment","environment-variables","environment-vars","etcd","jinja2","jinja2-templates","python","redis"],"created_at":"2024-10-10T14:15:27.896Z","updated_at":"2025-03-19T17:32:26.801Z","avatar_url":"https://github.com/flyte.png","language":"Python","readme":"confp\n=====\n\nA configuration management tool, similar to [confd](https://github.com/kelseyhightower/confd) using Python and the Jinja2 templating language.\n\nConfiguration files are created as Jinja2 templates, pulling values from one or more backends, and can be run continuously as a daemon or as a single-execution application.\n\nCurrently confp supports pulling data from the following backends:\n\n- Environment variables\n- Redis\n- etcd\n- Terraform state on S3\n\nInstallation\n------------\n\n```bash\npip install confp\n```\n\nConfiguration\n-------------\n\nConfiguration of confp is done in one YAML file. The file contains a `backends` section which\nhandles the retrieval of configuration values used in templates from the backend(s), and a\n`templates` section which specifies how and where to deploy templates.\n\nIt's also possible to use this file for the Python logging configuration. Refer to the `logging`\nsection in `config.example.yml` for an example of this.\n\n#### `backends` section\n\nEach of the keys in the `backends` dictionary is your name for a backend. They must contain\na `type` key, plus whichever configuration keys the specific backend requires. For example, the\n`redis` backend optionally takes `host` and `port` keys (among others).\n\nAnother example is the `env` backend which pulls values from environment variables. It optionally\ntakes a `prefix` key which all of the values will have at the beginning.\n\nHere's an example using both:\n\n```yaml\nbackends:\n  my_redis:\n    type: redis\n    host: redis.example.com\n    port: 6379\n  my_env:\n    type: env\n    prefix: MY_SERVICE_  # Will be removed when specifying keys in templates\n```\n\n#### `templates` section\n\nThe `templates` list specifies one or more templates to render. Each of the dictionaries must\ncontain values for the `src` and `dest` keys. You may optionally specify the following:\n\n- `owner` - The owner of the rendered template (only when running as root).\n- `mode` - The file mode of the rendered template.\n- `check_cmd` - The command to run in order to check that the rendered template is valid. Exit\ncode 0 means OK, \u003e0 means it's invalid and we'll roll back to the existing version of the template.\n- `restart_cmd` - The command to run which will either restart the daemon, or tell it to reload its\nconfig.\n\nYou may also include a `vars` key, which contains a dictionary where keys are the names for global\nvalues within templates and the value dict contains `backend` and `key` to specify where its value\ncomes from:\n\n```yaml\ntemplates:\n  - src: /templates/nginx-mysite.conf.j2\n    dest: /etc/nginx/sites-available/mysite.conf\n    owner: nginx\n    mode: '0664'\n    check_cmd: /usr/sbin/nginx -t -c {{ dest }}\n    restart_cmd: /usr/sbin/service nginx reload\n    vars:\n      FQDN:\n        backend: my_redis  # The name we gave to our redis backend\n        key: server/fqdn\n      WWW_ROOT:\n        backend: my_env\n        key: WWW_ROOT  # Pulls the value from env var MY_SERVICE_WWW_ROOT (see prefix above)\n        default: /var/www  # Fallback in case MY_SERVICE_WWW_ROOT env var isn't set\n```\n\nTemplates\n---------\n\nThese are standard [Jinja2 templates](http://jinja.pocoo.org/docs/latest/templates/) which define\nyour config files and where to pull the variables from. You may pull values from one or more\nbackends within the template, or leave the source of the values up to the configuration (see the\ntemplate `vars` section above).\n\nIn order to pull values from a specific backend, use the syntax `{{ my_redis('server/fqdn') }}`\nwhere `my_redis` is the name you gave your backend and the `server/fqdn` value is the key.\n\nSome backends such as `env` create a global variable called `\u003cbackend name\u003e__all` containing a `dict` of all matching variables. In the case of the `my_env` backend name the global would be called `my_env__all`. This is useful in order to iterate through all vars in a template.\n\nTo use values which have been set globally with the above `vars` configuration, simply use the\nname you assigned such as `{{ FQDN }}`.\n\nHere's an example using both methods:\n\n```jinja\nupstream backend {\n    server {{ my_redis('backend/server/host') }}:{{ my_redis('backend/server/port') }};\n}\nserver {\n    listen 80;\n    {#\n        The second argument to the functions optionally sets a default value\n        in case the key doesn't exist on the backend. Omitting the default will\n        cause a missing key to raise an exception.\n    #}\n    server_name {{ my_env('FQDN', 'www.example.com') }};\n    return 301 https://$server_name$request_uri;\n}\nserver {\n    listen 443 ssl;\n    server_name {{ my_redis('server/fqdn', 'www.example.com') }};\n\n    ssl_certificate /etc/letsencrypt/live/{{ FQDN }}/fullchain.pem;\n    ssl_certificate_key /etc/letsencrypt/live/{{ FQDN }}/privkey.pem;\n\n    root {{ WWW_ROOT }};\n\n    location / {\n        proxy_pass http://backend/;\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n        proxy_set_header X-Scheme $scheme;\n        proxy_set_header X-Forwarded-Proto $scheme;\n    }\n}\n```\n\nAll Jinja2 features such as conditionals and loops are supported.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflyte%2Fconfp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflyte%2Fconfp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflyte%2Fconfp/lists"}