Metadata-Version: 2.4
Name: opswork
Version: 0.10.2
Summary: OpsWork Swiss Knife.
Home-page: https://github.com/Clivern/OpsWork/
Author: Clivern
Author-email: hello@clivern.com
License: MIT
Project-URL: Documentation, https://github.com/Clivern/OpsWork/
Project-URL: Source, https://github.com/Clivern/OpsWork/
Project-URL: Changelog, https://github.com/Clivern/OpsWork/blob/main/CHANGELOG.rst
Project-URL: Tracker, https://github.com/Clivern/OpsWork/issues
Project-URL: Download, https://pypi.org/project/OpsWork/#files
Platform: any
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python
Classifier: License :: OSI Approved :: MIT License
Description-Content-Type: text/x-rst; charset=UTF-8
License-File: LICENSE.txt
Requires-Dist: click<=8.3.0
Requires-Dist: ansible-runner<=2.4.2
Requires-Dist: prettytable<=3.17.0
Requires-Dist: PyYAML<=6.0.3
Requires-Dist: cryptography<=46.0.3
Requires-Dist: GitPython<=3.1.45
Requires-Dist: requests<=2.32.5
Requires-Dist: importlib-metadata<=8.7.0; python_version < "3.8"
Dynamic: license-file

.. image:: https://img.shields.io/pypi/v/opswork.svg
    :alt: PyPI-Server
    :target: https://pypi.org/project/opswork/
.. image:: https://github.com/clivern/opswork/actions/workflows/ci.yml/badge.svg
    :alt: Build Status
    :target: https://github.com/clivern/opswork/actions/workflows/ci.yml
.. image:: https://static.pepy.tech/badge/opswork
    :alt: Downloads
    :target: https://pepy.tech/projects/opswork

|

=======
OpsWork
=======

To use opswork, follow the following steps:

1. Create a python virtual environment or use system wide environment

.. code-block::

    $ python3 -m venv venv
    $ source venv/bin/activate


2. Install opswork package with pip.

.. code-block::

    $ pip install opswork


3. Get opswork command line help

.. code-block::

    $ opswork --help


4. Init the config file and the sqlite database

.. code-block::

    $ opswork config init


5. To edit configs

.. code-block::

    $ opswork config init


6. Add a recipe

.. code-block::

    $ opswork recipe add <recipe_name> -p <recipe_relative_path>

    # Some examples
    $ opswork recipe add clivern/ping -p recipe/ping -f
    $ opswork recipe add clivern/nginx -p recipe/nginx -f
    $ opswork recipe add clivern/motd -p recipe/motd -f
    $ opswork recipe add clivern/cmd -p recipe/cmd -f
    # From remote git
    $ opswork recipe add clivern/dotfiles/update -p git@github.com:clivern/dotfiles.git -s brew/update -t dotfiles -f


7. To list recipes

.. code-block::

    $ opswork recipe list

    # Get recipes as a JSON
    $ opswork recipe list -o json | jq .


8. To get a recipe

.. code-block::

    $ opswork recipe get <recipe_name>


9. To delete a recipe

.. code-block::

    $ opswork recipe delete <recipe_name>


10. Add a host

.. code-block::

    $ opswork host add <host_name> -i <host_ip> -p <ssh_port> -u <ssh_username> -s <ssh_key_path>

    # Add a remote host
    $ opswork host add example.com -i 127.0.0.1 -p 22 -u root -s /Users/root/.ssh/id_rsa.pem

    # Add the localhost
    $ opswork host add localhost -i localhost -c local


11. To list hosts

.. code-block::

    $ opswork host list

    # Get hosts as a JSON
    $ opswork host list -o json | jq .


12. To get a host

.. code-block::

    $ opswork host get <host_name>


13. To SSH into a host

.. code-block::

    $ opswork host ssh <host_name>


14. To delete a host

.. code-block::

    $ opswork host delete <host_name>


15. Run a recipe towards a host

.. code-block::

    $ opswork recipe run <recipe_name> -h <host_name> -v key=value

    # Some examples
    $ opswork recipe run clivern/nginx -h example.com
    $ opswork recipe run clivern/ping -h localhost


16. To generate a random password

.. code-block::

    $ opswork random password 8


17. To add a secret

.. code-block::

    $ opswork secret add <secret/name> <secret_value> -t <tag>

    $ opswork secret add clivern/cloud_provider/api_key xxxx-xxxx-xxxx-xxxx -t cloud_provider


18. To list secrets

.. code-block::

    $ opswork secret list -o json


19. To get a secret

.. code-block::

    $ opswork secret get <secret_name>

    # For example
    $ opswork secret get clivern/cloud_provider/api_key


20. To delete a secret

.. code-block::

    $ opswork secret delete <secret_name>

    # For example
    $ opswork secret delete clivern/cloud_provider/api_key


21. To run a recipe with secrets

.. code-block::

    # add recipe
    $ opswork recipe add clivern/secrets -p recipe/secrets -f

    # add secret
    $ opswork secret add db_password s3cr3t --force

    # run recipe
    $ opswork recipe run clivern/secrets -h localhost


22. To batch load recipes and run them

.. code-block::

    $ opswork batch load batch.yml --force

    $ opswork batch run batch.yml --host localhost
