bigsudo


Namebigsudo JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://yourlabs.io/oss/bigsudo
SummaryObscene ansible runner
upload_time2023-11-23 15:47:10
maintainer
docs_urlNone
author
requires_python>=3
license
keywords automation cli ansible
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            bigsudo: Obscene ansible runner
===============================

Bigsudo is an opinionated command line wrapper to ansible-playbook.

**You must have ansible-playbook command installed for bigsudo to work!**

Features
--------

It accepts as first argument: role name, path or url, or playbook path
or url::

    bigsudo role.name # download role and run tasks/main.yml on localhost

    bigsudo role.name update # do tasks/update.yml
    bigsudo role.name user@host update # do tasks/update.yml on host
    bigsudo role.name @host update # with current user
    bigsudo role.name @host update foo=bar # custom variable
    bigsudo role.name {"foo":"bar"} # also accepts json without space
    bigsudo role.name -v # forwards any ansible-playbook argument

Note that bigsudo will automatically call ansible-galaxy install on
requirements.yml it finds in any role, recursively on each role that it got
galaxy to install. This means that yourlabs.docker/requirements.yml will also
be installed by bigsudo if your repo has this requirements.yml::

    - src: git+https://yourlabs.io/oss/yourlabs.docker

How command line parsing works
------------------------------

Three golden rules:

