{
"info": {
"author": "Laurent Peuch",
"author_email": "cortex@worlddomination.be",
"bugtrack_url": null,
"classifiers": [],
"description": "Introduction\n============\n\nDawdaw is an experiment to make a [SaltStack](http://www.saltstack.com/) custom [renderer](http://docs.saltstack.com/en/latest/ref/renderers/index.html) (the stuff that allows you to write your states in yaml/jinja2/mako/other) in an attempt to solve those problems:\n\n* current states are too verbose to write\n* you often repeat yourself too much\n* really have a linear states declaration for requires\n* explicit requires on included states, to avoid globals\n* namespacing all the things, to avoid globals\n* indirectly trying to solve the \"salt states are very hard to redistribute\" problem by going full python, you can now use setup.py and pypi/pip to redistribute you work\u00b9\n\nDisadvantages: you move await from full declarative code (which you were\nalready doing in fact with jinja2 templates) to go back to python code. This\nis, on one hand very powerful, on the other hand probably too powerful (and may\nbe way less easy to understand for devops that don't come from a programming\nbackground). That works for me because I'm a python dev and I'm using this for\nmy personal usages, but that might not fit your case.\n\nSample\n======\n\nMove from:\n\n```yaml\ninclude:\n - dotfiles\n\nwyrd-pkgs:\n pkg.installed:\n - name: wyrd\n - require:\n - sls: dotfiles\n\nreminds.git:\n git.latest:\n - name: ssh://git@bitbucket.org/psycojoker/reminds.git\n - runas: psycojoker\n - target: /home/psycojoker/reminds/\n - require:\n - pkg: git\n\ncd /home/psycojoker/reminds/ && bash init:\n cmd.run:\n - unless: ls /home/psycojoker/.reminders /home/psycojoker/.reminders.gcl\n - user: psycojoker\n - require:\n - git: reminds.git\n```\n\nTo:\n\n```python\n#!dawdaw_template\n\nfrom dawdaw.states import pkg, git, cmd, include\nfrom dawdaw.utils import default, test, debug\n\ndotfiles = include(\"dotfiles\")\n\nwith default(user=\"psycojoker\", runas=\"psycojoker\"):\n pkg.installed(\"wyrd\",\n require=[dotfiles.get(\"pkg\", \"dotfiles-pkgs\")])\n git.latest(\"ssh://git@bitbucket.org/psycojoker/reminds.git\",\n target=\"/home/psycojoker/reminds/\")\n\n if not test(\"ls /home/psycojoker/.reminders /home/psycojoker/.reminders.gcl\"):\n cmd.run(\"cd /home/psycojoker/reminds/ && bash init\")\n```\n\nInstallation\n============\n\n pip install dawdaw\n\n # this is how you install a renderer in salt\n # if you know a better way to distribute it, plz tell me\n\n # adapt the path to the location of your salt data\n mkdir -p /srv/salt/_renderers\n touch /srv/salt/_renderers/__init__.py\n\n curl \"https://raw.githubusercontent.com/Psycojoker/dawdaw/master/dawdaw_template.py\" > /srv/salt/_renderers/dawdaw_template.py\n\n # if you use salt in master/slave\n salt '*' saltutil.sync_renderers\n # or locally\n salt-call --local saltutil.sync_renderers\n\nOnce it's done, you can normally run highstates, this will handle\ndawdaw_template like any regular other state.\n\nDocumentation\n=============\n\nOnce you have installed dawdaw (see previous section), to use it, you simply need to put this as the first line of your file (dawdaw_template being the name of the file under which you have redirected the curl command bellow):\n\n```python\n#!dawdaw_template\n```\n\nStates\n------\n\nUsing states is extremely simple: just import the state module and call the\ncorresponding function like a python function.\n\n### Example\n\n```yaml\nstate_name:\n state_module.state_function:\n - argument_1: value_1\n - argument_2: value_2\n - argument_3: value_3\n ...\n```\n\nBecome:\n\n```python\nfrom dawdaw.states import state_module\n\nstate_module.state_function(\"state_name\",\n argument_1=\"value_1\",\n argument_2=\"value_2\",\n argument_3=\"value_3\",\n ...)\n```\n\n### Another example\n\n```yaml\nhttps://github.com/Psycojoker/dawdaw:\n git.latest:\n - target: /tmp/dawdaw\n```\n\nBecome:\n\n```python\nfrom dawdaw.states import git\n\ngit.latest(\"https://github.com/Psycojoker/dawdaw\", target=\"/tmp/dawdaw\")\n```\n\nThe 'default' context manager\n-----------------------------\n\nIn salt, you often end up repeating the same arguments a lot, like settings the\nprioprietary of the file to the same user a lot. This is boring and not error proof.\nSure, the\n'[use](http://docs.saltstack.com/en/latest/ref/states/requisites.html#use)'\nexists, but it's awkward and no one knows about it. Thanks to python, we have\ncontext managers and we can use the with keyword to handle that.\n\nThe default context manager create a context in which **every\ncommand that waits for some specific keywords will be called with it**.\n\n### Example\n\n```python\nfrom dawdaw.states import git, file\nfrom dawdaw.utils import default\n\n\nwith default(makedirs=True): \n # git won't received the 'makedirs' keyword\n git.latest(\"https:/...\", target=\"/some/stuf\")\n\n # file will received it\n file.managed(\"/some/stuff/subdir/settings_prod.py\", source=\"...\")\n```\n\nI often end up using it to settings user and groups:\n\n```python\nwith default(user='psycojoker', group='psycojoker', runas='psycojoker'): \n # ...\n```\n\nModules\n-------\n\n(The stuff you use in the CLI like salt '*' cmd.run \"ls /tmp\"). As simple\nas states, just import it and call it like normal python code (and play with\nit's return like in normal python):\n\n```python\nfrom dawdaw.modules import cmd\n\nfor f in cmd.run(\"ls /tmp\"):\n # do some stuff with 'f'\n```\n\nThe 'test' helper\n-----------------\n\nSometime, you need to test if a command return the code '0', you can do it\nusing cmd.retcode(\"...\") but that's quite boring. Dawdaw provides\na simple helper to do that for you:\n\n```python\nfrom dawdaw.utils import test\n\nif test(\"ls /tmp/this_file_exist\"):\n # do some stuff\n```\n\nRequisites\n----------\n\nIn dawdaw, you don't have to care that much about requisites, a linear\nexecution of the states in the order in which they are called is enforced. This\nmean, that, in this example, module.b will have a require on\nmodule.a and module.c will have a require on\nmodule.a **and** module.b:\n\n```python\nmodule.a(\"...\")\nmodule.b(\"...\")\nmodule.c(\"...\")\n```\n\nThe requires are only set if the state is actually called, so you can use 'if'\nand other control flow structure the way you want like in normal python code.\n\n**If you stil need/want to set explicit requires**, every state return a\nreference to itself once it is called, so you can simply do it this way:\n\n```python\na = module.a(\"...\")\nmodule.b(\"...\", require=[a]) # remember, requires are set in a list!\n```\n\nNamespacig, watch or more generally: how to refer to a state\n------------------------------------------------------------\n\nIn dawdaw, every state has its name namespaced with the name of the file it is\nstored in and the module from which it's called. For example, this state:\ngit.latest(\"https://github.com/Psycojoker/dawdaw\") in the file\ndawdaw.sls will have the name\ndawdaw_git_https://github.com/Psycojoker/dawdaw. **Keep this in mind\nif you want to refer to other states in non-dawdaw states.\n\nBut when you are in dawdaw you don't have to care about that: every state\nreturns a reference to itself once called, you can use that without caring\nabout how it is done and without the risk of making stupide mistake or having\nto rename it everywhere. For example:\n\n```python\na = module.a(\"...\")\nmodule.b(\"...\", watch=[a]) # remember, watchs are set in a list!\n```\n\nWorks for watch, watch_in, require,\nrequire_in, prereq, [the other\nrequisites](http://docs.saltstack.com/en/latest/ref/states/requisites.html) etc\n... Basically everytime you need to reference a state.\n\nIf you really need to do that by hand (don't), in reality, the reference is\njust a dict, so you can do this this way (don't forget about the namespacing!):\n\n```python\n# in file example.sls\n\nmodule.a(\"some_name\")\nmodule.b(\"...\", watch=[{\"module\": \"example_module_some_name\"}]) # remember, watchs are set in a list!\n```\n\nBut don't do that.\n\nInclude\n-------\n\ninclude works nearly the same than in salt. The only difference is\nthat you only include one state at once, not a list of states. This allows the\ninclude to return a representation of included sls file to\nreference states from this sls file.\n\nIn the same fashion than state, every state that follows an include will\nrequire on it to enforce linear execution.\n\n### Example:\n\n```python\nfrom dawdaw.states import include\n\ninclude(\"some_state\")\ninclude(\"another_state\")\n```\n\n### Reference:\n\nAn include can be use to reference a state of the included sls file (and it's\nrecommand to to avoid global namespaced reference) using the .get\nmethod. .get takes 2 parameters: the module and the name.\n\nExample:\n```python\nfrom dawdaw.states import include, pkg\n\nsome_state = include(\"some_state\")\ninclude(\"another_state\")\n\npkg.installed(\"stuff\", require=[some_state.get(\"a_module\", \"a_name\")])\n```\n\n**If the included sls file is not a dawdaw file, you must pass the argument\nin_dawdaw=False to include because of namespacing.**\n\nExample:\n```python\nfrom dawdaw.states import include, pkg\n\nsome_state = include(\"some_state\", in_dawdaw=False)\n\npkg.installed(\"stuff\", watch=[some_state.get(\"a_module\", \"a_name\")])\n```\n\nPillar, grains and opts\n-----------------------\n\nAll those 3 salt artifacts are accessible very easily by simply importing them\nand they will behave the same way than they behave in jinja2 templates (hint:\nthey are dictionaries):\n\n```python\nfrom dawdaw import pillar, grains, opts\n\npillar[\"stuff\"]\n```\n\ndebug\n-----\n\nDawdaw comes with a helper debug to debug what it does. This helper will simply print\non the shell the generated yaml (you'll see it in the logs or if you run salt\nlocally using \"salt-call --local\").\n\nUsage:\n\n```python\nfrom dawdaw.utils import debug\n\ndebug()\n```\n\nYou can pass a boolean argument to debug activated/desactivate debugging:\n\n```python\nfrom dawdaw.utils import debug\n\ndebug()\n\nif some_stuff:\n # finally don't need to debug\n debug(False)\n```\n\nAlso, since this is full python you can drop in [ipdb](https://github.com/gotcha/ipdb) to just debug your code. **Be sure to only do that if you run salt locally**.\n\nLicence\n-------\n\nBelgian Beerware.\n\nFootnotes\n---------\n\nI've had fun writing it, hopes you'll have using it. You don't want to know how it's made.\n\n\u00b9: I have [another experiment](https://github.com/Psycojoker/cellar) that try\nto solve this problem, but I'm not writing enough salt right now to move on\nit.",
"description_content_type": null,
"docs_url": null,
"download_url": "UNKNOWN",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/Psycojoker/dawdaw",
"keywords": "salt renderer",
"license": "beerware",
"maintainer": null,
"maintainer_email": null,
"name": "dawdaw",
"package_url": "https://pypi.org/project/dawdaw/",
"platform": "UNKNOWN",
"project_url": "https://pypi.org/project/dawdaw/",
"project_urls": {
"Download": "UNKNOWN",
"Homepage": "https://github.com/Psycojoker/dawdaw"
},
"release_url": "https://pypi.org/project/dawdaw/0.1.2/",
"requires_dist": null,
"requires_python": null,
"summary": "salt renderer for extremly lazy python dev",
"version": "0.1.2"
},
"last_serial": 1136321,
"releases": {
"0.1": [
{
"comment_text": "",
"digests": {
"md5": "c4a4d5ac2fcd4ac13a5dd9683ff307fe",
"sha256": "ed7336affc906fb03955514197e29a7872e28d8add2fea3d9a99e3a018a6f95d"
},
"downloads": -1,
"filename": "dawdaw-0.1-py2.7.egg",
"has_sig": false,
"md5_digest": "c4a4d5ac2fcd4ac13a5dd9683ff307fe",
"packagetype": "bdist_egg",
"python_version": "2.7",
"requires_python": null,
"size": 9398,
"upload_time": "2014-05-19T04:01:53",
"url": "https://files.pythonhosted.org/packages/bf/eb/da5ccc7f1b43f13690283f1c1c474d7bda12104c60d9eab954580e2e87d9/dawdaw-0.1-py2.7.egg"
},
{
"comment_text": "",
"digests": {
"md5": "12880b6c272586ac46f521406b18947b",
"sha256": "138e13b5d9fbff3c0d97a5e74c645effa3dfafa006305ed7311b9c057cf68f88"
},
"downloads": -1,
"filename": "dawdaw-0.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "12880b6c272586ac46f521406b18947b",
"packagetype": "bdist_wheel",
"python_version": "2.7",
"requires_python": null,
"size": 14011,
"upload_time": "2014-05-19T04:01:50",
"url": "https://files.pythonhosted.org/packages/8a/da/99c81c29941cce114f48600f92a61cc56991da545501a7ceef7a97a42351/dawdaw-0.1-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "9a6293f375cb91ff5c96bfd3efd700e6",
"sha256": "f1ab4c6e9d4d98cdaccdcf6b5c75f66781c43b1ae16ac0c31e4e08333d006046"
},
"downloads": -1,
"filename": "dawdaw-0.1.tar.gz",
"has_sig": false,
"md5_digest": "9a6293f375cb91ff5c96bfd3efd700e6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8250,
"upload_time": "2014-05-19T04:01:47",
"url": "https://files.pythonhosted.org/packages/99/e5/6d4df22e785ab5d131f9bb5b607b87e22dfefcbd9004b3d5276a8ac3f72a/dawdaw-0.1.tar.gz"
}
],
"0.1.1": [
{
"comment_text": "",
"digests": {
"md5": "62882b61a6e81f2ec89aa3ad3566d538",
"sha256": "76f97706f05ed1ed275b38f36566dd27995a795008a4f45ada131855666be467"
},
"downloads": -1,
"filename": "dawdaw-0.1.1-py2.7.egg",
"has_sig": false,
"md5_digest": "62882b61a6e81f2ec89aa3ad3566d538",
"packagetype": "bdist_egg",
"python_version": "2.7",
"requires_python": null,
"size": 9484,
"upload_time": "2014-06-24T19:50:25",
"url": "https://files.pythonhosted.org/packages/1f/e2/24464a45d6ac91984cb064c190e01fcd727b37db706680dc0ef091a5c78a/dawdaw-0.1.1-py2.7.egg"
},
{
"comment_text": "",
"digests": {
"md5": "d6252fc8519b86e65ca4f45f9d6a92dd",
"sha256": "db67bf3dcbc0777451ec6ca4fd1bd2d8e037a6a5df5549497dfa70f63aecd0e9"
},
"downloads": -1,
"filename": "dawdaw-0.1.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "d6252fc8519b86e65ca4f45f9d6a92dd",
"packagetype": "bdist_wheel",
"python_version": "2.7",
"requires_python": null,
"size": 14206,
"upload_time": "2014-06-24T19:50:23",
"url": "https://files.pythonhosted.org/packages/29/02/e75e1f3e154e4040d03dccc2b7f023305173cc77d571d7dab2f8ee6fd777/dawdaw-0.1.1-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "08f97d8362ab85dc363b8feecd7d5cd8",
"sha256": "dec08b20eea97938303fe758967ec00f9516a4d75917c8cf0288b805d8e7d7c7"
},
"downloads": -1,
"filename": "dawdaw-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "08f97d8362ab85dc363b8feecd7d5cd8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8349,
"upload_time": "2014-06-24T19:50:21",
"url": "https://files.pythonhosted.org/packages/fe/09/aeabe21696be219039cde6c0fbbe39362a423629ab9fcf75ff2a86ae37ff/dawdaw-0.1.1.tar.gz"
}
],
"0.1.2": [
{
"comment_text": "",
"digests": {
"md5": "b668268f4ba546c880259b1e8f7e551a",
"sha256": "73b3af139a04c9c479c5f0975391cb975c9e860a8aa1ab0c898d78f6f823befd"
},
"downloads": -1,
"filename": "dawdaw-0.1.2-py2.7.egg",
"has_sig": false,
"md5_digest": "b668268f4ba546c880259b1e8f7e551a",
"packagetype": "bdist_egg",
"python_version": "2.7",
"requires_python": null,
"size": 9555,
"upload_time": "2014-06-24T21:38:34",
"url": "https://files.pythonhosted.org/packages/dd/60/e3127f2a545020d90c4c3e7493f24558943f487a35d1e933ba69ddbeaf3e/dawdaw-0.1.2-py2.7.egg"
},
{
"comment_text": "",
"digests": {
"md5": "83bc2c1e46b6013ac0c6bd1b9a835bf0",
"sha256": "144583f63c9dcfbde73ad61e4658514a9ec5995ae29b858a984e134a5066b984"
},
"downloads": -1,
"filename": "dawdaw-0.1.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "83bc2c1e46b6013ac0c6bd1b9a835bf0",
"packagetype": "bdist_wheel",
"python_version": "2.7",
"requires_python": null,
"size": 14276,
"upload_time": "2014-06-24T21:38:32",
"url": "https://files.pythonhosted.org/packages/e7/28/293ad1120ef948647235767cad4b8e07e07ba640b6119998ac5cc2105bd0/dawdaw-0.1.2-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "d203ce50ebf0ddd0788411212a0118de",
"sha256": "29f85fb37c67a799696b2276671e42998ebb1995d7a02718aaf3c3840b0ac0f5"
},
"downloads": -1,
"filename": "dawdaw-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "d203ce50ebf0ddd0788411212a0118de",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8427,
"upload_time": "2014-06-24T21:38:29",
"url": "https://files.pythonhosted.org/packages/c1/d2/dc5bbb63e7334235a226ad6b8665f28871706b1af76e9eccf02ad62d357f/dawdaw-0.1.2.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "b668268f4ba546c880259b1e8f7e551a",
"sha256": "73b3af139a04c9c479c5f0975391cb975c9e860a8aa1ab0c898d78f6f823befd"
},
"downloads": -1,
"filename": "dawdaw-0.1.2-py2.7.egg",
"has_sig": false,
"md5_digest": "b668268f4ba546c880259b1e8f7e551a",
"packagetype": "bdist_egg",
"python_version": "2.7",
"requires_python": null,
"size": 9555,
"upload_time": "2014-06-24T21:38:34",
"url": "https://files.pythonhosted.org/packages/dd/60/e3127f2a545020d90c4c3e7493f24558943f487a35d1e933ba69ddbeaf3e/dawdaw-0.1.2-py2.7.egg"
},
{
"comment_text": "",
"digests": {
"md5": "83bc2c1e46b6013ac0c6bd1b9a835bf0",
"sha256": "144583f63c9dcfbde73ad61e4658514a9ec5995ae29b858a984e134a5066b984"
},
"downloads": -1,
"filename": "dawdaw-0.1.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "83bc2c1e46b6013ac0c6bd1b9a835bf0",
"packagetype": "bdist_wheel",
"python_version": "2.7",
"requires_python": null,
"size": 14276,
"upload_time": "2014-06-24T21:38:32",
"url": "https://files.pythonhosted.org/packages/e7/28/293ad1120ef948647235767cad4b8e07e07ba640b6119998ac5cc2105bd0/dawdaw-0.1.2-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "d203ce50ebf0ddd0788411212a0118de",
"sha256": "29f85fb37c67a799696b2276671e42998ebb1995d7a02718aaf3c3840b0ac0f5"
},
"downloads": -1,
"filename": "dawdaw-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "d203ce50ebf0ddd0788411212a0118de",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8427,
"upload_time": "2014-06-24T21:38:29",
"url": "https://files.pythonhosted.org/packages/c1/d2/dc5bbb63e7334235a226ad6b8665f28871706b1af76e9eccf02ad62d357f/dawdaw-0.1.2.tar.gz"
}
]
}