We use ansible to setup our main server which runs:
- Tomcat for the demos
- Ngnix as a proxy
- Overview of all demos: http://demo.scenarioo.org/overview
To test and run this ansible playbook locally you need to install:
- Vagrant >= 2.0
- VirtualBox >= 6.0
Start and setup the dev VM with: vagrant up
To deploy the demo server execute: ./infra.sh runAnsible vagrant
And browse to: http://localhost:8080
The CLI tool infra.sh
is used to manage demos and run ansible:
./infra.sh deployDemo <branchName> <buildNumber> <triggeredBy> <pullrequestURL> <pullrequestNumber>
./infra.sh undeployDemo <branchName>
./infra.sh runAnsible <vagrant|aws|demoserver> <pathToAlternativeSSHKey>
./infra.sh updateOverview
./infra.sh cleanupDemos
There are some tests that ensure the generated branch config JSONs are correct, for more info look at tests/Readme.md
Configuration is done in config.json
and under demos/<branch>.json
.
config.json
defaultScenariooBranch
: Branch we redirect to by default on demo.scenarioo.orgdemoConfigFolder
: Where are the config files for demos (useful to change for testing)maxBuildsPerDemo
: Limit the number of builds we keep for each demomaxConcurrentDemos
: Limit the number of demos running in parallel (first in, first out)persistentBranches
: List of demo branches that will not be removed => used for master and developscenariooDocuFolder
: Where to store scenarioo docu for each branchscenariooHost
: Usually demo.scenarioo.org, can be changed for testingtomcatFolder
: Tomcat base folder
demos/.json: For each demo branch
{
"branchName": "feature-755-investigate-building-docker-image",
"timestamp": "1540117349",
"buildNumber": "117",
"triggeredBy": "cgrossde",
"pullRequestUrl": "https://github.com/scenarioo/scenarioo/pull/773",
"pullRequestNumber": "773",
"buildUrl": "https://circleci.com/gh/scenarioo/scenarioo/117",
"warArtifact": "https://117-10269178-gh.circle-artifacts.com/0/scenarioo.war",
"warArtifactSha256": "ad5ca926cc3bc8213635643f549ded7c393bc53630ea58f1cb3387e5c3418932",
"docuArtifacts": [
{
"url": "https://116-10269178-gh.circle-artifacts.com/0/e2eScenariooDocu.zip",
"sha256": "b049f4e39ea841bbe92452f026f0fb7100de19a671b298d12dd716d2354b79b3",
"build": "116"
}
]
}
Ansible relies on the following environment vars when executed:
TOMCAT_USER_PASSWORD
: Used to secure the publish scenarioo docu endpoint. Defaults to: 'scenarioo' and user is always 'scenarioo'.CIRCLE_TOKEN
: Used to download WAR and scenarioo docu artifacts from CircleCICONFIG_FILE
: Optional. Allows to pass in a different config for testing. Defaults toconfig.json
CircleCI: Set these environment variables in the organsation context "scenarioo"
- https://circleci.com/gh/organizations/scenarioo/settings#contexts
- Create
CIRCLE_TOKEN
here: https://circleci.com/gh/scenarioo/scenarioo/edit#api
Tomcat:
/var/lib/tomcat8/webapps
/var/lib/tomcat8/logs
/var/lib/tomcat8/conf
/usr/share/tomcat8/bin
Nginx:
/etc/nginx/sites-enabled
Scenarioo:
/scenarioo/overviewpage
/scenarioo/data/<branchName>
To get the most out of the box without running into Java OutOfMemoryExceptions we need to keep an eye on memory:
- System: 1GB
- Elasticsearch: 0.8GB (500MB Java + docker overhead) see
roles/docker/tasks/main.yml
- Tomcat: 6GB (1GB per demo is a good measure) see
roles/tomcat/files/setenv.sh
If you would like to deploy a server on AWS (see hosts/hosts_aws
) or the demo server directly (hosts/hosts_demoserver_ovh
),
you can use the dockerized ansible.
Build docker image first:
docker build -t docker-ansible-runner docker-ansible-runner
Then execute: ./infra.sh runAnsible aws
You can also provide an alternative ssh key like this: ./infra.sh runAnsible aws ./.ssh/my_aws_ssh_key