- Bigsudo runs with ``--become`` by default (well, it's "bigsudo"), to avoid
  this, pass ``--nosudo``.  This is just because personnaly I am root and
  forget ``--become`` **a lot** more often than I need ``--nosudo``.
- **Bigsudo will take bigsudo arguments first**, they don't start with a dash,
  they are either strings without ``=`` which means they are positionnal
  arguments to bigsudo Python functions, either strings with ``=`` which means
  they are keyword arguments to bigsudo commands.
- From the point where an argument starts with a dash, all arguments are
  forwarded to ansible. **You cannot pass a bigsudo argument after passing an
  argument that starts with a dash**.

As such, these two calls are equivalent::

   bigsudo yourlabs.fqdn -e foo=bar
   bigsudo yourlabs.fqdn foo=bar

But that will not work::

   bigsudo yourlabs.fqdn -v foo=bar

Because it will generate that command in which ansible will look for
``foo=bar`` playbook::

   ansible-playbook -v foo=bar ...

Bigsudo will always print out generated ansible-playbook command lines anyway.

Continuous Deployment with Gitlab-CI
------------------------------------

Using gitlab-ci or drone-ci you can define multiline env vars, ie a with
$STAGING_HOST=deploy@yourstaging and json string for $STAGING_VARS::

    {
      "security_salt": "yoursecretsalf",
      "mysql_password": "...",
      // ....
    }

Then you can define a staging deploy job as such in .gitlab-ci.yml::

    image: yourlabs/python

    # example running tasks/update.yml, using the repo as role
    script: bigsudo . update $staging_host $staging_vars

    # example running playbook update.yml
    script: bigsudo ./update.yml $staging_host $staging_vars

This chapter describes the steps to setup the following deploy job in your
.gitlab-ci.yml::

  deploy-staging:
    image: yourlabs/python
    stage: deploy

    script:
    - mkdir -p ~/.ssh; echo $staging_key > ~/.ssh/id_ed25519; echo $staging_fingerprint > ~/.ssh/known_hosts; chmod 700 ~/.ssh; chmod 600 ~/.ssh/*
    - bigsudo . $staging_host --extra-vars=$staging_vars

    only:
      refs: [master]

    environment:
      name: staging
      url: https://staging.example.com

Create an ed25519 deploy key with the following command::

    ssh-keygen -t ed25519 -a 100 -f deploy.key

Upload the deployment key to your target::

    ssh-copy-id -i deploy.key user@staging.host

Add it to the enviromnent variable ``$staging_key`` ::

    cat deploy.key

Also add your host fingerprint in ``$staging_fingerprint``::

    ssh-keyscan staging.host

Add all the variables you need for your tasks in the ``$staging_vars`` env var
as a JSON dict, as described in the previous chapter.

            

Raw data

            {
    "_id": null,
    "home_page": "https://yourlabs.io/oss/bigsudo",
    "name": "bigsudo",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": "",
    "keywords": "automation cli ansible",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/bf/50/9c51b70dd25fd279bb0d2e1a66c27adc14032ba83d558706fbf7b606ccc6/bigsudo-1.1.0.tar.gz",
    "platform": null,
    "description": "bigsudo: Obscene ansible runner\n===============================\n\nBigsudo is an opinionated command line wrapper to ansible-playbook.\n\n**You must have ansible-playbook command installed for bigsudo to work!**\n\nFeatures\n--------\n\nIt accepts as first argument: role name, path or url, or playbook path\nor url::\n\n    bigsudo role.name # download role and run tasks/main.yml on localhost\n\n    bigsudo role.name update # do tasks/update.yml\n    bigsudo role.name user@host update # do tasks/update.yml on host\n    bigsudo role.name @host update # with current user\n    bigsudo role.name @host update foo=bar # custom variable\n    bigsudo role.name {\"foo\":\"bar\"} # also accepts json without space\n    bigsudo role.name -v # forwards any ansible-playbook argument\n\nNote that bigsudo will automatically call ansible-galaxy install on\nrequirements.yml it finds in any role, recursively on each role that it got\ngalaxy to install. This means that yourlabs.docker/requirements.yml will also\nbe installed by bigsudo if your repo has this requirements.yml::\n\n    - src: git+https://yourlabs.io/oss/yourlabs.docker\n\nHow command line parsing works\n------------------------------\n\nThree golden rules:\n\n- Bigsudo runs with ``--become`` by default (well, it's \"bigsudo\"), to avoid\n  this, pass ``--nosudo``.  This is just because personnaly I am root and\n  forget ``--become`` **a lot** more often than I need ``--nosudo``.\n- **Bigsudo will take bigsudo arguments first**, they don't start with a dash,\n  they are either strings without ``=`` which means they are positionnal\n  arguments to bigsudo Python functions, either strings with ``=`` which means\n  they are keyword arguments to bigsudo commands.\n- From the point where an argument starts with a dash, all arguments are\n  forwarded to ansible. **You cannot pass a bigsudo argument after passing an\n  argument that starts with a dash**.\n\nAs such, these two calls are equivalent::\n\n   bigsudo yourlabs.fqdn -e foo=bar\n   bigsudo yourlabs.fqdn foo=bar\n\nBut that will not work::\n\n   bigsudo yourlabs.fqdn -v foo=bar\n\nBecause it will generate that command in which ansible will look for\n``foo=bar`` playbook::\n\n   ansible-playbook -v foo=bar ...\n\nBigsudo will always print out generated ansible-playbook command lines anyway.\n\nContinuous Deployment with Gitlab-CI\n------------------------------------\n\nUsing gitlab-ci or drone-ci you can define multiline env vars, ie a with\n$STAGING_HOST=deploy@yourstaging and json string for $STAGING_VARS::\n\n    {\n      \"security_salt\": \"yoursecretsalf\",\n      \"mysql_password\": \"...\",\n      // ....\n    }\n\nThen you can define a staging deploy job as such in .gitlab-ci.yml::\n\n    image: yourlabs/python\n\n    # example running tasks/update.yml, using the repo as role\n    script: bigsudo . update $staging_host $staging_vars\n\n    # example running playbook update.yml\n    script: bigsudo ./update.yml $staging_host $staging_vars\n\nThis chapter describes the steps to setup the following deploy job in your\n.gitlab-ci.yml::\n\n  deploy-staging:\n    image: yourlabs/python\n    stage: deploy\n\n    script:\n    - mkdir -p ~/.ssh; echo $staging_key > ~/.ssh/id_ed25519; echo $staging_fingerprint > ~/.ssh/known_hosts; chmod 700 ~/.ssh; chmod 600 ~/.ssh/*\n    - bigsudo . $staging_host --extra-vars=$staging_vars\n\n    only:\n      refs: [master]\n\n    environment:\n      name: staging\n      url: https://staging.example.com\n\nCreate an ed25519 deploy key with the following command::\n\n    ssh-keygen -t ed25519 -a 100 -f deploy.key\n\nUpload the deployment key to your target::\n\n    ssh-copy-id -i deploy.key user@staging.host\n\nAdd it to the enviromnent variable ``$staging_key`` ::\n\n    cat deploy.key\n\nAlso add your host fingerprint in ``$staging_fingerprint``::\n\n    ssh-keyscan staging.host\n\nAdd all the variables you need for your tasks in the ``$staging_vars`` env var\nas a JSON dict, as described in the previous chapter.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Obscene ansible runner",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://yourlabs.io/oss/bigsudo"
    },
    "split_keywords": [
        "automation",
        "cli",
        "ansible"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bf509c51b70dd25fd279bb0d2e1a66c27adc14032ba83d558706fbf7b606ccc6",
                "md5": "5dec901897449cba9c96fac83dc82e64",
                "sha256": "ef372a72efa8e8a33aca28811f1cb1bba9c0d506823664bdc941300a6aa99e55"
            },
            "downloads": -1,
            "filename": "bigsudo-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "5dec901897449cba9c96fac83dc82e64",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 10607,
            "upload_time": "2023-11-23T15:47:10",
            "upload_time_iso_8601": "2023-11-23T15:47:10.378281Z",
            "url": "https://files.pythonhosted.org/packages/bf/50/9c51b70dd25fd279bb0d2e1a66c27adc14032ba83d558706fbf7b606ccc6/bigsudo-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-23 15:47:10",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "bigsudo"
}
        
Elapsed time: 0.14354s