{"id":20606810,"url":"https://github.com/jochumdev/saltstack-lxd-formula","last_synced_at":"2025-04-15T02:44:52.867Z","repository":{"id":67627097,"uuid":"63486494","full_name":"jochumdev/saltstack-lxd-formula","owner":"jochumdev","description":"LXD Formula for Saltstack","archived":false,"fork":false,"pushed_at":"2016-12-24T15:23:55.000Z","size":880,"stargazers_count":8,"open_issues_count":2,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-15T02:44:47.110Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jochumdev.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":"2016-07-16T14:26:17.000Z","updated_at":"2018-10-08T14:42:47.000Z","dependencies_parsed_at":"2023-05-25T13:00:31.755Z","dependency_job_id":null,"html_url":"https://github.com/jochumdev/saltstack-lxd-formula","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jochumdev%2Fsaltstack-lxd-formula","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jochumdev%2Fsaltstack-lxd-formula/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jochumdev%2Fsaltstack-lxd-formula/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jochumdev%2Fsaltstack-lxd-formula/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jochumdev","download_url":"https://codeload.github.com/jochumdev/saltstack-lxd-formula/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248997087,"owners_count":21195797,"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-16T09:34:46.930Z","updated_at":"2025-04-15T02:44:52.861Z","avatar_url":"https://github.com/jochumdev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"===\nLXD\n===\n\nThis project MOVED to `saltstack-formulas`_\n===========================================\n\n`LXD`_ is a container \"hypervisor\". This formulas provides\nseveral states to help manage it and its containers.\n\nThis formula will allow you to:\n\n- Initialize LXD with storage, authentication and network settings.\n- Create some default settings for containers (profiles).\n- Pull an image from various sources.\n- Create a container with an image.\n- Start/Stop/Restart/Freeze/Unfreeze/Migrate a container.\n- And finaly undo all of the above.\n\nBefore we forget it, `LXD`_ and this formula allows you to\n**migrate unprivliged containers** from one host to another!\n\n.. _LXD: https://linuxcontainers.org/lxd/\n.. _saltstack-formulas: https://github.com/saltstack-formulas/lxd-formula\n\nTODOS\n=====\n\n- For container states (_states/lxd_container.py)\n\n * Add support file put (including salt:// scheme)\n * Add support file get\n * Add support execute\n\nThe functionality for this is available in the module:\n\n.. code-block:: bash\n\n   salt \u003cminion\u003e lxd.container_put \u003cname\u003e host_src container_dst [mode=0600] [uid=0] [gid=0]\n\n   salt \u003cminion\u003e lxd.container_get \u003cname\u003e container_src host_dst\n\n   salt \u003cminion\u003e lxd.container_execute \u003cname\u003e '[\"ls\", \"-l\"]'\n\n\n\nRequirements\n============\n\n- There are currently only LXD packages for Ubuntu GNU/Linux so for the daemon\n  you need Ubuntu.\n- This has been tested with Saltstack `2016.3.1`, we don't know if it\n  works with other versions.\n- `PyLXD`_ version 2.0.5 from PIP (enable use_pip and it will get that version!).\n\n.. _PyLXD: https://github.com/pcdummy/pylxd\n.. _169: https://github.com/lxc/pylxd/pull/169\n\nInstallation\n============\n\nClone and symlink\n-----------------\n\n- Put/symlink the contents of **_modules** into **salt/base/_modules/**.\n- Put/symlink the contents of **_states** into **salt/base/_states/**.\n- Put/symlink the directory **lxd** into **salt/base/**\n\nPer git remote\n--------------\n\n.. code-block:: yaml\n\n    gitfs_remotes:\n      - https://github.com/pcdummy/saltstack-lxd-formula.git\n\n\nAvailable states\n================\n\n.. contents::\n    :local:\n\n``lxd.init``\n-------------\n\nDoes everthing below.\n\n\n``lxd.lxd``\n-----------\n\nInstalls lxd manages its settings.\n\n\nMinimal examples\n++++++++++++++++\n\nTo not listen on the network and use the default storage engine\n\n.. code-block:: yaml\n\n    lxd:\n      lxd:\n        run_init: True\n\n      python:\n        # Currently pylxd version 2 is required for the lxd module to work.\n        use_pip: True\n\nTo listen on the network:\n\n.. code-block:: yaml\n\n    lxd:\n      lxd:\n        run_init: True\n\n        init:\n          trust_password: \"PaSsW0rD\"\n          network_address: \"[::]\"\n          network_port: \"8443\"\n\n\n      python:\n        # Currently pylxd version 2 is required for the lxd module to work.\n        use_pip: True\n\nConfig examples\n+++++++++++++++\n\n.. code-block:: yaml\n\n    lxd:\n      lxd:\n        run_init: True\n\n        init:\n          trust_password: \"PaSsW0rD\"\n          network_address: \"[::]\"\n          network_port: \"8443\"\n\n\n        # Lets say you configured the password wrong on init or want to change it:\n        config:\n          password:\n            key: core.trust_password\n            value: \"VerySecure!337\"\n            force_password: True    # Currently this will be executed every time\n                                    # you execute this state.\n\n        # Now lets say somewhere else you want to change the ip LXD is listening one\n          network:\n            key: core.https_address\n            value: \"[fd57:1:see:bad:c0de::14]:8443\"\n\n\n      python:\n        # Currently pylxd version 2 is required for the lxd module to work.\n        use_pip: True\n\n\n``lxd.client``\n--------------\n\nInstalls the lxd client - its a simple package installer for `lxd-client` (on Debian at least).\n\n\n``lxd.python``\n--------------\n\nInstalls pylxd, this requires the `pip-formula`_ if you enable \"use_pip\".\n\n.. _pip-formula: https://github.com/saltstack-formulas/pip-formula\n\n\n``lxd.remotes``\n---------------\n\nManages pylxd server connections, this is usefull when you want\nto create profiles/images/containers on remote LXD instances.\n\n.. attention::\n\n    Migrations and image copies don't work with provided \"local\" endpoint, overwrite it if you want to migrate from/to local.\n\nOverwrite **local**:\n++++++++++++++++++++\n\nMigrations and image copies don't work with provided \"local\" endpoint, overwrite it.\n\n.. code-block:: yaml\n\n    lxd:\n      remotes:\n        local:\n          type: lxd\n          remote_addr : \"https://srv02:8443\"\n          cert : \"/root/.config/lxc/client.crt\"\n          key : \"/root/.config/lxc/client.key\"\n          verify_cert : False\n          password\" : \"PaSsW0rD\"\n\nA named remote\n++++++++++++++\n\nThis is just here for other states to get its values.\n\n.. code-block:: yaml\n\n    lxd:\n      remotes:\n        srv01:\n          type: lxd\n          remote_addr : \"https://srv01:8443\"\n          cert : \"/root/.config/lxc/client.crt\"\n          key : \"/root/.config/lxc/client.key\"\n          verify_cert : False\n\nA remote we try to authenticate to\n++++++++++++++++++++++++++++++++++\n\n.. code-block:: yaml\n\n    lxd:\n      remotes:\n        srv02:\n          type: lxd\n          remote_addr : \"https://srv02:8443\"\n          cert : \"/root/.config/lxc/client.crt\"\n          key\" : \"/root/.config/lxc/client.key\"\n          verify_cert : False\n          password\" : \"PaSsW0rD\"\n\n\n``lxd.profiles``\n----------------\n\nManages LXD profiles, profiles are something like defaults for a container,\nyou can add multible profiles to a single container.\n\nIts general a good idea to look how profiles look on the `wire`_:\n\n.. _wire: https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-10\n\nAlso:\n\n.. code-block:: bash\n\n   salt-call lxd.profile_list --out=json\n\n   salt-call lxd.container_list --out=json\n\ngives nice informations about profile config keys and devices.\n\n\nA local profile that enables autostart\n++++++++++++++++++++++++++++++++++++++\n\n\n.. code-block:: yaml\n\n    lxd:\n      profiles:\n        local:    # local is special it means local unix socket, not authentication needed.\n          autostart:\n            config:\n              # Enable autostart\n              boot.autostart: 1\n              # Delay between containers in seconds.\n              boot.autostart.delay: 2\n              # The lesser the later it gets started on autostart.\n              boot.autostart.priority: 1\n\n\nThe same profile on the \"named\" remote \"srv01\"\n++++++++++++++++++++++++++++++++++++++++++++++\n\n.. code-block:: yaml\n\n    lxd:\n      profiles:\n        srv01:    # Notice the change from \"local\" to \"srv01\"\n          autostart:\n            config:\n              # Enable autostart\n              boot.autostart: 1\n              # Delay between containers in seconds.\n              boot.autostart.delay: 2\n              # The lesser the later it gets started on autostart.\n              boot.autostart.priority: 1\n\n\nA local profile that adds a interface\n+++++++++++++++++++++++++++++++++++++\n\n.. code-block:: yaml\n\n    lxd:\n      profiles:\n        local:\n          add_eth1:\n            devices:\n              eth1:\n                type: \"nic\"\n                nictype\": \"bridged\"\n                parent\": \"br1\"\n\n\nA local profile that adds a shared mount point\n++++++++++++++++++++++++++++++++++++++++++++++\n\n.. code-block:: yaml\n\n    lxd:\n      profiles:\n        local:\n          shared_mount:\n            devices:\n              shared_mount:\n                type: \"disk\"\n                # Source on the host\n                source: \"/home/shared\"\n                # Path in the container\n                path: \"home/shared\"\n\n\nA limited container profile\n+++++++++++++++++++++++++++\n\nSee `stgraber's blog`_\n\n.. _stgraber's blog: https://www.stgraber.org/2016/03/26/lxd-2-0-resource-control-412/\n\n.. code-block:: yaml\n\n    lxd:\n      profiles:\n        local:\n          small:\n            config:\n              limits.cpu: 1\n              limits.memory: 512MB\n            device:\n              root:\n                limits.read: 20Iops\n                limits.write: 10Iops\n\n\nMongoDB special case\n++++++++++++++++++++\n\nIf you use the MongoDB ext_pillar you will notice that it doesn't like\ndots in field names, this is why we added a special case for that:\n\n.. code-block:: yaml\n\n    lxd:\n      profiles:\n        local:\n          autostart:\n            config:\n              # Notice the key/value style here\n              - key: boot.autostart\n                value: 1\n              - key: boot.autostart.delay\n                value: 2\n              - key: boot.autostart.priority\n                value: 1\n\n\nTo remove a profile\n+++++++++++++++++++\n\n.. code-block:: yaml\n\n    lxd:\n      profiles:\n        local:\n          autostart:\n            absent: True\n\n\n``lxd.images``\n--------------\n\nManages LXD images.\n\nTo create an image from file on host 'local'\n++++++++++++++++++++++++++++++++++++++++++++\n\n.. code-block:: yaml\n\n    lxd:\n      images:\n        local:\n          busybox:\n            name: busybox     # Its alias\n            source:\n              type: file\n              filename: salt://lxd/files/busybox.tar.xz\n              saltenv: base\n\n\nTo create an image from the provided \"images\" remote\n++++++++++++++++++++++++++++++++++++++++++++++++++++\n\nOn `images.linuxcontainers.org`_ you see a list of images available.\n\n.. _images.linuxcontainers.org: http://images.linuxcontainers.org/\n\nAnd with ``lxc image list images:`` you get a list of aliases.\n\n.. code-block:: yaml\n\n    lxd:\n      images:\n        local:\n          xenial_amd64:\n            name: xenial/amd64    # Its alias\n            source:\n              name: ubuntu/xenial/amd64\n              remote: images_linuxcontainers_org    # See map.jinja for it\n            aliases: ['x', 'xa64']  # More aliases\n            public: False\n            auto_update: True\n\n\nTo create an image from \"simplestreams\"\n+++++++++++++++++++++++++++++++++++++++\n\nWe also implemented a way to copy images from simplestreams, to do so:\n\n.. code-block:: yaml\n\n    lxd:\n      images:\n        local:\n          trusty_amd64:\n            source:\n              name: trusty/amd64\n              remote: ubuntu    # See map.jinja for it\n            aliases: ['t', 'ta64']  # More aliases\n            public: False\n            auto_update: True\n\nThose simplestreams images have cloud-init integrated! Use\n\n    $ lxc image alias list ubuntu:\n\nto get a list of available aliases.\n\n\nTo create an image from an URL\n++++++++++++++++++++++++++++++\n\n.. code-block:: yaml\n\n    lxd:\n      images:\n        local:\n          trusty_amd64:\n            source:\n              type: url\n              url: https://dl.stgraber.org/lxd\n            aliases: ['busbox-amd64']  # More aliases\n            public: False\n            auto_update: True\n\n\n``lxd.containers``\n------------------\n\nManages LXD containers, this includes `lxd.images`, `lxd.profiles` and `lxd.remotes`.\n\n\nTo create a container and start it\n++++++++++++++++++++++++++++++++++\n\nFrom the image alias \"xenial/amd64\"\n\n.. code-block:: yaml\n\n    lxd:\n      containers:\n        local:\n          ubuntu-xenial:\n            running: True\n            source: xenial/amd64\n\n\nSame with the profiles \"default\" and \"autostart\"\n++++++++++++++++++++++++++++++++++++++++++++++++\n\nWe also add a higher start priority and a device eth1\n\n.. code-block:: yaml\n\n    lxd:\n      containers:\n        local:\n          ubuntu-xenial2:\n            running: True\n            source: xenial/amd64\n            profiles:\n              - default\n              - autostart\n            config:\n              boot.autostart.priority: 1000\n            devices:\n              eth1:\n                type: \"nic\"\n                nictype\": \"bridged\"\n                parent\": \"br1\"\n            opts:\n              require:\n                - lxd_profile: lxd_profile_local_autostart\n\n\nLater you might want migrate \"ubuntu-xenial\" to \"srv01\"\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n.. code-block:: yaml\n\n    lxd:\n      containers:\n        srv01:\n          ubuntu-xenial:\n            migrated: True\n            stop_and_start: True    # No live-migration but start/stop.\n            source: local       # Note that we've overwritten \"local\",\n                                # else this wont work!\n\n\nAnd finaly send it to /dev/null\n+++++++++++++++++++++++++++++++\n\n.. code-block:: yaml\n\n    lxd:\n      containers:\n        srv01:\n          ubuntu-xenial:\n            absent: True\n            stop: True\n\n\nLXD execution Module\n====================\n\nPlease see `execution_module doc`_ for it, or better directly the well documented\nsourcecode of the `LXD Module`_.\n\n.. _execution_module doc: doc/execution_module.rst\n.. _LXD Module: _modules/lxd.py\n\n\nAuthors\n=======\n\n`René Jochum`_ \u003crene@jochums.at\u003e\n\n.. _René Jochum: https://rene.jochums.at\n\nKees Bos \u003ck.bos@capitar.com\u003e\n\n\nLicense\n=======\n\nApache Version 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjochumdev%2Fsaltstack-lxd-formula","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjochumdev%2Fsaltstack-lxd-formula","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjochumdev%2Fsaltstack-lxd-formula/lists"}