Download PDF
Download page Java エージェントの Ansible 設定.
Java エージェントの Ansible 設定
次の項では、Java エージェントの Ansible ロールの使用例を示します。
Linux または Windows 上での Java エージェントのインストール
Example 1:アプリケーション インストゥルメンテーションなしで Windows または Linux に Java エージェントをインストールするために使用される Ansible® ロール:
---
- hosts: all
tasks:
- name: Include variables for the controller settings
# Include all yaml files under the vars directory
include_vars:
dir: vars
extensions:
- 'yaml'
- 'yml'
- include_role:
name: appdynamics.agents.java
vars:
agent_version: 21.1.0
agent_type: java
agent_action: upgrade # can be upgrade/install/rollback/uninstall, defaults to upgrade when unspecified
application_name: "IoT_API" # agent default application
tier_name: "java_tier" # agent default tier
Example 2:Java スタートアップスクリプトを変更し、再起動を実行して Java エージェントをインストールするための Ansible ロール:
---
- hosts: single-java-host
tasks:
- name: Include variables for the controller settings
# Include all yaml files under the vars directory
include_vars:
dir: vars
extensions:
- 'yaml'
- 'yml'
- import_role:
name: appdynamics.agents.java
public: yes
vars:
agent_version: 21.1.0
agent_type: java
application_name: "BIGFLY" # agent default application
tier_name: "java_tier" # agent default tier
- name: Edit startup script with new java startup variables
lineinfile:
path: /opt/application/startAll.sh
# Line to Search/Match against
regexp: '^(.*)(-jar.*$)'
# Line to Replace with
line: '\1 -javaagent:{{ java_agent_dest_folder_linux }}/javaagent.jar -Dappdynamics.agent.nodeName=application-1 \2'
backup: yes
backrefs: yes
state: present
notify: RestartingApp
- name: Allow appuser write to appd logs folder
user:
name: appuser
groups:
- appdynamics
append: yes
become: yes
handlers:
- name: RestartingApp
command: '/opt/application/stopAll.sh && /opt/application/startAll.sh'
args:
chdir: '/opt/application/'
JBoss/Wildfly のインストゥルメント化
このロールの特徴は次のとおりです。
- Linux の Java エージェントのインストール
- Jboss/Wildfly のインストゥルメント化
- アプリケーションの自動再起動(
systemd
サービスが存在する場合) - Java エージェントの起動検証
Example 1:Java エージェントをインストールし、1 つ以上のアプリケーションをインストゥルメント化します。
---
- hosts: all
tasks:
- name: Include variables for the controller settings
# Include all yaml files under the vars directory
include_vars:
dir: vars
extensions:
- 'yaml'
- 'yml'
- include_role:
name: appdynamics.agents.java
# use java role variables in the following instrumentation tasks when public: yes
public: yes
vars:
agent_version: 21.1.0
agent_type: java
- include_role:
name: appdynamics.agents.instrument_jboss
vars:
# instrument jboss:
application_name: "IoT_API2"
tier_name: "Jboss"
jboss_service: wildfly
app_user: wildfly
restart_app: yes
jboss_config: /opt/wildfly/bin/standalone.sh
Example 2:このロールでは、インストゥルメント化されたすべてのアプリケーションが、Java エージェントのログディレクトリにアクセスできます。
場合によっては、アプリケーション PID ユーザーが Linux ホストでローカルでないことがあります。この場合、AppDynamics グループに追加できません。このような場合、代わりにアプリケーションユーザーに Java エージェントディレクトリを所有させることができます。
---
- hosts: all
tasks:
- name: Include variables for the controller settings
# Include all yaml files under the vars directory
include_vars:
dir: vars
extensions:
- 'yaml'
- 'yml'
- include_role:
name: appdynamics.agents.java
# use java role variables in the following instrumentation tasks when public: yes
public: yes
vars:
agent_version: 21.1.0
agent_type: java
# single app mode: Can skip appdynamics user creation and own java-agent directory by app user (wildfly in this case)
create_appdynamics_user: no
agent_dir_permission:
user: wildfly
group: wildfly
- include_role:
name: appdynamics.agents.instrument_jboss
vars:
# instrument jboss:
application_name: "IoT_API2"
tier_name: "Jboss"
jboss_service: wildfly
app_user: wildfly
restart_app: yes
jboss_config: /opt/wildfly/bin/standalone.sh
JBoss インストゥルメンテーションの変数
変数 | 説明 | 必須 | デフォルト |
---|---|---|---|
app_user | このアプリケーションを実行するユーザー。これを指定する必要があるため、java-agent ログディレクトリへの書き込み権限が付与されます。 | Y | jboss |
jboss_service | restart_app が 'yes' に設定されている場合に再起動する必要がある Systemd サービス | なし | |
restart_app | インストゥルメント化されたサービスを自動的に再起動するには、'yes' に設定します。 | なし | × |
backup | 変更前に元の構成ファイルをバックアップするかどうかです。 | なし | いいえ |
jboss_config | インストゥルメント化する Jboss/Wildfly 設定。jboss standalone.sh へのパスを指定します。 | Y | /opt/wildfly/bin/standalone.sh |
Apache Tomcatのインストゥルメント化
このロールの特徴は次のとおりです。
- Linux の Java エージェントのインストール
- Apache Tomcat のインストゥルメンテーション
- アプリケーションの自動再起動(
systemd
サービスが存在する場合) - Java エージェントの起動検証
Example 1:Java エージェントをインストールし、1 つ以上のアプリケーションをインストゥルメント化します。
---
- hosts: all
tasks:
- name: Include variables for the controller settings
# Include all yaml files under the vars directory
include_vars:
dir: vars
extensions:
- 'yaml'
- 'yml'
- include_role:
name: appdynamics.agents.java
# use java role variables in the following instrumentation tasks when public: yes
public: yes
vars:
agent_version: 21.1.0
agent_type: java
- include_role:
name: appdynamics.agents.instrument_tomcat
vars:
# instrument tomcat:
tomcat_service: tomcat9
application_name: "IoT_API22"
tier_name: "Tomcat"
app_user: tomcat
restart_app: yes
tomcat_config: /usr/share/tomcat9/bin/setenv.sh
Example 2:インストゥルメント化されたすべてのアプリケーションが、Java エージェントのログディレクトリにアクセスできるようにします。
場合によっては、アプリケーション PID ユーザーが Linux ホストでローカルでないことがあります。この場合、AppDynamics グループに追加できません。このような場合、代わりにアプリケーションユーザーに Java エージェントディレクトリを所有させることができます。
---
- hosts: all
tasks:
- name: Include variables for the controller settings
# Include all yaml files under the vars directory
include_vars:
dir: vars
extensions:
- 'yaml'
- 'yml'
- include_role:
name: appdynamics.agents.java
# use java role variables in the following instrumentation tasks when public: yes
public: yes
vars:
agent_version: 21.1.0
agent_type: java
# single app mode: Can skip appdynamics user creation and own java-agent directory by app user (tomcat in this case)
create_appdynamics_user: no
agent_dir_permission:
user: tomcat
group: tomcat
- include_role:
name: appdynamics.agents.instrument_tomcat
vars:
# instrument tomcat:
tomcat_service: tomcat9
application_name: "IoT_API22"
tier_name: "Tomcat"
app_user: tomcat
restart_app: yes
tomcat_config: /usr/share/tomcat9/bin/setenv.sh
Tomcat インストゥルメンテーションの変数
変数 | 説明 | 必須 | デフォルト |
---|---|---|---|
app_user | このアプリケーションを実行するユーザー。これを指定する必要があるため、java-agent ログディレクトリへの書き込み権限が付与されます。 | Y | tomcat |
tomcat_service | restart_app が 'yes' に設定されている場合に再起動する必要がある Systemd サービス | なし | |
add_service_override | 有効にすると、systemd オーバーライドファイルを追加して、AppDynamics java-agent ディレクトリへの書き込み権限を明示的に許可します。ubuntu20.04 にインストールされている tomcat9 に必要です。 | なし | 〇 |
restart_app | インストゥルメント化されたサービスを自動的に再起動するには、'yes' に設定します。 | なし | × |
backup | 変更前に元の構成ファイルをバックアップするかどうかです。 | なし | × |
tomcat_config | 変更する tomcat 構成ファイルを選択します。setenv.sh ファイルへのフルパスを設定する必要があります(例:<CATALINA_HOME>/bin/setenv.sh )。RHEL ディストリビューションで Tomcat が yum とともにインストールされている場合、このファイルはスタートアップスクリプトによって呼び出されません。その場合は、代わりに /etc/tomcat/conf.d/appdynamics.conf に設定できます。 | Y |