Skip to content

Instantly share code, notes, and snippets.

@astrobounce
Created August 21, 2018 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astrobounce/6fb27116d9308080eb257b60e0680404 to your computer and use it in GitHub Desktop.
Save astrobounce/6fb27116d9308080eb257b60e0680404 to your computer and use it in GitHub Desktop.
Helper Code to Launch Instances with Elasticsearch configured .
### Sample Helper Code to Launcg Elasticsearch cluster preconfigured Instance
from troposphere import Ref, Join
from troposphere import autoscaling, policies, Base64
from magicdict import MagicDict
class EC2_MASTER(MagicDict):
def __init__(self, parameters):
super(EC2_MASTER, self).__init__()
self.launch_configuration = autoscaling.LaunchConfiguration(
"LaunchConfiguration",
Metadata={
"AWS::CloudFormation::Init": {
"configSets": {
"elastic_install": ["create_lvm","install_elastic_repo","install_elasticsearch"]
},
"create_lvm": {
"commands": {
"01_pvcreate": {
"command": "pvcreate /dev/xvdf"
},
"02_vgcreate": {
"command": "vgcreate data /dev/xvdf"
},
"03_lvcreate": {
"command": "lvcreate -n data -l 100%FREE data"
},
"04_mkfs": {
"command": "mkfs.ext4 /dev/data/data"
},
"05_mkdir": {
"command": "mkdir /data"
},
"06_fstab": {
"command": 'echo "/dev/data/data /data ext4 defaults 0 2" >> /etc/fstab'
},
"07_mount": {
"command": "mount -a"
}
}
},
// Some more secret code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment