{"id":20111750,"url":"https://github.com/openstack/os-apply-config","last_synced_at":"2025-04-07T10:22:34.485Z","repository":{"id":10120168,"uuid":"12188909","full_name":"openstack/os-apply-config","owner":"openstack","description":"Apply configuration from cloud metadata. Mirror of code maintained at opendev.org.","archived":false,"fork":false,"pushed_at":"2024-10-19T15:39:47.000Z","size":357,"stargazers_count":51,"open_issues_count":0,"forks_count":18,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-31T08:09:29.421Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://opendev.org/openstack/os-apply-config","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openstack.png","metadata":{"files":{"readme":"README.rst","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,"publiccode":null,"codemeta":null}},"created_at":"2013-08-18T02:03:41.000Z","updated_at":"2024-10-19T15:39:51.000Z","dependencies_parsed_at":"2024-01-17T05:00:13.470Z","dependency_job_id":"5e63fe92-7ca8-474b-a7ff-a81044a98e3d","html_url":"https://github.com/openstack/os-apply-config","commit_stats":{"total_commits":227,"total_committers":56,"mean_commits":4.053571428571429,"dds":0.801762114537445,"last_synced_commit":"53eef8b5c2a366d6640e800889c1b79b6be835a6"},"previous_names":[],"tags_count":104,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openstack%2Fos-apply-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openstack%2Fos-apply-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openstack%2Fos-apply-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openstack%2Fos-apply-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openstack","download_url":"https://codeload.github.com/openstack/os-apply-config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247631990,"owners_count":20970093,"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-11-13T18:17:35.854Z","updated_at":"2025-04-07T10:22:34.462Z","avatar_url":"https://github.com/openstack.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"========================\nTeam and repository tags\n========================\n\n.. image:: https://governance.openstack.org/tc/badges/os-apply-config.svg\n    :target: https://governance.openstack.org/tc/reference/tags/index.html\n\n.. Change things from this point on\n\n===============\nos-apply-config\n===============\n\n----------------------------------------------\nApply configuration from cloud metadata (JSON)\n----------------------------------------------\n\nWhat does it do?\n================\n\nIt turns metadata from one or more JSON files like this::\n\n    {\"keystone\": {\"database\": {\"host\": \"127.0.0.1\", \"user\": \"keystone\", \"password\": \"foobar\"}}}\n\ninto service config files like this::\n\n    [sql]\n    connection = mysql://keystone:foobar@127.0.0.1/keystone\n    ...other settings...\n\nUsage\n=====\n\nJust pass it the path to a directory tree of templates::\n\n    sudo os-apply-config -t /home/me/my_templates\n\nBy default it will read config files according to the contents of\nthe file `/var/lib/os-collect-config/os_config_files.json`. In\norder to remain backward compatible it will also fall back to\n/var/run/os-collect-config/os_config_files.json, but the fallback\npath is deprecated and will be removed in a later release. The main\npath can be changed with the command line switch `--os-config-files`,\nor the environment variable `OS_CONFIG_FILES_PATH`. The list can\nalso be overridden with the environment variable `OS_CONFIG_FILES`.\nIf overriding with `OS_CONFIG_FILES`, the paths are expected to be colon,\n\":\", separated. Each json file referred to must have a mapping as their\nroot structure. Keys in files mentioned later in the list will override\nkeys in earlier files from this list. For example::\n\n    OS_CONFIG_FILES=/tmp/ec2.json:/tmp/cfn.json os-apply-config\n\nThis will read `ec2.json` and `cfn.json`, and if they have any\noverlapping keys, the value from `cfn.json` will be used. That will\npopulate the tree for any templates found in the template path. See\nhttps://opendev.org/openstack/os-collect-config for a\nprogram that will automatically collect data and populate this list.\n\nYou can also override `OS_CONFIG_FILES` with the `--metadata` command\nline option, specifying it multiple times instead of colon separating\nthe list.\n\n`os-apply-config` will also always try to read metadata in the old\nlegacy paths first to populate the tree. These paths can be changed\nwith `--fallback-metadata`.\n\nTemplates\n=========\n\nThe template directory structure should mimic a root filesystem, and\ncontain templates for only those files you want configured. For\nexample::\n\n   ~/my_templates$ tree\n   .\n   +-- etc\n       +-- keystone\n       |    +-- keystone.conf\n       +-- mysql\n             +-- mysql.conf\n\nAn example tree can be found `here \u003chttps://opendev.org/openstack/tripleo-image-elements/src/branch/master/elements/os-apply-config\u003e`_.\n\nIf a template is executable it will be treated as an *executable\ntemplate*.  Otherwise, it will be treated as a *mustache template*.\n\nMustache Templates\n------------------\n\nIf you don't need any logic, just some string substitution, use a\nmustache template.\n\nMetadata settings are accessed with dot ('.') notation::\n\n  [sql]\n  connection = mysql://{{keystone.database.user}}:{{keystone.database.password}}@{{keystone.database.host}}/keystone\n\nExecutable Templates\n--------------------\n\nConfiguration requiring logic is expressed in executable templates.\n\nAn executable template is a script which accepts configuration as a\nJSON string on standard in, and writes a config file to standard out.\n\nThe script should exit non-zero if it encounters a problem, so that\nos-apply-config knows what's up.\n\nThe output of the script will be written to the path corresponding to\nthe executable template's path in the template tree::\n\n  #!/usr/bin/env ruby\n  require 'json'\n  params = JSON.parse STDIN.read\n  puts \"connection = mysql://#{c['keystone']['database']['user']}:#{c['keystone']['database']['password']}@#{c['keystone']['database']['host']}/keystone\"\n\nYou could even embed mustache in a heredoc, and use that::\n\n  #!/usr/bin/env ruby\n  require 'json'\n  require 'mustache'\n  params = JSON.parse STDIN.read\n\n  template = \u003c\u003c-eos\n  [sql]\n  connection = mysql://{{keystone.database.user}}:{{keystone.database.password}}@{{keystone.database.host}}/keystone\n\n  [log]\n  ...\n  eos\n\n  # tweak params here...\n\n  puts Mustache.render(template, params)\n\n\nQuick Start\n===========\n::\n\n   # install it\n   sudo pip install -U git+https://opendev.org/openstack/os-apply-config.git\n\n   # grab example templates\n   git clone https://opendev.org/openstack/tripleo-image-elements /tmp/config\n\n   # run it\n   os-apply-config -t /tmp/config/elements/nova/os-apply-config/ -m /tmp/config/elements/seed-stack-config/config.json -o /tmp/config_output\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenstack%2Fos-apply-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenstack%2Fos-apply-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenstack%2Fos-apply-config/lists"}