Skip to content

Commit

Permalink
Expand recipe to support containerized and standalone Jboss/Wildfly a…
Browse files Browse the repository at this point in the history
…pp servers (#631)
  • Loading branch information
mbruzina authored Feb 3, 2022
1 parent 76c9ca9 commit 1668280
Show file tree
Hide file tree
Showing 20 changed files with 733 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
node_modules
.DS_Store
recipes/.prettierrc
*.war
*.war
177 changes: 126 additions & 51 deletions recipes/newrelic/apm/java/linux.yml

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions test/definitions-eu/apm/java/deb10-sysd-jboss.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"global_tags": {
"owning_team": "OpenSource",
"Environment": "development",
"Department": "Product",
"Product": "Virtuoso"
},
"resources": [
{
"id": "jboss",
"display_name": "AwsDebianInfraJavaInstallHost",
"provider": "aws",
"type": "ec2",
"size": "t2.micro",
"ami_name": "debian-10-amd64-2020????-???-*",
"user_name": "admin"
}
],
"services": [
{
"id": "java1",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/jboss/systemd/install/linux/roles",
"port": 6001,
"destinations": ["jboss"]
}
],
"instrumentations": {
"resources": [
{
"id": "jbossRecipe",
"resource_ids": [
"jboss"
],
"provider": "newrelic",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/newrelic-cli/install-recipe/roles",
"params": {
"recipe_content_url": "https://raw.githubusercontent.com/newrelic/open-install-library/main/recipes/newrelic/apm/java/linux.yml",
"validate_output": "New Relic installation complete"
}
},
{
"id": "recipeValidation",
"resource_ids": [
"jboss"
],
"provider": "newrelic",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/newrelic-cli/validate-recipe/roles",
"params": {
"nrql_query": "Select count(*) from ApplicationAgentContext where agent.language='java' and host like '%HOSTNAME%' since 5 minutes ago"
}
}
]
}
}
57 changes: 57 additions & 0 deletions test/definitions-eu/apm/java/rhl2-sysd-jboss.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"global_tags": {
"owning_team": "OpenSource",
"Environment": "development",
"Department": "Product",
"Product": "Virtuoso"
},
"resources": [
{
"id": "jboss",
"display_name": "AwsLinux2InfraJavaInstallHost",
"provider": "aws",
"type": "ec2",
"size": "t2.micro",
"ami_name": "amazonlinux-2-base*",
"user_name": "ec2-user"
}
],
"services": [
{
"id": "java1",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/jboss/systemd/install/linux/roles",
"port": 6001,
"destinations": ["jboss"]
}
],
"instrumentations": {
"resources": [
{
"id": "jbossRecipe",
"resource_ids": [
"jboss"
],
"provider": "newrelic",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/newrelic-cli/install-recipe/roles",
"params": {
"recipe_content_url": "https://raw.githubusercontent.com/newrelic/open-install-library/main/recipes/newrelic/apm/java/linux.yml",
"validate_output": "New Relic installation complete"
}
},
{
"id": "recipeValidation",
"resource_ids": [
"jboss"
],
"provider": "newrelic",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/newrelic-cli/validate-recipe/roles",
"params": {
"nrql_query": "Select count(*) from ApplicationAgentContext where agent.language='java' and host like '%HOSTNAME%' since 5 minutes ago"
}
}
]
}
}
66 changes: 66 additions & 0 deletions test/definitions-eu/apm/java/rhl2-yum-docker-jboss.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"global_tags": {
"owning_team": "OpenSource",
"Environment": "development",
"Department": "Product",
"Product": "Virtuoso"
},
"resources": [{
"id": "dockerjboss",
"display_name": "AwsLinux2InfraJavaInstallHost",
"provider": "aws",
"type": "ec2",
"size": "t2.micro",
"ami_name": "amazonlinux-2-base*",
"user_name": "ec2-user"
}],
"services": [
{
"id": "docker",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/docker/install/aws-linux2/roles",
"port": 9999,
"destinations": [
"dockerjboss"
]
},
{
"id": "jboss",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/jboss/docker/linux/noApp/roles",
"port": 9090,
"destinations": [
"dockerjboss"
]
}
],
"instrumentations": {
"resources": [
{
"id": "jbossRecipe",
"resource_ids": [
"dockerjboss"
],
"provider": "newrelic",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/newrelic-cli/install-recipe/roles",
"params": {
"recipe_content_url": "https://raw.githubusercontent.com/newrelic/open-install-library/main/recipes/newrelic/apm/java/linux.yml",
"validate_output": "New Relic installation complete"
}
},
{
"id": "recipeValidation",
"resource_ids": [
"dockerjboss"
],
"provider": "newrelic",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/newrelic-cli/validate-recipe/roles",
"params": {
"nrql_query": "Select count(*) from ApplicationAgentContext where agent.language='java' and host like '%CONTAINERID%' since 15 minutes ago"
}
}
]
}
}
65 changes: 65 additions & 0 deletions test/definitions-eu/apm/java/ub20-apt-docker-jboss.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"global_tags": {
"owning_team": "OpenSource",
"Environment": "development",
"Department": "Product",
"Product": "Virtuoso"
},
"resources": [{
"id": "dockerjboss",
"provider": "aws",
"type": "ec2",
"size": "t2.medium",
"ami_name": "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-????????.1",
"user_name": "ubuntu"
}],
"services": [
{
"id": "docker",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/docker/install/debian/roles",
"port": 9999,
"destinations": [
"dockerjboss"
]
},
{
"id": "jboss",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/jboss/docker/debian/noApp/roles",
"port": 9090,
"destinations": [
"dockerjboss"
]
}
],
"instrumentations": {
"resources": [
{
"id": "jbossRecipe",
"resource_ids": [
"dockerjboss"
],
"provider": "newrelic",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/newrelic-cli/install-recipe/roles",
"params": {
"recipe_content_url": "https://raw.githubusercontent.com/newrelic/open-install-library/main/recipes/newrelic/apm/java/linux.yml",
"validate_output": "New Relic installation complete"
}
},
{
"id": "recipeValidation",
"resource_ids": [
"dockerjboss"
],
"provider": "newrelic",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/newrelic-cli/validate-recipe/roles",
"params": {
"nrql_query": "Select count(*) from ApplicationAgentContext where agent.language='java' and host like '%CONTAINERID%' since 5 minutes ago"
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
msg: Install docker

- name: Update packages
shell: yum update -y
shell: "yum update -y"
become: true

- name: Install docker
shell: amazon-linux-extras install docker -y
shell: "amazon-linux-extras install docker -y"
become: true

- name: Start docker service
shell: service docker start
shell: "service docker start"
become: true

- name: Granting permission to docker from ec2-user
shell: usermod -a -G docker ec2-user
shell: "usermod -a -G docker ec2-user"
become: true

- name: reset ssh connection to flush user/group permission change
Expand All @@ -29,4 +29,5 @@
until: output is not failed

- name: Testing docker run
shell: docker run hello-world
shell: "docker run hello-world"
become: yes
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
when: service_port is not defined

- name: Run JBoss Docker container
shell: "docker run -d -p 8080:8080 -p 9990:9990 jboss/wildfly /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0"
shell: "docker run -d -p {{ service_port }}:8080 -p 9990:9990 jboss/wildfly /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0"
become: yes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

- name: Pull JBoss Docker image
shell: "docker pull jboss/wildfly"
become: yes
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---

- fail:
msg: "service_id is required"
when: service_id is not defined

- debug:
msg: Starting {{ service_id }} service

- fail:
msg: "service_port is required"
when: service_port is not defined

- name: Run JBoss Docker container
shell: "docker run -d -p {{ service_port }}:8080 -p 9990:9990 jboss/wildfly /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0"
become: yes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM jboss/wildfly
ADD spring-boot-rest.war /opt/jboss/wildfly/standalone/deployments/
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---

- name: purge python-pip
shell: apt-get purge --auto-remove python-pip
become: yes

- name: apt-get update
shell: apt-get update
become: yes
ignore_errors: true

- name: install pip
shell: apt-get -y install python3-pip
become: yes

- name: install docker-py
shell: pip install docker-py
become: yes

- name: Upload war to host
synchronize: src=. dest=/home/{{ ansible_user }}
become: yes

- name: Build JBoss Image
docker_image: >
name=spring-boot-rest
tag=wildfly
path=/home/{{ ansible_user }}
state=present
become: yes

# NOTE: context root of deployed app is name of artifact i.e. http://localhost:<service_port>/spring-boot-rest
- name: Run JBoss Docker container
shell: "docker run -d -p {{ service_port }}:8080 spring-boot-rest:wildfly /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0"
become: yes
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,3 @@
- name: Restart wildfly service
shell: systemctl restart wildfly
become: true

- block:
- name: Export USERNAME
shell: "echo export NR_CLI_JMX_USERNAME=newrelic >> ~/.bashrc"
- name: Export PASSWORD
shell: "echo export NR_CLI_JMX_PASSWORD=Virtuoso4all! >> ~/.bashrc"
- name: Export HOSTNAME
shell: "echo export NR_CLI_JMX_HOST=localhost >> ~/.bashrc"
- name: Export DB_PORT
shell: "echo export NR_CLI_JMX_PORT=9990 >> ~/.bashrc"
- name: Export Enable_SSL
shell: "echo export NR_CLI_SSL_ENABLED=n >> ~/.bashrc"
- name: Export KEYSTORE
shell: "echo export NR_CLI_KEYSTORE=notUsed >> ~/.bashrc"
- name: Export KEYSTORE_PASSWORD
shell: "echo export NR_CLI_KEYSTORE_PASSWORD=notUsed >> ~/.bashrc"
- name: Export TRUST STORE
shell: "echo export NR_CLI_TRUSTSTORE=notUsed >> ~/.bashrc"
- name: Export TRUST STORE PASSWORD
shell: "echo export NR_CLI_TRUSTSTORE_PASSWORD=notUsed >> ~/.bashrc"
when: create_env_var|bool
Loading

0 comments on commit 1668280

Please sign in to comment.