#cloud-config package_update: true package_upgrade: true packages: - apache2 write_files: - content: | #!/usr/bin/env python3 import optparse as op import os import shutil import subprocess def parseOptions(): """Parses command line options """ parser=op.OptionParser(usage="Usage: %prog USERNAME" ,version="%prog 1.0",description="Sets up Apache2 for the given USERNAME") #parse command line options return parser.parse_args() def replaceStrInFile(strMatch,strReplace,fileName): """Replace all occurrences of strMatch with strReplace in file fileName """ file=open(fileName,mode='r') fileText=file.read() file.close() fileText=fileText.replace(strMatch,strReplace) file=open(fileName,mode='w') file.write(fileText) file.close() def makePublicHtml(userName): """Creates the public html directory and index.html in the users home directory """ #make public html directory publicHtmlDir="/home/"+userName+"/public_html" try: os.makedirs(publicHtmlDir) except FileExistsError: pass #make place holder index file indexFileName=os.path.join(publicHtmlDir,"index.html") indexText="