Skip to content

Commit

Permalink
Commit changes made by code formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Mar 8, 2024
1 parent d02d019 commit b71ef0a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 52 deletions.
38 changes: 18 additions & 20 deletions ansible/roles/oracle-oms-setup/tasks/import_metric_extension.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
# Imports a Single Metric Extension
- block:

- name: Ensure Metric Build Directory is Empty
file:
path: "{{ stage }}/metric_extension"
state: absent
path: "{{ stage }}/metric_extension"
state: absent

- name: Create New Metric Build Directory
- name: Create New Metric Build Directory
file:
path: "{{ stage }}/metric_extension"
state: directory
path: "{{ stage }}/metric_extension"
state: directory

- name: Copy Metric Components
ansible.builtin.copy:
src: "{{ metric_extension_component }}"
dest: "{{ stage }}/metric_extension"
loop:
- "{{ metric_extension_path }}/collection"
- "{{ metric_extension_path }}/metadata"
- "{{ metric_extension_path }}/scripts"
- "{{ metric_extension_path}}/mea.xml"
- "{{ metric_extension_path }}/collection"
- "{{ metric_extension_path }}/metadata"
- "{{ metric_extension_path }}/scripts"
- "{{ metric_extension_path}}/mea.xml"
loop_control:
loop_var: metric_extension_component
loop_var: metric_extension_component

- name: Remove Previous Metric Extension Zip
file:
path: "{{ stage }}/{{ metric_extension_name }}.zip"
state: absent
path: "{{ stage }}/{{ metric_extension_name }}.zip"
state: absent

- name: Create Metric Extension Zip
shell: |
cd {{ stage }}/metric_extension
zip -r ../{{ metric_extension_name }}.zip *
cd {{ stage }}/metric_extension
zip -r ../{{ metric_extension_name }}.zip *
- name: Import Metric Extension
become_user: oracle
Expand All @@ -42,8 +41,7 @@
register: import_metric_extension

always:

- name: Remove Metric Extension Zip File
file:
path: "{{ stage }}/{{ metric_extension_name }}.zip"
state: absent
- name: Remove Metric Extension Zip File
file:
path: "{{ stage }}/{{ metric_extension_name }}.zip"
state: absent
60 changes: 29 additions & 31 deletions ansible/roles/oracle-oms-setup/tasks/import_metric_extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Metric Extensions are found in the files/metric_extensions subdirectory with
# further subdirectories for Metric Extensions which are specific to a particular
# application (such as Delius) or common Metric Extensions which are more
# generic and may be applicable to multiple or all applications.
# generic and may be applicable to multiple or all applications.
#

- name: Get Metric Extensions
Expand All @@ -19,20 +19,19 @@
register: get_metric_extensions
loop: "{{ application_groups + ['common'] }}"
loop_control:
loop_var: application_name
loop_var: application_name

- debug:
var: get_metric_extensions

- name: Populate List of Metric Extensions
set_fact:
metric_extensions: "{{ get_metric_extensions.results | map(attribute='files') | flatten | map(attribute='path') | list }}"
metric_extensions: "{{ get_metric_extensions.results | map(attribute='files') | flatten | map(attribute='path') | list }}"

- debug:
var: metric_extensions
var: metric_extensions

- block:

- name: Copy EMCLI Login Script
ansible.builtin.template:
src: emcli_login.sh.j2
Expand All @@ -44,8 +43,8 @@
- name: Import Extensions
include_tasks: import_metric_extension.yml
vars:
metric_extension_path: "{{ metric_extension }}"
metric_extension_name: "{{ metric_extension.split('/')[-1] }}"
metric_extension_path: "{{ metric_extension }}"
metric_extension_name: "{{ metric_extension.split('/')[-1] }}"
loop: "{{ metric_extensions }}"
loop_control:
loop_var: metric_extension
Expand All @@ -70,41 +69,41 @@

- name: Get Versions
debug:
var: get_metric_extensions_versions
var: get_metric_extensions_versions

- name: Initialize Dictionary of Metric Extension Versions
set_fact:
metric_extensions_versions: {}
metric_extensions_versions: {}

- name: Create Dictionary of Metric Extension Versions
set_fact:
metric_extensions_versions: "{{ metric_extensions_versions | combine({extension.split('|')[0]: extension.split('|')[1] }) }}"
metric_extensions_versions: "{{ metric_extensions_versions | combine({extension.split('|')[0]: extension.split('|')[1] }) }}"
loop: "{{ get_metric_extensions_versions.stdout_lines | select('match','^EXTENSION=') | list | map('regex_replace','^EXTENSION=','') | list }}"
loop_control:
loop_var: extension
loop_var: extension

- name: Show Versions
debug:
var: metric_extensions_versions
var: metric_extensions_versions

# All Metric Extensions are Designed for the Host Target
# Note from EM 13c Licensing Doc: https://docs.oracle.com/cd/E63000_01/OEMLI/base_functionality.htm
# Create new metrics to monitor conditions specific to customer environments.
# Note: Metric Extensions are available free of charge only for the host target and not for other targets.
- name: Save Latest Versions of Metric Extensions as Deployable Draft
shell: |
echo "running emcli_login.sh"
. {{ stage }}/emcli_login.sh
{{ emcli }} save_metric_extension_draft -target_type="host" -name="{{ extension | regex_replace('\$','\\$') }}" -version="{{ metric_extensions_versions[extension] }}"
echo "running emcli_login.sh"
. {{ stage }}/emcli_login.sh
{{ emcli }} save_metric_extension_draft -target_type="host" -name="{{ extension | regex_replace('\$','\\$') }}" -version="{{ metric_extensions_versions[extension] }}"
loop: "{{ metric_extensions_versions.keys() }}"
loop_control:
loop_var: extension
loop_var: extension
register: save_as_draft
failed_when:
- save_as_draft.stderr != ''
- not save_as_draft.stderr is search('.*Only metric extensions in editable status can be saved as a deployable draft.*')
failed_when:
- save_as_draft.stderr != ''
- not save_as_draft.stderr is search('.*Only metric extensions in editable status can be saved as a deployable draft.*')
changed_when:
- save_as_draft.stderr == ''
- save_as_draft.stderr == ''

- pause:
seconds: 30
Expand All @@ -128,13 +127,12 @@
====================================================================================
always:

- name: Remove EMCLI Login Script
file:
path: "{{ stage }}/{{ file_name }}"
state: absent
loop:
- emcli_login.sh
- get_metric_extensions_versions.sql
loop_control:
loop_var: file_name
- name: Remove EMCLI Login Script
file:
path: "{{ stage }}/{{ file_name }}"
state: absent
loop:
- emcli_login.sh
- get_metric_extensions_versions.sql
loop_control:
loop_var: file_name
2 changes: 1 addition & 1 deletion ansible/roles/oracle-oms-setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@
tags:
- amibuild
- ec2provision
- import_metric_extensions
- import_metric_extensions

0 comments on commit b71ef0a

Please sign in to comment.