Deploy your plugin
******************

Once you decide that your plugin is ready for distribution, take the following steps:

* Build the final version of the plugin using the ``oneagent_build_plugin`` tool.
* Promote the plugin to production mode. To do this, go to **Settings > Monitored technologies > Custom plugins** and select a staging plugin that you're satisfied with. Hit the **Upgrade now** button.

  .. image:: ../images/demo_01_promote_plugin.png

* Deploy the plugin by copying the folder generated by ``oneagent_build_plugin`` tool to the ``plugin_deployment`` folder in the root of your OneAgent installation [1]_ or use a configuration management tool, such as Puppet, Chef, or Ansible.Be sure that you copy the entire folder (named for example ``custom.python.demo_plugin``),
  and not the zip archive that is generated by ``oneagent_build_plugin``.
* Restart OneAgent.


.. rubric:: Important considerations

Please note when distributing custom plugins:

* The plugin directories require at least read permissions for the appropriate user [2]_.
* Changing the contents of the plugin requires restarting OneAgent so that the plugins will be reloaded.
* If you're unsure how the plugins are loaded, and if you've copied them to the right place,
  learn more at :doc:`../plugin_lifecycle/index` in the "Plugin loading" section.

Example deployment with Ansible
===============================

An example playbook for distributing your plugin via Ansible could look similar to this:

.. literalinclude:: deploy_demo_plugin.yml

Given you have inventory with plugin_deployment group, the output of running the script could look like this:

.. literalinclude:: deploy_ansible_results.out

If you're unsure how ansible works please refer to `Ansible documentation <http://docs.ansible.com/>`_


.. [1] Usually ``/opt/dynatrace/oneagent`` or ``C:\\Program Files (x86)\\dynatrace\\oneagent``
.. [2] ``dtuser`` on linux, ``Local system account`` on Windows
