forked from redhatstuart/Ansiblefest2020
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stuart R. Kirk
committed
Oct 11, 2020
1 parent
bf3f14a
commit 15d95ef
Showing
226 changed files
with
170,519 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
apiVersion: apps/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: mssql-deployment | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: mssql | ||
spec: | ||
terminationGracePeriodSeconds: 10 | ||
containers: | ||
- name: mssql | ||
image: mcr.microsoft.com/mssql/server:2017-latest | ||
ports: | ||
- containerPort: 1433 | ||
env: | ||
- name: MSSQL_PID | ||
value: "Developer" | ||
- name: ACCEPT_EULA | ||
value: "Y" | ||
- name: SA_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: mssql | ||
key: SA_PASSWORD | ||
volumeMounts: | ||
- name: mssqldb | ||
mountPath: /var/opt/mssql | ||
volumes: | ||
- name: mssqldb | ||
persistentVolumeClaim: | ||
claimName: mssql-data | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: mssql-deployment | ||
spec: | ||
selector: | ||
app: mssql | ||
ports: | ||
- protocol: TCP | ||
port: 1433 | ||
targetPort: 1433 | ||
type: LoadBalancer | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
kind: StorageClass | ||
apiVersion: storage.k8s.io/v1beta1 | ||
metadata: | ||
name: azure-disk | ||
provisioner: kubernetes.io/azure-disk | ||
parameters: | ||
storageaccounttype: Standard_LRS | ||
kind: Managed | ||
--- | ||
kind: PersistentVolumeClaim | ||
apiVersion: v1 | ||
metadata: | ||
name: mssql-data | ||
annotations: | ||
volume.beta.kubernetes.io/storage-class: azure-disk | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 8Gi |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# 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/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
|
||
# 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 | ||
|
||
# dotenv | ||
.env | ||
|
||
# virtualenv | ||
.venv | ||
venv/ | ||
ENV/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"scriptFile": "main.py", | ||
"bindings": [ | ||
{ | ||
"name": "myblob", | ||
"type": "blobTrigger", | ||
"direction": "in", | ||
"path": "samples-workitems/{name}", | ||
"connection":"AzureWebJobsStorage" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import logging | ||
|
||
import azure.functions as func | ||
|
||
def main(myblob: func.InputStream): | ||
logging.info(f"Python blob trigger function processed blob \n" | ||
f"Name: {myblob.name}\n" | ||
f"Blob Size: {myblob.length} bytes") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# BlobTrigger | ||
|
||
The `BlobTrigger` makes it incredibly easy to react to new Blobs inside of Azure Blob Storage. This sample demonstrates a simple use case of processing data from a given Blob. | ||
|
||
## How it works | ||
|
||
For a `BlobTrigger` to work, you provide a path which dictates where the blobs are located inside your container, and can also help restrict the types of blobs you wish to return. For instance, you can set the path to `samples/{name}.png` to restrict the trigger to only the samples path and only blobs with ".png" at the end of their name. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Cosmos DB Trigger | ||
A function that will be run whenever documents change in a document collection. | ||
|
||
## How it works | ||
This template shows a Cosmos DB trigger binding in the function.json file and a Python function that uses that binding. The function writes log messages when Cosmos DB records are modified. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import logging | ||
|
||
import azure.functions as func | ||
|
||
|
||
def main(documents: func.DocumentList) -> str: | ||
if documents: | ||
logging.info('Document id: %s', documents[0].id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"type": "cosmosDBTrigger", | ||
"name": "documents", | ||
"direction": "in", | ||
"leaseCollectionName": "leases" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM mcr.microsoft.com/azure-functions/python:2.0 | ||
|
||
ENV host:logger:consoleLoggingMode=always | ||
|
||
COPY . /home/site/wwwroot | ||
|
||
RUN cd /home/site/wwwroot && pip install -r requirements.txt | ||
RUN pip install ansible[azure] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"scriptFile": "main.py", | ||
"bindings": [ | ||
{ | ||
"authLevel": "anonymous", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "req" | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "$return" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import logging | ||
import azure.functions as func | ||
import subprocess | ||
import json | ||
|
||
def main(req: func.HttpRequest) -> func.HttpResponse: | ||
logging.info('Python HTTP trigger function processed a request.') | ||
|
||
subscription_id = req.params.get('subscription_id') | ||
tenant = req.params.get('tenant') | ||
secret = req.params.get('secret') | ||
client = req.params.get('client_id') | ||
|
||
body = req.get_body() | ||
|
||
f = open("./playbook.yml", "wb") | ||
f.write(body) | ||
f.close() | ||
|
||
cmd = "export AZURE_CLIENT_ID=" + client + "; " | ||
cmd += "export AZURE_SECRET=" + secret + "; " | ||
cmd += "export AZURE_SUBSCRIPTION_ID=" + subscription_id + "; " | ||
cmd += "export AZURE_TENANT=" + tenant + "; " | ||
cmd += "ansible-playbook ./playbook.yml" | ||
|
||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) | ||
output, error = process.communicate() | ||
|
||
# output = cmd | ||
# error = "no error" | ||
try: | ||
x = json.dumps({ 'output': str(output), 'error': str(error) }) | ||
#if len(str(output) + str(error)) > 0: | ||
# return func.HttpResponse("XXXXXX", headers={"Access-Control-Allow-Origin": "*"}) | ||
#else: | ||
# return func.HttpResponse("YYYYYY", headers={"Access-Control-Allow-Origin": "*"}) | ||
return func.HttpResponse(x, headers={"Access-Control-Allow-Origin": "*"}) | ||
|
||
except Exception as e: | ||
return func.HttpResponse("EXCEPTION", headers={"Access-Control-Allow-Origin": "*"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# HttpTrigger | ||
|
||
The `HttpTrigger` makes it incredibly easy to have your functions executed via an HTTP call to your function. | ||
|
||
## How it works | ||
|
||
When you call the function, be sure you checkout which security rules you apply. If you're using an apikey, you'll need to include that in your request. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"scriptFile": "main.py", | ||
"bindings": [ | ||
{ | ||
"name": "msg", | ||
"type": "queueTrigger", | ||
"direction": "in", | ||
"queueName": "samplequeue", | ||
"connection":"AzureWebJobsStorage" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import logging | ||
|
||
import azure.functions as func | ||
|
||
|
||
def main(msg: func.QueueMessage) -> None: | ||
logging.info('Python queue trigger function processed a queue item: %s', | ||
msg.get_body().decode('utf-8')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# QueueTrigger | ||
|
||
The `QueueTrigger` makes it incredibly easy to react to new Queues inside of Azure Queue Storage. This sample demonstrates a simple use case of processing data from a given Queue. | ||
|
||
## How it works | ||
|
||
For a `QueueTrigger` to work, you provide a path which dictates where the queue messages are located inside your container. |
Oops, something went wrong.