Skip to content

Commit eec05ff

Browse files
authored
2.1.1 - Documentation improvements (#15)
* pom.xml * Bumped pom to 2.1.0 * pom.xml, publish-maven-package.yml * Added profiles * NginxFileServer.groovy * Fixed bug in FileServerConfig which breaks creation of subdirectories * Mainly working on documentation in README.md * Basic JSM Setup.groovy, JsmH2Deployment.groovy * Improved documentation and comments * Bumped pom to 2.1.1
1 parent 4491bd1 commit eec05ff

11 files changed

Lines changed: 108 additions & 23 deletions

File tree

.gitignore

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/target/
22
/.idea/vcs.xml
3-
/Environments/Terraform/.terraform/
4-
/Environments/Terraform/.terraform.lock.hcl
5-
/Environments/Terraform/.terraform.tfstate.lock.info
6-
/Environments/Terraform/terraform.tfstate
7-
/Environments/Terraform/terraform.tfstate.backup
3+
/Environments/AWS/.terraform/
4+
/Environments/AWS/.terraform.lock.hcl
5+
/Environments/AWS/.terraform.tfstate.lock.info
6+
/Environments/AWS/terraform.tfstate
7+
/Environments/AWS/terraform.tfstate.backup
File renamed without changes.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ variable "aws_credentials" {
2525
variable "dockerServerCert" {
2626
type = map(string)
2727
default = {
28-
"tlscacert" = "../../resources/dockerCert/ca.pem"
29-
"tlscert" = "../../resources/dockerCert/server-cert.pem"
30-
"tlskey" = "../../resources/dockerCert/server-key.pem"
28+
"tlscacert" = "~/.docker/ca.pem"
29+
"tlscert" = "~/.docker/server-cert.pem"
30+
"tlskey" = "~/.docker/server-key.pem"
3131
}
3232

3333
}

README.md

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,64 @@
1+
# DevStack
12

3+
DevStack is intended for the DevOps engineer who finds her/him self constantly jumping between different DevOps enterprise tools to deliver new solutions.
24

3-
## Setup of test Environment
5+
DevStack gives you simple to reuse groovy classes for spinning up new test environments in a local or remote docker engine and automates the basic setup of the individual tool.
46

5-
//TODO add info about license files
7+
## What does it really do?
68

7-
1. Setup certs in resources/dockerCert
9+
DevStack creates local or remote docker containers, sets up docker level networking, spins up the container with sensible settings and configures the basic settings needed inside the tool to get it up and running.
10+
11+
Example: [JsmAndBitbucketH2Deployment.groovy](src%2Fmain%2Fgroovy%2Fcom%2Feficode%2Fdevstack%2Fdeployment%2Fimpl%2FJsmAndBitbucketH2Deployment.groovy)
12+
13+
This class will help you spin up JIRA and Bitbucket containers in the same docker network, configure sensible JAVA environment variables, setup DBs for both applications, install JIRA apps and create an Application Link between them.
14+
15+
## Pros/Cons
16+
17+
### Pro
18+
* Facilitate testing of complex setups
19+
* Got a complex flow involving Jira, Bitbucket, Jenkins, Harbor and now you are afraid of upgrading?
20+
* Integrate DevStack in your Spock test, configure it to spin up a mirror of your environment and the flow. Tweak the version used and run your test.
21+
* Takes over after Docker has done its thing.
22+
* Docker is great for starting an application like JIRA but then it´s up to you (or DevStack) to setup, DB, Apps, Admin accounts, licenses.
23+
* Move away from Snowflake test environments, test your changes in fresh environments every time.
24+
* DevStack can use local or remote Docker engines, making running the tests locally on your machine easy while still offloading the heavy lifting to a cloud Docker Engine.
25+
26+
### Cons
27+
* DevStack is not intended for production use ever, it should only be used for short-lived test environments with nothing to loose.
28+
* Not intended for existing environments, presumes DevStack was used to setup up the environment.
29+
30+
# Setup Docker Engine in AWS
31+
32+
DevStack defaults to trying to connect to a local Docker engine, but a terraform project is supplied for setting up a remote EC2 with docker engine. The docker engine will be configured to only accept HTTPS from your IP.
33+
34+
### Requirements:
35+
* An AWS account with no vital data
36+
* With corresponding Access and Secret key: [Check guide](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html#Using_CreateAccessKey)
37+
* CA, Server and Client certs
38+
* This script can be used for generating the Certs: [createCerts](https://gist.github.com/farthinder/9df3019e2e01cdd167dd02abf7d5f903)
39+
* SSH Keys
40+
41+
1. Setup Docker Engine certs in ~/.docker/
842
* ca.pem: A ca cert that signed the other certs
9-
* cert.pem & key.pem: Public and private keys to be used by docker client
10-
* server-cert.pem & server-key.pem: Public and private keys to be used by docker server. Should be setup for domain name: docker.domain.se
43+
* server-cert.pem & server-key.pem: Public and private keys to be used by docker server. By convention DevStack uses: docker.domain.se, but anything is fine aslong as you can put it in your hosts file.
44+
* ~/.docker/ is the default place but can be changed in [variables.tf](Environments%2FAWS%2Fvariables.tf)
45+
46+
2. Setup Docker Client certs in ~/.docker/
47+
* ca.pem: A ca cert that signed the other certs (same as in step 1)
48+
* cert.pem & key.pem: Public and private keys to be used by docker client
49+
* The ~/.docker/ location is arbitrary and ultimately determined by you when you instantiate DevStack classes.
1150

12-
2. Set up an AWS account with high (admin) privileges in an ISOLATED test account *WITH NO VITAL SETUPS*
51+
3. Set up an AWS account with high (admin) privileges in an ISOLATED test account *WITH NO VITAL DATA*
1352
* Get Access Key and Secret Key for the account
14-
* Update *aws_credentials* in Environments/Terraform/variables.tf
53+
* Update *aws_credentials* in Environments/AWS/variables.tf
1554

16-
3. Make sure you have a valid public SSH key in ~/.ssh/id_rsa.pub
17-
* Or update *ssh-public-key-local-path* in Environments/Terraform/variables.tf
55+
4. Make sure you have a valid public SSH key in ~/.ssh/id_rsa.pub
56+
* Or update *ssh-public-key-local-path* in Environments/AWS/variables.tf
1857

19-
4. Update *trusted-external-ips* in Environments/Terraform/variables.tf
58+
5. Update *trusted-external-ips* in Environments/AWS/variables.tf
2059
* This should normally be set to your external ip, check for example: https://whatismyipaddress.com
2160

22-
5. Go to Environments/Terraform and run terraform apply
61+
6. Go to Environments/Terraform and run terraform apply
2362
* Note the "Hosts-record" output, this needs to be added to your /etc/hosts
2463

2564

examples/Basic JSM Setup.groovy

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ import com.eficode.devstack.deployment.impl.JsmH2Deployment
22

33
String jiraBaseUrl = "http://localhost:8080"
44
JsmH2Deployment jsmDep = new JsmH2Deployment(jiraBaseUrl)
5-
File projectRoot = new File(".")
5+
File projectRoot = new File("../").canonicalFile
6+
7+
//Set JSM license that should be used
68
jsmDep.setJiraLicense(new File(projectRoot.path + "/resources/jira/licenses/jsm.license"))
9+
10+
//Optional settings
11+
//jsmDep.jsmContainer.containerImageTag = "5.5.1" //Set docker image (and JSM) version
12+
//jsmDep.jsmContainer.containerName = "Testing" //Set custom container name
13+
//jsmDep.jsmContainer.jvmMaxRam = 4000 //Set max ram used by JSM
14+
//jsmDep.appsToInstall = ["https://marketplace.atlassian.com/download/apps/6820/version/1005740":new File(projectRoot.path + "/resources/jira/licenses/scriptrunnerForJira.license").text]
15+
16+
jsmDep.stopAndRemoveDeployment()
17+
718
jsmDep.setupDeployment()

pom.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.eficode</groupId>
88
<artifactId>devstack</artifactId>
9-
<version>2.1.0-SNAPSHOT-groovy-${revision}</version>
9+
<version>2.1.1-SNAPSHOT-groovy-${revision}</version>
1010
<packaging>jar</packaging>
1111

1212
<name>DevStack - Parent pom</name>
@@ -176,7 +176,9 @@
176176

177177
<exclude>com.google.code.gson:gson</exclude>
178178
<exclude>org.apache.httpcomponents</exclude>
179-
<exclude>commons-*</exclude>
179+
180+
<!--exclude>commons-*</exclude--> <!--Seems to break JenkinsAndHarborDeployment.groovy:103, needs org/apache/commons/io/FileUtils-->
181+
180182
<exclude>com.kohlschutter.junixsocket:junixsocket-core</exclude>
181183

182184
</excludes>

src/main/groovy/com/eficode/devstack/deployment/impl/HarborDeployment.groovy

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ class HarborDeployment implements Deployment {
3131
this.containers.find { it instanceof HarborManagerContainer } as HarborManagerContainer
3232
}
3333

34+
35+
/**
36+
* Returns the IP of the container listening on the private port 8080, ie the main frontend container IP
37+
* @return
38+
*/
39+
String getFrontendContainerIp() {
40+
41+
ContainerSummary harborNginxC = harborContainers.find {it.ports.privatePort.contains(8080)}
42+
43+
String harborNginxIp = harborNginxC?.networkSettings?.networks?.values()?.ipAddress?.first()
44+
45+
return harborNginxIp
46+
47+
}
48+
3449
@Override
3550
boolean setupDeployment() {
3651

src/main/groovy/com/eficode/devstack/deployment/impl/JsmH2Deployment.groovy

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ import com.eficode.devstack.deployment.Deployment
77
import org.slf4j.Logger
88
import org.slf4j.LoggerFactory
99

10+
/**
11+
* Sets up a JSM deployment,
12+
* creates a local H2 database,
13+
* configures JSM license and admin account (admin/admin)
14+
* installs optional marketplace apps and their licenses.
15+
*
16+
*
17+
* Before running setupDeployment() make sure to setJiraLicense() and optionally populate setAppsToInstall (ex: [https:marketplace....:AAbbv1223cc...])
18+
*
19+
* Container name will be derived from the supplied jiraBaseUrl, but can be overridden before creation with: jsmH2Deployment.jsmContainer.containerName = "Something"
20+
*/
21+
1022
class JsmH2Deployment implements Deployment{
1123

1224
String friendlyName = "JIRA H2 Deployment"
@@ -18,6 +30,12 @@ class JsmH2Deployment implements Deployment{
1830

1931
String jiraBaseUrl
2032

33+
/**
34+
* Sets up a JSM Deployment
35+
* @param jiraBaseUrl The full base url where JIRA should be reached (ex: http://jira.domain.se:8080)
36+
* @param dockerHost An optional docker host, when not using local Docker Engine (ex: https://docker.domain.se:2376)
37+
* @param dockerCertPath folder containing ca.pem, and the client cert: cert.pem, key.pem (ex: ~/.docker/")
38+
*/
2139
JsmH2Deployment(String jiraBaseUrl, String dockerHost = "", String dockerCertPath = "") {
2240
this.jiraBaseUrl = jiraBaseUrl
2341
this.jiraRest = new JiraInstanceManagerRest(jiraBaseUrl)

0 commit comments

Comments
 (0)