The following sections provide the example use cases for the Python Agent Playbook:

Install Python Agent

Example 1: AnsibleĀ® role used to install Python Agent with the following features:

  • Installs Python Agent on Linux (Debian, Alpine, and RedHat)
  • Creates a backup if existing installation is detected
---
- 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.python
      vars:
        agent_version: 22.10.0.5500.0
        # possible value:
        #          - latest: Latest version 
        #          - 22.10.0.5500.0: Any Specific version number
        agent_type: python
        agent_action: upgrade
        # possible value:
        #          - upgrade: upgrade currently installed agent to agent_version 
        #          - install: install agent_version
        #          - rollback: rollback to previous backup if any
        #          - uninstall: uninstall agent
        # Python specific Args
        install_env: default # [default - (main python path taken automatically), virtualenv - (virtualenv path need to be provided)]
        # possible value:
        #          - default: install agent in global python
        #          - virtualenv: install agent  to specific virtualenv
        virtualenv_path: /home/ansible/venv
        # possible value:
        #          - /home/ansible/venv: virtualenv path
        #          - None
        install_agent_from: appd-portal
        # possible value:
        #          - pypi: Downlaod agent from PYPI
        #          - appd-portal: Download agent from AppD portal
YML

Example 2: Ansible role to start a sample application with Python Agent:

---
- 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.python
    
    - name: Start Sample Python app
      shell: "nohup pyagent run -c /opt/appdynamics/python-agent/appd.cfg python3 /home/ubuntu/app.py &"
      async: 100
      poll: 0
      register: status
      failed_when: "'FAILED' in status.stdout"

Config path and the application path has to be changed accordingly. 
YML

Python Agent Variables

VariableDescriptionDefaultPossible ValuesRequired

agent_config_path

Specify the absolute path (including the file path) for the manually created configuration file containing the agent configuration data.

None.

agent_destination_directory

No
analytics_hostAnalytics Agent hostname.localhost
No
analytics_portAnalytics Agent port.9090
No
analytics_sslSet to ON to enable SSL communication with the Analytics Agent.OFF
No
analytics_ca_fileCertificate of the CA authority that signed the certificate of Analytics Agent.

No
eum_disable_cookieWhen set to ON, the agent does not add EUM correlation data to WSGI response headers.OFFOFF, ONNo
eum_user_agent_allowlistIf specified overwrites the default allowlist for user agents added as EUM correlation data headers. Use it to specify alternate user agents as a comma-separated list. Use '*' to allow all user agents.Mozilla, Opera, WebKit, Nokia
No
install_agent_fromInstall Agent from PYPI or Download portalpypipypi, appd-portalYes
install_env

Python Environment where to install Splunk AppDynamics Agent (global or virtual environment)

defaultdefault, virtualenvYes
log_levelDirectory to write proxy and agent logswarningwarning, debug, infoNo
log_debuggingThe log level for the agent.
off, onNo
log_dirDirectory to write debug level logs/tmp/appd/logs
No
node_reuseReuse node names-true, falseNo
node_reuse_prefixNode name prefix while reusing node names--No
pypi_index_urlChange the pypi index url to any internal artifactoryhttps://pypi.org/simple
No
snapshot_exit_call_details_lengthSpecifies the number of characters in the details string describing exit calls in transaction snapshots.100
No
transaction_monitor_bt_max_duration_msThe maximum duration of a business transaction in milliseconds.12000
No
virtualenv_pathPath to virtualenv. It is required if install_env is set to virtualenvnoneNone, venv_pathYes, if install_env = virtualenv
No, if 
install_env = default
wsgi_scriptPath to WSGI script file.

No
wsgi_callableName of WSGI callable in script/module.application
No
wsgi_moduleThe fully-qualified name of the application module.

No


AnsibleĀ® is a registered trademark of Red Hat, Inc. in the United States and other countries.