Not a customer? Click the 'Start a free trial' link to begin a 30-day SaaS trial of our product and to join our community.
Existing Cisco AppDynamics customers should click the 'Sign In' button to authenticate to access the community
on 09-10-2024 02:19 PM
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.
sudo
(root) privileges to execute tasks.
Create a directory structure for the Ansible playbook as follows:
Define your target machine (localhost in this case) in the inventory
file:
[appd_agents]
localhost ansible_connection=local
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
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
Replace the download URL placeholder with your own Smart Agent download URL from the AppDynamics download site.
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
To run the playbook, execute the following command:
ansible-playbook -i inventory playbook.yml
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.
I'd like to thank you for this Ansible solution for automating smart agents' deployment. I have tried in a lab environment, and it works like a charm. I improved the playbook.yml & main.yml files a little bit to adhere to Ansible best practices from ansible lint.
playbook.yml
---
- name: AppDynamcis Smart Agent
hosts: appd_agents
gather_facts: false
become: true
roles:
- smart_agent
...
main.yml
Used FQCN for all plays
---
- name: Download AppDynamics Smart Agent using get_url # Use get_url instead of curl
ansible.builtin.get_url:
url: https://download.appdynamics.com/download/prox/download-file/appdsmartagent/<VERSION>/appdsmartagent_64_linux_<VERSION>.zip
headers:
Authorization: Bearer <BEARER_TOKEN>"
checksum: md5:<MD5_HASH> # To check file integrity
mode: '0440'
dest: /tmp
- name: Unarchive the Smart Agent zip
ansible.builtin.unarchive:
src: /tmp/appdsmartagent_64_linux_<VERSION>.zip
dest: /opt/appdynamics/
remote_src: true
- name: Configure Smart Agent in config.ini
ansible.builtin.replace:
path: /opt/appdynamics/config.ini
regexp: 'ControllerURL\s*=\s*.*'
replace: 'ControllerURL=https://xxxxx.saas.appdynamics.com'
- name: Set ControllerPort in config.ini
ansible.builtin.replace:
path: /opt/appdynamics/config.ini
regexp: 'ControllerPort\s*=\s*.*'
replace: 'ControllerPort=443'
- name: Set FMServicePort in config.ini
ansible.builtin.replace:
path: /opt/appdynamics/config.ini
regexp: 'FMServicePort\s*=\s*.*'
replace: 'FMServicePort=443'
- name: Set AccountAccessKey in config.ini
ansible.builtin.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
ansible.builtin.lineinfile:
path: /opt/appdynamics/config.ini
regexp: '^AccountName\s*='
line: 'AccountName=xxxxx'
insertafter: '^ControllerPort\s*=.*'
- name: Enable SSL in config.ini
ansible.builtin.replace:
path: /opt/appdynamics/config.ini
regexp: 'EnableSSL\s*=\s*.*'
replace: 'EnableSSL=true'
- name: Start Smart Agent
ansible.builtin.shell: /opt/appdynamics/smartagentctl start --service > /tmp/log.log 2>&1
become: true
register: output
changed_when: output.rc != 0 # <- Uses the return code to define when the task has changed.
...
Once again, thank you so much. Your work is much appreciated, at least by me :))
Thank you so much Osama, I will try deploying with your updated playbook.yml & main.yml
Thank you! Your submission has been received!
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form