mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2025-12-17 02:13:06 -06:00
AZURE-211 Renamed az_* files to azure_*
This commit is contained in:
12
roles/azure_app_insights_install/.yamllint
Normal file
12
roles/azure_app_insights_install/.yamllint
Normal file
@@ -0,0 +1,12 @@
|
||||
extends: default
|
||||
|
||||
rules:
|
||||
line-length: disable
|
||||
braces:
|
||||
max-spaces-inside: 1
|
||||
level: error
|
||||
brackets:
|
||||
max-spaces-inside: 1
|
||||
level: error
|
||||
truthy: disable
|
||||
trailing-spaces: false
|
||||
5
roles/azure_app_insights_install/defaults/main.yml
Normal file
5
roles/azure_app_insights_install/defaults/main.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
|
||||
app_insights_version: "{{ lookup('env', 'APPINSIGHTS_VER') or '2.6.0' }}"
|
||||
app_insights_instrumentation_key: "{{ lookup('env', 'APPINSIGHTS_INSTRUMENTATION_KEY') or 'XXX' }}"
|
||||
app_insights_jaxb_version: 2.3.1
|
||||
3
roles/azure_app_insights_install/handlers/main.yml
Normal file
3
roles/azure_app_insights_install/handlers/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- name: Restart Collectd
|
||||
service: name=collectd state=restarted
|
||||
@@ -0,0 +1,14 @@
|
||||
# Molecule managed
|
||||
|
||||
{% if item.registry is defined %}
|
||||
FROM {{ item.registry.url }}/{{ item.image }}
|
||||
{% else %}
|
||||
FROM {{ item.image }}
|
||||
{% endif %}
|
||||
|
||||
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
|
||||
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \
|
||||
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
|
||||
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \
|
||||
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
|
||||
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
lint:
|
||||
name: yamllint
|
||||
platforms:
|
||||
- name: ubuntu_lts
|
||||
image: ubuntu:bionic
|
||||
groups:
|
||||
- azure_node_local
|
||||
provisioner:
|
||||
name: ansible
|
||||
options:
|
||||
skip-tags: runtime_pkg
|
||||
lint:
|
||||
name: ansible-lint
|
||||
options:
|
||||
x: ["701"]
|
||||
inventory:
|
||||
links:
|
||||
group_vars: ../../../../group_vars/
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
||||
enabled: false
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
vars:
|
||||
atl_product_family: "crowd"
|
||||
atl_product_edition: "crowd"
|
||||
atl_product_user: "crowd"
|
||||
atl_download_format: "tarball"
|
||||
roles:
|
||||
- role: linux_common
|
||||
- role: azure_common
|
||||
- role: product_common
|
||||
- role: product_install
|
||||
- role: azure_app_insights_install
|
||||
@@ -0,0 +1,38 @@
|
||||
import os
|
||||
import pytest
|
||||
|
||||
import testinfra.utils.ansible_runner
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
||||
def test_collectd_installed(host):
|
||||
package = host.package('collectd')
|
||||
assert package.is_installed
|
||||
|
||||
def test_collectd_file(host):
|
||||
f = host.file('/etc/collectd/collectd.conf')
|
||||
assert f.exists
|
||||
assert f.contains('InstrumentationKey "XXX"')
|
||||
assert f.mode == 0o0644
|
||||
|
||||
def test_jaxb_installed(host):
|
||||
f = host.file('/usr/share/collectd/java/jaxb-api-2.3.1.jar')
|
||||
assert f.exists
|
||||
|
||||
@pytest.mark.parametrize('filename', [
|
||||
'/opt/atlassian/crowd/current/crowd-webapp/WEB-INF/lib/applicationinsights-core-2.6.0.jar',
|
||||
'/opt/atlassian/crowd/current/crowd-webapp/WEB-INF/lib/applicationinsights-web-2.6.0.jar',
|
||||
'/opt/atlassian/crowd/current/crowd-webapp/WEB-INF/lib/applicationinsights-agent-2.6.0.jar'
|
||||
])
|
||||
def test_app_insight_jars_downloaded(host, filename):
|
||||
f = host.file(filename)
|
||||
assert f.exists
|
||||
|
||||
def test_app_insights_collectd_file(host):
|
||||
f = host.file('/usr/share/collectd/java/applicationinsights-collectd-2.6.0.jar')
|
||||
assert f.exists
|
||||
|
||||
def test_applicationinsights_xml_installed(host):
|
||||
f = host.file('/opt/atlassian/crowd/current/crowd-webapp/WEB-INF/classes/ApplicationInsights.xml')
|
||||
assert f.exists
|
||||
71
roles/azure_app_insights_install/tasks/main.yml
Normal file
71
roles/azure_app_insights_install/tasks/main.yml
Normal file
@@ -0,0 +1,71 @@
|
||||
---
|
||||
|
||||
- name: Install collectd for app insights
|
||||
package:
|
||||
name:
|
||||
- collectd
|
||||
|
||||
- name: Download Collectd App Insights jar
|
||||
get_url:
|
||||
url: "https://github.com/Microsoft/ApplicationInsights-Java/releases/download/{{ app_insights_version }}/{{ item }}"
|
||||
dest: "/usr/share/collectd/java/applicationinsights-collectd-{{ app_insights_version }}.jar"
|
||||
with_items:
|
||||
- "applicationinsights-collectd-{{ app_insights_version }}.jar"
|
||||
|
||||
- name: Configure Collectd
|
||||
template: src=collectd.conf.j2 dest=/etc/collectd/collectd.conf
|
||||
notify:
|
||||
- Restart Collectd
|
||||
|
||||
- name: Change collectd.conf permissions
|
||||
file:
|
||||
path: /etc/collectd/collectd.conf
|
||||
mode: '+r'
|
||||
|
||||
- name: Install JAXB
|
||||
get_url:
|
||||
url: "https://repo1.maven.org/maven2/javax/xml/bind/jaxb-api/{{ app_insights_jaxb_version }}/jaxb-api-{{ app_insights_jaxb_version }}.jar"
|
||||
dest: "/usr/share/collectd/java/"
|
||||
|
||||
- name: Download App Insights jars
|
||||
get_url:
|
||||
url: "https://github.com/Microsoft/ApplicationInsights-Java/releases/download/{{ app_insights_version }}/{{ item }}"
|
||||
dest: "{{ atl_product_installation_versioned }}/crowd-webapp/WEB-INF/lib/"
|
||||
with_items:
|
||||
- "applicationinsights-core-{{ app_insights_version }}.jar"
|
||||
- "applicationinsights-web-{{ app_insights_version }}.jar"
|
||||
- "applicationinsights-agent-{{ app_insights_version }}.jar"
|
||||
|
||||
- name: Add java agent to JAVA_OPTS
|
||||
lineinfile:
|
||||
path: "{{ atl_product_installation_versioned }}/apache-tomcat/bin/setenv.sh"
|
||||
regexp: '^export JAVA_OPTS'
|
||||
line: "export JAVA_OPTS=\"$JAVA_OPTS -javaagent:{{ atl_product_installation_versioned }}\
|
||||
/crowd-webapp/WEB-INF/lib/applicationinsights-agent-{{ app_insights_version }}.jar\""
|
||||
|
||||
- name: Add ApplicationInsights.xml configuration
|
||||
template: src=ApplicationInsights.xml.j2 dest={{ atl_product_installation_versioned }}/crowd-webapp/WEB-INF/classes/ApplicationInsights.xml
|
||||
|
||||
- name: Check for existing App Insights Filter
|
||||
xml:
|
||||
path: "/opt/atlassian/crowd/current/crowd-webapp/WEB-INF/web.xml"
|
||||
xpath: //*[.="ApplicationInsightsWebFilter"]
|
||||
count: yes
|
||||
register: appInsightsFilter
|
||||
|
||||
- name: Add App Insights Filter
|
||||
xml:
|
||||
path: "/opt/atlassian/crowd/current/crowd-webapp/WEB-INF/web.xml"
|
||||
xpath: /*[name()='web-app']
|
||||
input_type: xml
|
||||
pretty_print: yes
|
||||
add_children:
|
||||
- "<filter>\
|
||||
<filter-name>ApplicationInsightsWebFilter</filter-name>\
|
||||
<filter-class>com.microsoft.applicationinsights.web.internal.WebRequestTrackingFilter</filter-class>\
|
||||
</filter>"
|
||||
- "<filter-mapping>\
|
||||
<filter-name>ApplicationInsightsWebFilter</filter-name>\
|
||||
<url-pattern>/*</url-pattern>\
|
||||
</filter-mapping>"
|
||||
when: appInsightsFilter.count < 1
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings" schemaVersion="2014-05-30">
|
||||
|
||||
<!-- The key from the portal: -->
|
||||
<InstrumentationKey>{{ app_insights_instrumentation_key }}</InstrumentationKey>
|
||||
|
||||
<!-- HTTP request component (not required for bare API) -->
|
||||
<TelemetryModules>
|
||||
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebRequestTrackingTelemetryModule"/>
|
||||
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebSessionTrackingTelemetryModule"/>
|
||||
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebUserTrackingTelemetryModule"/>
|
||||
</TelemetryModules>
|
||||
|
||||
<!-- Events correlation (not required for bare API) -->
|
||||
<!-- These initializers add context data to each event -->
|
||||
<TelemetryInitializers>
|
||||
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationIdTelemetryInitializer"/>
|
||||
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationNameTelemetryInitializer"/>
|
||||
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebSessionTelemetryInitializer"/>
|
||||
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserTelemetryInitializer"/>
|
||||
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserAgentTelemetryInitializer"/>
|
||||
</TelemetryInitializers>
|
||||
|
||||
</ApplicationInsights>
|
||||
98
roles/azure_app_insights_install/templates/collectd.conf.j2
Normal file
98
roles/azure_app_insights_install/templates/collectd.conf.j2
Normal file
@@ -0,0 +1,98 @@
|
||||
FQDNLookup true
|
||||
BaseDir "/var/lib/collectd"
|
||||
PIDFile "/var/run/collectd.pid"
|
||||
PluginDir "/usr/lib/collectd"
|
||||
TypesDB "/usr/share/collectd/types.db"
|
||||
Interval 10
|
||||
Timeout 2
|
||||
ReadThreads 5
|
||||
WriteThreads 5
|
||||
LoadPlugin logfile
|
||||
<Plugin "logfile">
|
||||
LogLevel "info"
|
||||
File "/var/log/collectd.log"
|
||||
Timestamp true
|
||||
</Plugin>
|
||||
LoadPlugin aggregation
|
||||
<Plugin aggregation>
|
||||
<Aggregation>
|
||||
Plugin "cpu"
|
||||
Type "cpu"
|
||||
GroupBy "Host"
|
||||
GroupBy "TypeInstance"
|
||||
CalculateSum true
|
||||
CalculateAverage true
|
||||
</Aggregation>
|
||||
</Plugin>
|
||||
|
||||
# Collect CPU statistics
|
||||
LoadPlugin cpu
|
||||
|
||||
# Write collected statistics in CSV format
|
||||
LoadPlugin csv
|
||||
<Plugin csv>
|
||||
DataDir "/var/lib/collectd/csv"
|
||||
StoreRates false
|
||||
</Plugin>
|
||||
|
||||
# Collect partition usage statistics
|
||||
LoadPlugin df
|
||||
<Plugin df>
|
||||
Device "/dev/xvda1"
|
||||
MountPoint "/media/atl"
|
||||
IgnoreSelected false
|
||||
ReportByDevice false
|
||||
ReportReserved false
|
||||
ReportInodes false
|
||||
ValuesAbsolute true
|
||||
ValuesPercentage false
|
||||
</Plugin>
|
||||
|
||||
# Collect disk IO statistics
|
||||
LoadPlugin disk
|
||||
<Plugin disk>
|
||||
Disk "/^[hs]d[a-f][0-9]?$/"
|
||||
IgnoreSelected false
|
||||
</Plugin>
|
||||
|
||||
# Collect network interface usage statistics
|
||||
LoadPlugin interface
|
||||
<Plugin interface>
|
||||
Interface "eth0"
|
||||
IgnoreSelected false
|
||||
</Plugin>
|
||||
|
||||
# Collect system load statistics
|
||||
LoadPlugin load
|
||||
|
||||
# Collect memory utilization statistics
|
||||
LoadPlugin memory
|
||||
<Plugin memory>
|
||||
# Don't use absolute as each AWS ec2 instance is different, use percentage instead to get a uniform view
|
||||
ValuesAbsolute false
|
||||
ValuesPercentage true
|
||||
</Plugin>
|
||||
|
||||
LoadPlugin swap
|
||||
<Plugin "swap">
|
||||
ReportByDevice false
|
||||
ReportBytes true
|
||||
</Plugin>
|
||||
|
||||
LoadPlugin java
|
||||
<Plugin java>
|
||||
JVMArg "-verbose:jni"
|
||||
JVMArg "-Djava.class.path=/usr/share/collectd/java/jaxb-api-2.3.1.jar:/usr/share/collectd/java/applicationinsights-collectd-{{ app_insights_version }}.jar:/usr/share/collectd/java/collectd-api.jar:/usr/share/collectd/java/generic-jmx.jar"
|
||||
|
||||
# Enabling Application Insights plugin
|
||||
LoadPlugin "com.microsoft.applicationinsights.collectd.ApplicationInsightsWriter"
|
||||
|
||||
# Configuring Application Insights plugin
|
||||
<Plugin ApplicationInsightsWriter>
|
||||
InstrumentationKey "{{ app_insights_instrumentation_key }}"
|
||||
SDKLogger true
|
||||
</Plugin>
|
||||
|
||||
</Plugin>
|
||||
|
||||
Include "/etc/collectd.d"
|
||||
Reference in New Issue
Block a user