Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create superset of application groups #1086

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion ansible/roles/oracle-oms-setup/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,21 @@ emcli: "{{ oem_mw_home }}/bin/emcli"
# Note that the value must exactly match the tag.applications JSON value
# as defined in modernisation-platform/environments/<application>.json as
# this is used to create the application tag on the instances running Oracle.
application_groups: ["delius", "nomis", "oasys", "corporate-staff-rostering", "hmpps-oem"]
#
# Note that hmpps-oem appears under Prisons and Probation since it is a shared
# infrastructure used by both application areas.

application_groups:
prisons:
- nomis
- oasys
- corporate-staff-rostering
- hmpps-oem
probation:
- delius
- iaps
- hmpps-oem

emctl: "{{ oem_agent_base }}/agent_inst/bin/emctl"

# For targets without Diagnostics pack the following directory is used to
Expand Down
27 changes: 25 additions & 2 deletions ansible/roles/oracle-oms-setup/tasks/create_group.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
loop:
- emcli_login.sh
- create_group.sh
- create_superset_group.sh

- name: Run Dynamic Group Creation Script
ansible.builtin.shell: |
echo "To resolve - Error: Some required configuration is missing, corrupt, inaccessible, or insecure (access permissions are too liberal)."
echo "Resolve the problem and run setup."
chown -R oracle:oinstall /u01/app/oracle/product/gc_inst135/em/EMGC_OMS1/sysman/emcli/setup/.emcli

- name: Run Dynamic Group Creation Script
- name: Run Dynamic Group Creation Script for Each Application
become_user: oracle
ansible.builtin.shell: |
echo "running emcli_login.sh"
Expand All @@ -28,12 +29,33 @@
{{ stage }}/create_group.sh
register: run_group_creation
changed_when: run_group_creation.stdout is search('.*dynamic group created.*')
loop: "{{ application_groups }}"
loop: "{{ application_groups.values() | flatten | unique }}"
loop_control:
loop_var: application_name
environment:
APPLICATION: "{{ application_name }}"

# We create "superset" groups which group Prisons applications together
# or Probation applications together. The hmpps-oem application appears
# in both superset groups since it is shared.
# In contrast to the application groups, the superset is a static group
# as it does not need to automatically add new targets.
- name: Create Application Superset Groups
become_user: oracle
ansible.builtin.shell: |
echo "running emcli_login.sh"
{{ stage }}/emcli_login.sh
echo "running create_superset_group.sh"
{{ stage }}/create_superset_group.sh
register: run_supserset_group_creation
changed_when: run_supserset_group_creation.stdout is search('Group .*created successfully.*')
loop: "{{ application_groups.keys() }}"
loop_control:
loop_var: application_superset_name
environment:
SUPERSET: "{{ application_superset_name }}"
MEMBERS: "{{ application_groups[application_superset_name] | sort | join(',') }}"

always:
- name: Remove Group Creation scripts from Staging Area
ansible.builtin.file:
Expand All @@ -42,3 +64,4 @@
loop:
- emcli_login.sh
- create_group.sh
- create_superset_group.sh
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 @@ -58,7 +58,7 @@
tags:
- amibuild
- ec2provision
- dynamic_group
- create_groups

- import_tasks: import_incident_rule_set.yml
tags:
Expand Down
18 changes: 9 additions & 9 deletions ansible/roles/oracle-oms-setup/tasks/oem_ru_upgrade.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
---
- name: Prerequisites
include: oms_ru_upgrade_prerequisites.yml
include_tasks: oms_ru_upgrade_prerequisites.yml

- name: Download software from s3 bucket
include: download_oem_ru_software.yml
include_tasks: download_oem_ru_software.yml
tags: download

- name: Update OMSPatcher
include: oms_upgrade_omspatcher.yml
include_tasks: oms_upgrade_omspatcher.yml
tags: omspatcher_upgrade

- name: Update OPatch
include: oms_upgrade_opatch.yml
include_tasks: oms_upgrade_opatch.yml
tags: oms_opatch_upgrade

- name: Create OMSPatcher properties file
include: create_omspatcher_property_file.yml
include_tasks: create_omspatcher_property_file.yml
tags: oms_property_file

- name: Apply required patches to OMS
include: apply_oms_patch.yml
include_tasks: apply_oms_patch.yml
tags: patch_oms

- name: Update AgentPatcher
include: oms_upgrade_agentpatcher.yml
include_tasks: oms_upgrade_agentpatcher.yml
tags: omspatcher_upgrade

- name: Upgrade central agent
include: apply_agent_patch.yml
include_tasks: apply_agent_patch.yml
tags: upgrade_agent

- name: Remove files from staging area
include: cleanup.yml
include_tasks: cleanup.yml
vars:
patch_type: agent
tags: patch_agent
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
#
# Creates OEM Dynamic Groups for each Application "Superset"
# which is either "Prisons" or "Probation"; this allows common
# application areas to be grouped together.

. ~/.bash_profile
export JAVA_HOME=$ORACLE_HOME/jdk/jre

if [ $( {{ emcli }} get_groups -noheader -script | cut -f1 | grep -Ec ${SUPERSET} ) -gt 0 ] ; then
echo "${SUPERSET} group already exists."
# Check if membership is correct
EXISTING_MEMBERSHIP=$({{ emcli }} get_group_members -name=${SUPERSET} | awk '$2~/^group$/{print $1}' | sort | paste -sd,)
if [[ "${EXISTING_MEMBERSHIP}" != "${MEMBERS}" ]];
then
echo "${SUPERSET} group membership has changed. Dropping to allow it to be re-created."
{{ emcli }} delete_group -name=${SUPERSET}
echo "Waiting for group removal"
sleep 60
fi
fi

# Create or recreate the supserset group
if [ $( {{ emcli }} get_groups -noheader -script | cut -f1 | grep -Ec ${SUPERSET} ) -eq 0 ] ; then
TARGETS=$(echo ${MEMBERS} | sed 's/,/:group;/g; s/$/:group/')
{{ emcli }} create_group -name=${SUPERSET} -add_targets="${TARGETS}"
if [[ $? -eq 0 ]]; then
echo "New ${SUPERSET} static group created."
fi
fi