diff --git a/ansible/roles/oracle-oms-setup/tasks/create_jobs.yml b/ansible/roles/oracle-oms-setup/tasks/create_jobs.yml index b5729d2a3..8dc978d58 100644 --- a/ansible/roles/oracle-oms-setup/tasks/create_jobs.yml +++ b/ansible/roles/oracle-oms-setup/tasks/create_jobs.yml @@ -1,6 +1,15 @@ # # We apply OEM job property files to create these jobs. # +- name: Check if inside AWS. + uri: + url: http://169.254.169.254/latest/meta-data + timeout: 20 + register: aws_uri_check + failed_when: false + +- set_fact: + is_aws_environment: "{{ aws_uri_check.status == 200 }}" - name: Get Job Property Files ansible.builtin.find: @@ -9,6 +18,7 @@ depth: 1 file_type: file delegate_to: localhost + become: "{{ is_aws_environment | default(true) }}" register: get_oem_job_property_files loop: "{{ application_groups.keys() | list + ['common'] }}" loop_control: diff --git a/ansible/roles/oracle-oms-setup/tasks/import_metric_extensions.yml b/ansible/roles/oracle-oms-setup/tasks/import_metric_extensions.yml index b870a93d5..17b4c74d4 100644 --- a/ansible/roles/oracle-oms-setup/tasks/import_metric_extensions.yml +++ b/ansible/roles/oracle-oms-setup/tasks/import_metric_extensions.yml @@ -9,6 +9,16 @@ # generic and may be applicable to multiple or all applications. # +- name: Check if inside AWS. + uri: + url: http://169.254.169.254/latest/meta-data + timeout: 20 + register: aws_uri_check + failed_when: false + +- set_fact: + is_aws_environment: "{{ aws_uri_check.status == 200 }}" + - name: Get Metric Extensions ansible.builtin.find: paths: "{{ role_path }}/files/metric_extensions/{{ application_name }}" @@ -16,8 +26,9 @@ depth: 1 file_type: directory delegate_to: localhost + become: "{{ is_aws_environment | default(true) }}" register: get_metric_extensions - loop: "{{ application_groups + ['common'] }}" + loop: "{{ application_groups.keys() | list + ['common'] }}" loop_control: loop_var: application_name