Created
August 21, 2018 18:25
-
-
Save astrobounce/6fb27116d9308080eb257b60e0680404 to your computer and use it in GitHub Desktop.
Helper Code to Launch Instances with Elasticsearch configured .
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
### 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