newrelic / ansible-install

Building installation support for our customers are using ansible to manage their infrastructure and services at scale
Apache License 2.0
7 stars 7 forks source link

ask: proxy setting in newrelic-infra.yml #62

Closed 8mccm8 closed 1 year ago

8mccm8 commented 1 year ago

HI all

how can I setup proxy in /etc/newrelic-infra.yml ?

thanks

amolero-nr commented 1 year ago

Hi @8mccm8!

We configure the infrastructure agent's proxy settings with an ansible environment variable (HTTPS_PROXY, see it here) when executing the ansible playbook, so that users don't have to modify the /etc/newrelic-infra.yml by themselves.

If for any reason you still want to add a proxy config to the /etc/newrelic-infra.yml, please take a look at these docs:

8mccm8 commented 1 year ago

HI @amolero-nr

I set HTTPS_PROXY and the installation was done correctly BUT the proxy directive was not set in /etc/newrelic-infra.yml and my agent can't send metrics to the API...

I willl check again tomorrow.

amolero-nr commented 1 year ago

Hey @8mccm8,

In my test, after setting the HTTPS_PROXY env var like this below in my playbook:

- name: Install New Relic
  hosts: linux
  roles:
    - role: newrelic.newrelic_install
      vars:
        targets:
          - infrastructure
          - logs
      environment:
        NEW_RELIC_API_KEY: "..."
        NEW_RELIC_ACCOUNT_ID: "..."
        NEW_RELIC_REGION: "..."
        HTTPS_PROXY: "http://MY_PROXY:PORT"

I got the config option successfully added to my newrelic-infra.yml as follows:

enable_process_metrics: true
status_server_enabled: true
status_server_port: 18003
license_key: < ... >
custom_attributes:
  nr_deployed_by: ansible-install

proxy: http://172.31.45.182:3128         #  <-- HERE
8mccm8 commented 1 year ago

hi @amolero-nr

definitely not:

    - role: roles/newrelic.newrelic-infra_new  
      vars:  
        targets:  
          - infrastructure  
        install_timeout_seconds: 1000  
        verbosity: debug  
      environment:  
        NEW_RELIC_API_KEY: "{{nrinfragent_env.NEW_RELIC_API_KEY }}"  
        NEW_RELIC_ACCOUNT_ID: "{{ nrinfragent_env.NEW_RELIC_ACCOUNT_ID }}"  
        http_proxy: "{{ proxy_env_redhat.http_proxy }}"  
        https_proxy: "{{ proxy_env_redhat.https_proxy }}"  
cat /etc/newrelic-infra.yml
enable_process_metrics: true
status_server_enabled: true
status_server_port: 18003
license_key: xxxxxxxxxxxxxxxxxxxxx
custom_attributes:
  nr_deployed_by: ansible-install

I must add this if I want proxy in my config:

roles:

    - role: roles/newrelic.newrelic-infra_new
      vars:
        targets:
          - infrastructure
        tags:
          proxy: "{{ proxy_env_redhat.https_proxy }}"
        install_timeout_seconds: 1000
        verbosity: debug
      environment:
        NEW_RELIC_API_KEY: "{{nrinfragent_env.NEW_RELIC_API_KEY }}"
        NEW_RELIC_ACCOUNT_ID: "{{ nrinfragent_env.NEW_RELIC_ACCOUNT_ID }}"
        http_proxy: "{{ proxy_env_redhat.http_proxy }}"
        https_proxy: "{{ proxy_env_redhat.https_proxy }}"

and I can see the CLI called with the tag option with proxy value...

amolero-nr commented 1 year ago

This brief AWS Linux instance demo shows it works as expected.

amolero-nr commented 1 year ago

What is your OS?

8mccm8 commented 1 year ago

redhat 8 ansible 2.9

amolero-nr commented 1 year ago

Unfortunately, we don't support Ansible 2.9

8mccm8 commented 1 year ago

ok! strange to be not aligned with an ansible version distributed for professional environment like RedHat!

Julien4218 commented 1 year ago

We follow the non-EOL ansible version https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-core-support-matrix

8mccm8 commented 1 year ago

Thx all... l never really checked these stories of packages licenses etc now it's done