cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Abhi.Bajaj
AppDynamics Team

Step-by-Step Guide to Deploying AppDynamics Smart Agent Using Ansible on Linux Systems

This article will guide you through installing the AppDynamics Smart Agent on a Linux system using Ansible. It covers downloading, configuring, and starting the Smart Agent in an automated fashion. This setup ensures that the Smart Agent is correctly configured for your environment.

Prerequisites:

  1. Ansible Installed: Make sure Ansible is installed on the machine where you are running the playbook.
  2. Sudo Privileges: The playbook requires sudo (root) privileges to execute tasks.
  3. Download URL: You need a valid download URL for the AppDynamics Smart Agent. You can get this from the AppDynamics download site (replace the provided URL with your own).

 

Steps to Set Up the Ansible Playbook

1. Directory Structure

Create a directory structure for the Ansible playbook as follows:Screenshot 2024-09-10 at 4.09.51 PM.png

2. Inventory File

Define your target machine (localhost in this case) in the inventory file:

[appd_agents]
localhost ansible_connection=local

3. Ansible Playbook (playbook.yml)

The main playbook references the smart_agent role. Ensure become: true is set to allow privilege escalation for necessary tasks:

---
- hosts: appd_agents
  become: true
  roles:
    - smart_agent

4. Role Tasks (roles/smart_agent/tasks/main.yml)

The tasks in this role will include downloading, unarchiving, configuring, and starting the Smart Agent.

- name: Download AppDynamics Smart Agent using curl
  command: >
    curl -L -O -H "Authorization: Bearer <YOUR_AUTH_TOKEN>"
    "https://download.appdynamics.com/download/prox/download-file/appdsmartagent/<version>/appdsmartagent_64_linux_<version>.zip"
  args:
    chdir: /tmp

- name: Unarchive the Smart Agent zip
  unarchive:
    src: /tmp/appdsmartagent_64_linux_<version>.zip
    dest: /opt/appdynamics/
    remote_src: yes

- name: Configure Smart Agent in config.ini
  replace:
    path: /opt/appdynamics/config.ini
    regexp: 'ControllerURL\s*=\s*.*'
    replace: 'ControllerURL=https://xxxxx.saas.appdynamics.com'

- name: Set ControllerPort in config.ini
  replace:
    path: /opt/appdynamics/config.ini
    regexp: 'ControllerPort\s*=\s*.*'
    replace: 'ControllerPort=443'

- name: Set FMServicePort in config.ini
  replace:
    path: /opt/appdynamics/config.ini
    regexp: 'FMServicePort\s*=\s*.*'
    replace: 'FMServicePort=443'

- name: Set AccountAccessKey in config.ini
  replace:
    path: /opt/appdynamics/config.ini
    regexp: '^AccountAccessKey\s*=\s*.*'
    replace: 'AccountAccessKey=<YOUR_ACCOUNT_ACCESS_KEY>'

- name: Ensure AccountName is set in the main section of config.ini
  lineinfile:
    path: /opt/appdynamics/config.ini
    regexp: '^AccountName\s*='
    line: 'AccountName=xxxxx'
    insertafter: '^ControllerPort\s*=.*'

- name: Enable SSL in config.ini
  replace:
    path: /opt/appdynamics/config.ini
    regexp: 'EnableSSL\s*=\s*.*'
    replace: 'EnableSSL=true'

- name: Start Smart Agent
  shell: /opt/appdynamics/smartagentctl start --service > /tmp/log.log 2>&1
  become: yes
  register: output

5. Replace the Download URL and other controller parameter

Replace the download URL placeholder with your own Smart Agent download URL from the AppDynamics download site.

  • In the command task for downloading the Smart Agent, replace <YOUR_AUTH_TOKEN> with your AppDynamics authentication token and replace <version> with the appropriate version for your Smart Agent. For example:
- name: Download AppDynamics Smart Agent using curl
  command: >
    curl -L -O -H "Authorization: Bearer YOUR_AUTH_TOKEN"
    "https://download.appdynamics.com/download/prox/download-file/appdsmartagent/24.8.0.551/appdsmartagent_64_linux_24.8.0.551.zip"
  args:
    chdir: /tmp
  • Replace Controller URL, Controller Port, AccessKey and AccountName with your credentials

6. Running the Playbook

To run the playbook, execute the following command:

ansible-playbook -i inventory playbook.yml

Conclusion

This Ansible playbook simplifies downloading, configuring, and running the AppDynamics Smart Agent on a Linux system. Make sure to replace the download URL and account details with your specific values, and you’ll have the agent up and running in no time.

Version history
Last update:
‎09-10-2024 02:19 PM
Updated by:
Join Us On December 10
Learn how Splunk and AppDynamics are redefining observability


Register Now!

Observe and Explore
Dive into our Community Blog for the Latest Insights and Updates!


Read the blog here