os-apply-config


Nameos-apply-config JSON
Version 14.0.0 PyPI version JSON
download
home_pagehttps://opendev.org/openstack/os-apply-config
SummaryConfig files from cloud metadata
upload_time2024-04-19 09:18:54
maintainerNone
docs_urlNone
authorOpenStack
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ========================
Team and repository tags
========================

.. image:: https://governance.openstack.org/tc/badges/os-apply-config.svg
    :target: https://governance.openstack.org/tc/reference/tags/index.html

.. Change things from this point on

===============
os-apply-config
===============

----------------------------------------------
Apply configuration from cloud metadata (JSON)
----------------------------------------------

What does it do?
================

It turns metadata from one or more JSON files like this::

    {"keystone": {"database": {"host": "127.0.0.1", "user": "keystone", "password": "foobar"}}}

into service config files like this::

    [sql]
    connection = mysql://keystone:foobar@127.0.0.1/keystone
    ...other settings...

Usage
=====

Just pass it the path to a directory tree of templates::

    sudo os-apply-config -t /home/me/my_templates

By default it will read config files according to the contents of
the file `/var/lib/os-collect-config/os_config_files.json`. In
order to remain backward compatible it will also fall back to
/var/run/os-collect-config/os_config_files.json, but the fallback
path is deprecated and will be removed in a later release. The main
path can be changed with the command line switch `--os-config-files`,
or the environment variable `OS_CONFIG_FILES_PATH`. The list can
also be overridden with the environment variable `OS_CONFIG_FILES`.
If overriding with `OS_CONFIG_FILES`, the paths are expected to be colon,
":", separated. Each json file referred to must have a mapping as their
root structure. Keys in files mentioned later in the list will override
keys in earlier files from this list. For example::

    OS_CONFIG_FILES=/tmp/ec2.json:/tmp/cfn.json os-apply-config

This will read `ec2.json` and `cfn.json`, and if they have any
overlapping keys, the value from `cfn.json` will be used. That will
populate the tree for any templates found in the template path. See
https://opendev.org/openstack/os-collect-config for a
program that will automatically collect data and populate this list.

You can also override `OS_CONFIG_FILES` with the `--metadata` command
line option, specifying it multiple times instead of colon separating
the list.

`os-apply-config` will also always try to read metadata in the old
legacy paths first to populate the tree. These paths can be changed
with `--fallback-metadata`.

Templates
=========

The template directory structure should mimic a root filesystem, and
contain templates for only those files you want configured. For
example::

   ~/my_templates$ tree
   .
   +-- etc
       +-- keystone
       |    +-- keystone.conf
       +-- mysql
             +-- mysql.conf

An example tree can be found `here <https://opendev.org/openstack/tripleo-image-elements/src/branch/master/elements/os-apply-config>`_.

If a template is executable it will be treated as an *executable
template*.  Otherwise, it will be treated as a *mustache template*.

Mustache Templates
------------------

If you don't need any logic, just some string substitution, use a
mustache template.

Metadata settings are accessed with dot ('.') notation::

  [sql]
  connection = mysql://{{keystone.database.user}}:{{keystone.database.password}}@{{keystone.database.host}}/keystone

Executable Templates
--------------------

Configuration requiring logic is expressed in executable templates.

An executable template is a script which accepts configuration as a
JSON string on standard in, and writes a config file to standard out.

The script should exit non-zero if it encounters a problem, so that
os-apply-config knows what's up.

The output of the script will be written to the path corresponding to
the executable template's path in the template tree::

  #!/usr/bin/env ruby
  require 'json'
  params = JSON.parse STDIN.read
  puts "connection = mysql://#{c['keystone']['database']['user']}:#{c['keystone']['database']['password']}@#{c['keystone']['database']['host']}/keystone"

You could even embed mustache in a heredoc, and use that::

  #!/usr/bin/env ruby
  require 'json'
  require 'mustache'
  params = JSON.parse STDIN.read

  template = <<-eos
  [sql]
  connection = mysql://{{keystone.database.user}}:{{keystone.database.password}}@{{keystone.database.host}}/keystone

  [log]
  ...
  eos

  # tweak params here...

  puts Mustache.render(template, params)


Quick Start
===========
::

   # install it
   sudo pip install -U git+https://opendev.org/openstack/os-apply-config.git

   # grab example templates
   git clone https://opendev.org/openstack/tripleo-image-elements /tmp/config

   # run it
   os-apply-config -t /tmp/config/elements/nova/os-apply-config/ -m /tmp/config/elements/seed-stack-config/config.json -o /tmp/config_output




            

Raw data

            {
    "_id": null,
    "home_page": "https://opendev.org/openstack/os-apply-config",
    "name": "os-apply-config",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "OpenStack",
    "author_email": "openstack-discuss@lists.openstack.org",
    "download_url": "https://files.pythonhosted.org/packages/6c/d6/a324904b9f1549290241c4349828893534ad1745cd35f04a39ebd52a2cc3/os-apply-config-14.0.0.tar.gz",
    "platform": null,
    "description": "========================\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 <https://opendev.org/openstack/tripleo-image-elements/src/branch/master/elements/os-apply-config>`_.\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 = <<-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\n\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Config files from cloud metadata",
    "version": "14.0.0",
    "project_urls": {
        "Homepage": "https://opendev.org/openstack/os-apply-config"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5687ca051a2f5505b1fe693e9c6cc5e546d6e11f3c697d0a5a1222689c4d8ec1",
                "md5": "a8f9fac99090005d5c22907e777bf734",
                "sha256": "0c4541dad0930f553cc577d16523c277ffd2b42aa9e08f649b2c193e05779bbf"
            },
            "downloads": -1,
            "filename": "os_apply_config-14.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a8f9fac99090005d5c22907e777bf734",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 32029,
            "upload_time": "2024-04-19T09:18:48",
            "upload_time_iso_8601": "2024-04-19T09:18:48.075732Z",
            "url": "https://files.pythonhosted.org/packages/56/87/ca051a2f5505b1fe693e9c6cc5e546d6e11f3c697d0a5a1222689c4d8ec1/os_apply_config-14.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6cd6a324904b9f1549290241c4349828893534ad1745cd35f04a39ebd52a2cc3",
                "md5": "784adda8c69cf85d6d539480ecde4bc0",
                "sha256": "8c44ef209268bc8ec2f45e34e734f8bb381decd517b6221f2714c22a00eda99d"
            },
            "downloads": -1,
            "filename": "os-apply-config-14.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "784adda8c69cf85d6d539480ecde4bc0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 28236,
            "upload_time": "2024-04-19T09:18:54",
            "upload_time_iso_8601": "2024-04-19T09:18:54.815193Z",
            "url": "https://files.pythonhosted.org/packages/6c/d6/a324904b9f1549290241c4349828893534ad1745cd35f04a39ebd52a2cc3/os-apply-config-14.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-19 09:18:54",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "os-apply-config"
}
        
Elapsed time: 0.24176s