Skip to content

Instantly share code, notes, and snippets.

View appScriptSnippet.py
if querystring != None:
url = 'http://{{ grains['databaseServer'] }}/cgi-bin/database.py?querystring=' + querystring
else:
url = 'http://{{ grains['databaseServer'] }}/cgi-bin/database.py'
View appServerCT.yaml
cloudConfig: |
#cloud-config
preserve-hostname: false
hostname: ${self.resourceName}.corp.local
runcmd:
- curl -L https://bootstrap.saltstack.com -o install_salt.sh
- sudo sh install_salt.sh -A ${propgroup.SaltStackConfiguration.masterAddress}
- sudo salt-call grains.set serverRole app
- sudo salt-call grains.set databaseServer ${resource.database_Server_1.networks.address[0]}
- sudo salt-call state.highstate
View appScript.py
#!/usr/bin/python
import os, sys, cgi
import requests
print "Content-type:text/html\n\n";
print "<head><title>Company Phone Directory</title></head>\n"
print "<body>\n"
print "<h1>Directory Lookup</h1>\n"
remote = os.getenv("REMOTE_ADDR")
form = cgi.FieldStorage()
View app.sls
# Install packages and configuration for 2tier-app app server role
installAppRolePackages:
pkg.installed:
- pkgs:
- python
- httpd
- epel-release
- python-pip
- policycoreutils-python
View dbAppScript.py
#! /usr/bin/python
import cgi
import sqlite3
conn=sqlite3.connect('/var/www/db/directory.db')
curs=conn.cursor()
print "Content-type:text/plain\n\n";
form = cgi.FieldStorage()
querystring = form.getvalue("querystring")
if querystring != None:
View database.sls
# Install packages and configuration for 2tier-app database role
installDbRolePackages:
pkg.installed:
- pkgs:
- python
- httpd
startApache:
service.running: