示例#1
0
    def setUpClass(cls):
        """
        Call the main method of the ansible_runner_service script to Start
        the daemon normally
        """

        setup_dirs(['env', 'inventory', 'project', 'artifacts'])

        seed_dirs([
            ('./data/artifacts/53b955f2-b79a-11e8-8be9-c85b7671906d',
             './samples/artifacts/53b955f2-b79a-11e8-8be9-c85b7671906d'),
            ('./data/project/testplaybook.yml',
             './samples/project/testplaybook.yml')
        ])

        configuration.init("dev")
        cls.config = configuration.settings
        cls.app = main(test_mode=True)
示例#2
0
    def setUpClass(cls):
        """
        Call the main method of the ansible_runner_service script to Start
        the daemon normally
        """

        setup_dirs(['env', 'inventory', 'project', 'artifacts'])

        seed_dirs([
            ('./data/artifacts/53b955f2-b79a-11e8-8be9-c85b7671906d',
             './samples/artifacts/53b955f2-b79a-11e8-8be9-c85b7671906d'),
            ('./data/project/testplaybook.yml',
             './samples/project/testplaybook.yml')
        ])

        configuration.init("dev")
        cls.config = configuration.settings
        cls.app = main(test_mode=True)
        response = cls.app.get('/api/v1/login',
                               headers=get_auth_header('admin', 'admin'))

        assert response.status_code == 200, "Unable to get login token"

        cls.token = json.loads(response.data).get('data')['token']
    # setup ssl for the Flask http server
    ssl_context = get_ssl()

    app = create_app()

    if test_mode:
        app.config['TESTING'] = True
        app.config['WTF_CSRF_ENABLED'] = False
        return app.test_client()

    # Start the API server
    app.run(host=configuration.settings.ip_address,
            port=configuration.settings.port,
            threaded=True,
            ssl_context=ssl_context,
            debug=configuration.settings.debug,
            use_reloader=False)


if __name__ == "__main__":

    # setup signal handler for a kill/sigterm request (background mode)
    signal.signal(signal.SIGTERM, signal_stop)

    mode = get_mode()

    print("Starting ansible-runner-service")
    configuration.init(mode=mode)

    main()
示例#4
0
import runner_service.configuration as configuration
from runner_service.app import create_app
from ansible_runner_service import setup_common_environment, remove_artifacts_init
"""
WSGI config for Ansible Runner Service

It exposes the WSGI callable as a module-level variable named ``application``.

"""

# wsgi entry point is only for production servers
configuration.init(mode='prod')

# Setup log and ssh and other things present in all the environments
setup_common_environment()

# Setup remove of artifacts
remove_artifacts_init()

# The object to be managed by uwsgi
application = create_app()
def main():

    setup_logging()

    logging.info("Run mode is: {}".format(configuration.settings.mode))

    ssl_context = get_ssl()

    app = create_app()

    # Start the API server
    app.run(host=configuration.settings.ip_address,
            port=configuration.settings.port,
            threaded=True,
            ssl_context=ssl_context,
            debug=True,
            use_reloader=False)


if __name__ == "__main__":

    # setup signal handler for a kill/sigterm request (background mode)
    signal.signal(signal.SIGTERM, signal_stop)

    mode = get_mode()

    print("Starting ansible-runner-service")
    configuration.init(mode=mode)

    main()