diff --git a/ara/setup/README.rst b/ara/setup/README.rst new file mode 100644 index 00000000..c2fabde4 --- /dev/null +++ b/ara/setup/README.rst @@ -0,0 +1,5 @@ +This directory contains scripts meant to help configuring ARA with Ansible. + +For more information, visit the documentation_. + +.. _documentation: http://ara.readthedocs.io/en/latest/configuration.html diff --git a/ara/setup/__init__.py b/ara/setup/__init__.py new file mode 100644 index 00000000..8557a6f4 --- /dev/null +++ b/ara/setup/__init__.py @@ -0,0 +1,25 @@ +# Copyright (c) 2017 Red Hat, Inc. +# +# This file is part of ARA: Ansible Run Analysis. +# +# ARA is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ARA is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ARA. If not, see . + +import os + +# The path where ARA is installed (parent directory) +path = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + +action_plugins = os.path.abspath(os.path.join(path, 'plugins/actions')) +callback_plugins = os.path.abspath(os.path.join(path, 'plugins/callbacks')) +library = os.path.abspath(os.path.join(path, 'plugins/modules')) diff --git a/ara/setup/action_plugins.py b/ara/setup/action_plugins.py new file mode 100644 index 00000000..b403d56d --- /dev/null +++ b/ara/setup/action_plugins.py @@ -0,0 +1,22 @@ +# Copyright (c) 2017 Red Hat, Inc. +# +# This file is part of ARA: Ansible Run Analysis. +# +# ARA is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ARA is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ARA. If not, see . + +from __future__ import print_function +from . import action_plugins + +if __name__ == "__main__": + print(action_plugins) diff --git a/ara/setup/ansible.py b/ara/setup/ansible.py new file mode 100644 index 00000000..b4bf48ab --- /dev/null +++ b/ara/setup/ansible.py @@ -0,0 +1,29 @@ +# Copyright (c) 2017 Red Hat, Inc. +# +# This file is part of ARA: Ansible Run Analysis. +# +# ARA is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ARA is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ARA. If not, see . + +from __future__ import print_function +from . import callback_plugins, action_plugins, library + +config = """ +[defaults] +callback_plugins={} +action_plugins={} +library={} +""".format(callback_plugins, action_plugins, library) + +if __name__ == "__main__": + print(config.strip()) diff --git a/ara/setup/callback_plugins.py b/ara/setup/callback_plugins.py new file mode 100644 index 00000000..297aaf1a --- /dev/null +++ b/ara/setup/callback_plugins.py @@ -0,0 +1,22 @@ +# Copyright (c) 2017 Red Hat, Inc. +# +# This file is part of ARA: Ansible Run Analysis. +# +# ARA is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ARA is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ARA. If not, see . + +from __future__ import print_function +from . import callback_plugins + +if __name__ == "__main__": + print(callback_plugins) diff --git a/ara/setup/env.py b/ara/setup/env.py new file mode 100644 index 00000000..66161311 --- /dev/null +++ b/ara/setup/env.py @@ -0,0 +1,28 @@ +# Copyright (c) 2017 Red Hat, Inc. +# +# This file is part of ARA: Ansible Run Analysis. +# +# ARA is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ARA is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ARA. If not, see . + +from __future__ import print_function +from . import callback_plugins, action_plugins, library + +exports = """ +export ANSIBLE_CALLBACK_PLUGINS={} +export ANSIBLE_ACTION_PLUGINS={} +export ANSIBLE_LIBRARY={} +""".format(callback_plugins, action_plugins, library) + +if __name__ == "__main__": + print(exports.strip()) diff --git a/ara/setup/library.py b/ara/setup/library.py new file mode 100644 index 00000000..85d6fea3 --- /dev/null +++ b/ara/setup/library.py @@ -0,0 +1,22 @@ +# Copyright (c) 2017 Red Hat, Inc. +# +# This file is part of ARA: Ansible Run Analysis. +# +# ARA is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ARA is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ARA. If not, see . + +from __future__ import print_function +from . import library + +if __name__ == "__main__": + print(library) diff --git a/ara/setup/path.py b/ara/setup/path.py new file mode 100644 index 00000000..a401e011 --- /dev/null +++ b/ara/setup/path.py @@ -0,0 +1,22 @@ +# Copyright (c) 2017 Red Hat, Inc. +# +# This file is part of ARA: Ansible Run Analysis. +# +# ARA is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ARA is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ARA. If not, see . + +from __future__ import print_function +from . import path + +if __name__ == "__main__": + print(path) diff --git a/ara/tests/unit/test_setup.py b/ara/tests/unit/test_setup.py new file mode 100644 index 00000000..58573241 --- /dev/null +++ b/ara/tests/unit/test_setup.py @@ -0,0 +1,29 @@ +# Copyright (c) 2017 Red Hat, Inc. +# +# This file is part of ARA: Ansible Run Analysis. +# +# ARA is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ARA is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ARA. If not, see . + +from ara.tests.unit.common import TestAra + + +class TestSetup(TestAra): + """ Tests the utils module """ + def setUp(self): + super(TestSetup, self).setUp() + + def tearDown(self): + super(TestSetup, self).tearDown() + + # TODO: Add tests :D diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index 6d96907c..aff0655b 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -12,39 +12,47 @@ To begin using ARA, you'll first need to set up Ansible so it knows about the the ARA :ref:`callback ` and, if necessary, the :ref:`ara_record ` and :ref:`ara_read ` modules. The callback and modules are bundled when installing ARA but you need to know -where they have been installed in order to let Ansible know where they are located. +where they have been installed in order to let Ansible know where they are +located. -.. tip:: +This location will be different depending on your operating system, how you are +installing ARA and whether you are using Python 2 or Python 3. - The location where ARA will be depends on your operating system and how it - is installed. - Here's some examples of where ARA can be found: +ARA ships a set of convenience Python modules to help you configure Ansible to +use it. - - ``/usr/lib/python2.7/site-packages/ara`` - - ``/usr/lib/python3.5/site-packages/ara`` - - ``$VIRTUAL_ENV/lib/python2.7/site-packages/ara`` +They can be used like so:: - If you're not sure where ARA will end up being installed, you can use this - snippet to print its location. It works in both Python 2 and Python 3:: + $ python -m ara.setup.path + /usr/lib/python2.7/site-packages/ara - python -c "import os,ara; print(os.path.dirname(ara.__file__))" + $ python -m ara.setup.action_plugins + /usr/lib/python2.7/site-packages/ara/plugins/actions + + $ python -m ara.setup.callback_plugins + /usr/lib/python2.7/site-packages/ara/plugins/callbacks + + $ python -m ara.setup.library + /usr/lib/python2.7/site-packages/ara/plugins/modules Using ansible.cfg ~~~~~~~~~~~~~~~~~ -Set up your `ansible.cfg`_ file to seek the callback and modules in the appropriate -directories:: +This sets up a new `ansible.cfg`_ file to load the callbacks and modules from +the appropriate locations:: - $ export ara_location=$(python -c "import os,ara; print(os.path.dirname(ara.__file__))") - $ cat > ansible.cfg <