.gitignore | ●●●●● patch | view | raw | blame | history | |
README.md | ●●●●● patch | view | raw | blame | history | |
playbooks/.gitignore | ●●●●● patch | view | raw | blame | history | |
playbooks/install.yml | ●●●●● patch | view | raw | blame | history | |
playbooks/inventory.ini | ●●●●● patch | view | raw | blame | history | |
playbooks/requirements.yml | ●●●●● patch | view | raw | blame | history | |
playbooks/vars/RedHat.yml | ●●●●● patch | view | raw | blame | history | |
requirements.txt | ●●●●● patch | view | raw | blame | history | |
server.py | ●●●●● patch | view | raw | blame | history | |
test/test.yml | ●●●●● patch | view | raw | blame | history | |
wsgi.py | ●●●●● patch | view | raw | blame | history |
.gitignore
New file @@ -0,0 +1,105 @@ # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover .hypothesis/ .pytest_cache/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # Jupyter Notebook .ipynb_checkpoints # pyenv .python-version # celery beat schedule file celerybeat-schedule # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ README.md
@@ -1,2 +1,9 @@ # provisioner-api Status reporting API for provisioning classrooms # Sample API for report application status via JSON document This API has two endpoints: * healthz returns 200 and json string indicating health of API * status returns 200 + json doc if it can find a given JSON document returns 404 if it cannot find the document playbooks/.gitignore
New file @@ -0,0 +1 @@ roles playbooks/install.yml
New file @@ -0,0 +1,48 @@ --- - hosts: bastions become: yes tasks: - name: Create application folder file: name: "/opt/status/src" state: directory - name: Copy application files copy: dest: "/opt/status/src/{{ item }}" src: "../{{ item }}" owner: "{{ ansible_user }}" mode: 0644 with_items: - requirements.txt - server.py - wsgi.py - name: Create folder file: name: "{{item}}" state: directory owner: "{{ansible_user}}" group: nginx with_items: - /opt/status/run - /opt/status/log - name: Fix selinux context for nginx access shell: | semanage fcontext -a -t httpd_sys_rw_content_t "{{item}}(/.*)?" restorecon -R -v "{{item}}" with_items: - /opt/status/run - /opt/status/log - name: Install python virtualenv pip: name: virtualenv - name: Install python application as a service include_role: name: Stouts.wsgi vars: python_enabled: false wsgi_group: nginx wsgi_applications: - name: status server: gunicorn module: wsgi pip_requirements: requirements.txt playbooks/inventory.ini
New file @@ -0,0 +1,2 @@ [bastions] bastion.33cc33cc.do417.dev.nextcle.com ansible_ssh_private_key_file=~/.ssh/glsdev ansible_user=ec2-user playbooks/requirements.yml
New file @@ -0,0 +1,8 @@ # This is the Ansible Galaxy requirements file to pull in the correct roles # to support the operation of CASL provisioning/runs. # and also support any role dependency while using the repository in Ansible Tower # From 'Stouts.wsgi' - src: https://github.com/Stouts/Stouts.wsgi version: 2.1.4 playbooks/vars/RedHat.yml
New file @@ -0,0 +1,3 @@ --- wsgi_service: systemd requirements.txt
New file @@ -0,0 +1,3 @@ Flask==1.0.2 gunicorn==19.9.0 requests==2.6.0 server.py
New file @@ -0,0 +1,31 @@ #!/usr/bin/python from flask import Flask, request, jsonify, make_response import requests import os.path import json application = Flask(__name__) @application.route('/api/provision/v1/healthz') def healthz(): return make_response(jsonify({"health": "ok"}), 200) @application.route('/api/provision/v1/status') def status(): if os.path.exists('/tmp/provision_report.json'): with open('/tmp/provision_report.json') as json_file: data = json.load(json_file) return make_response(jsonify(data), 200) return make_response(jsonify({"status": "unknown"}), 404) @application.route('/api/provision/v1/report', methods=['POST']) def report(): with open('/tmp/provision_report.json', 'w') as json_file: json.dump(request.json, json_file) return make_response("", 200) if __name__ == '__main__': application.run(host='127.0.0.1') test/test.yml
New file @@ -0,0 +1,14 @@ --- - hosts: localhost connection: local become: false tasks: - name: Send start status uri: url: http://bastion.33cc33cc.do417.dev.nextcle.com/api/provision/v1/report method: POST body_format: json body: status: "allocating infrastructure" status_code: - 200 wsgi.py
New file @@ -0,0 +1,4 @@ from server import application if __name__ == "__main__": application.run()