AWSTemplateFormatVersion: 2010-09-09 Description: | AWS CloudFormation ELASTEST. Parameters: KeyName: Type: 'AWS::EC2::KeyPair::KeyName' Description: >- Specifies the name of an existing Amazon EC2 key pair to enable SSH access to the EC2 instances in your cluster. ConstraintDescription: Must be the name of an existing EC2 KeyPair. ElastestUsername: Type: String Description: A valid username to access Elastest Platform Default: elastest ElastestPassword: Type: String Description: A valid password for Elastest User Default: elastest NoEcho: true ElastestVersion: Type: String Description: Elastest version to deploy Default: latest ElastestMode: Type: String Description: >- ElasTest has two execution modes. Mini mode (default mode) and Single-node. Each of them increases the number of features offered by ElasTest from less to more. Default: mini AllowedValues: - mini - singlenode InstanceType: Description: Elastest Machine - EC2 instance type Type: String Default: m5.2xlarge AllowedValues: - a1.2xlarge - a1.4xlarge - c5.2xlarge - c5.4xlarge - c5.9xlarge - c5.18xlarge - c5d.2xlarge - c5d.4xlarge - c5d.9xlarge - c5d.18xlarge - r4.xlarge - m5.2xlarge - m5.4xlarge - m5.12xlarge - r5.2xlarge - r5.4xlarge - r5.12xlarge - r5.24xlarge - r5d.2xlarge - r5d.4xlarge - r5d.12xlarge - r5d.24xlarge ConstraintDescription: must be a valid EC2 instance type. SwapSize: Type: Number Description: >- It's known that ElasticSearch needs some swap space. This CloudFormation will create a swapfile in the instance to be used as swap space. Please set the size Default: 4 WantJenkins: Type: String Default: true Description: Do you want to use Jenkins CI with Elastest? AllowedValues: - true - false WantTestLink: Type: String Default: true Description: Do you want to use TestLink Project Manager with Elastest? AllowedValues: - true - false DiskSize: Type: Number Default: 50 Description: Disk size for data and everything else CustomDNS: Type: String Description: >- If you have a custom DNS name like elastest.mycompany.com or an ElasticIP you can write it down here. If not, leave this blank. Mappings: RegionMap: ap-south-1: AMI: ami-0ccfb82eb6753816c eu-west-3: AMI: ami-0d211c0630a27d535 eu-north-1: AMI: ami-0668e678 eu-west-2: AMI: ami-093e991c961466876 eu-west-1: AMI: ami-03066618d711c711f ap-northeast-2: AMI: ami-04e54d146a99b4902 ap-northeast-1: AMI: ami-0add9d820fddb4986 sa-east-1: AMI: ami-06334b62398fffc0f ca-central-1: AMI: ami-08920d280a9085846 ap-southeast-1: AMI: ami-021d3dcd4504ff87d ap-southeast-2: AMI: ami-043fd543a2f513317 eu-central-1: AMI: ami-014bdcadfd7487c3c us-east-1: AMI: ami-0a9a72fc61e9e5f59 us-east-2: AMI: ami-091500d5046adbdef us-west-1: AMI: ami-04d2b883688faa414 us-west-2: AMI: ami-07891ef972bbf5ae7 Resources: ElastestEC2Instance: Type: 'AWS::EC2::Instance' Metadata: Comment: "Install and configure Elastest Instance on EC2" AWS::CloudFormation::Init: config: files: "/etc/cfn/cfn-hup.conf": content: !Sub | [main] stack=${AWS::StackId} region=${AWS::Region} mode: "000400" owner: "root" group: "root" "/etc/cfn/hooks.d/cfn-auto-reloader.conf": content: !Sub | [cfn-auto-reloader-hook] triggers=post.update path=Resources.ElastestEC2Instance.Metadata.AWS::CloudFormation::Init action=/usr/local/bin/cfn-init -v --stack ${AWS::StackName} --resource ElastestEC2Instance --region ${AWS::Region} mode: "000400" owner: "root" group: "root" "/usr/local/bin/installDocker.sh": content: | #!/bin/bash -x set -eu -o pipefail curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable" apt-get update apt-get install -y docker-ce usermod -aG docker ubuntu mode: "000755" owner: "root" group: "root" "/usr/local/bin/createSwapSpace.sh": content: !Sub | #!/bin/bash -x set -eu -o pipefail fallocate -l ${SwapSize}G /swapfile chmod 600 /swapfile mkswap /swapfile swapon /swapfile echo '/swapfile none swap sw 0 0' >>/etc/fstab mode: "000755" owner: "root" group: "root" "/usr/local/bin/adjustMaxMapCount.sh": content: | #!/bin/bash -x set -eu -o pipefail echo vm.max_map_count=262144 >> /etc/sysctl.conf sysctl -w vm.max_map_count=262144 mode: "000755" owner: "root" group: "root" "/usr/local/bin/lauchElastest.sh": content: !Sub | #!/bin/bash -x set -eu -o pipefail if [ "${CustomDNS}" == "" ]; then PUBLIC_HOSTNAME=$(curl http://169.254.169.254/latest/meta-data/public-hostname) else PUBLIC_HOSTNAME=${CustomDNS} fi docker run \ -d \ --rm \ -v /etc/elastest:/data \ -v /var/run/docker.sock:/var/run/docker.sock \ elastest/platform:${ElastestVersion} start \ --server-address=$PUBLIC_HOSTNAME \ -u ${ElastestUsername} \ -p ${ElastestPassword} \ -m=${ElastestMode} \ $([ ${WantJenkins} == "true" ] && echo " --jenkins ") \ $([ ${WantTestLink} == "true" ] && echo " --testlink ") \ mode: "000755" owner: "root" group: "root" "/usr/local/bin/waitForElastest.sh": content: | #!/bin/bash -x sleep 1m ETM_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' elastest_etm_1) while [ "${ETM_IP}"x == "x" ]; do ETM_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' elastest_etm_1); sleep 1m; done while [ $(curl --output /dev/null --silent --head --fail --write-out "%{http_code}\\n" http://${ETM_IP}:8091/) != "200" ]; do echo "Waiting for elastest ETM..."; sleep 1m; done NGINX_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' elastest_etm-proxy_1) while [ $(curl --output /dev/null --silent --head --fail --write-out "%{http_code}\\n" http://${NGINX_IP}/) != "401" ]; do echo "Waiting for elastest ETM Proxy..."; sleep 1m; done mode: "000755" owner: "root" group: "root" "/usr/local/bin/setAfterBootEnv.sh": content: !Sub | #!/bin/bash if [ "${CustomDNS}" == "" ]; then cat >/usr/local/bin/elastest-start</usr/local/bin/elastest-start</usr/local/bin/elastest-stop</etc/systemd/system/elastest.service<