|
1 | 1 | - name: Set Secrets Dictionary
|
2 | 2 | set_fact:
|
| 3 | + account_name: "hmpps-oem-{{ aws_environment }}" |
| 4 | + assume_role_name: "EC2OracleEnterpriseManagementSecretsRole" |
3 | 5 | secretsmanager_passwords:
|
4 | 6 | emrep:
|
5 |
| - account_name: "hmpps-oem-{{ aws_environment }}" |
6 |
| - assume_role_name: "EC2OracleEnterpriseManagementSecretsRole" |
7 | 7 | secret: "/oracle/database/EMREP/shared-passwords"
|
8 | 8 | users:
|
9 | 9 | - sysman:
|
10 | 10 | catalog:
|
11 |
| - account_name: "hmpps-oem-{{ aws_environment }}" |
12 |
| - assume_role_name: "EC2OracleEnterpriseManagementSecretsRole" |
13 | 11 | secret: "/oracle/database/{{ catalog }}/shared-passwords"
|
14 | 12 | users:
|
15 | 13 | - rcvcatowner:
|
|
18 | 16 | set_fact:
|
19 | 17 | account_ids: "{{ lookup('aws_ssm', 'account_ids', region='eu-west-2') }}"
|
20 | 18 |
|
21 |
| -- name: Get OEM secrets |
22 |
| - import_role: |
23 |
| - name: secretsmanager-passwords |
24 |
| - vars: |
25 |
| - secretsmanager_passwords: "{{ secretsmanager_passwords }}" |
| 19 | +- name: Copy Get Facts Script On Conditions |
| 20 | + when: (tnsnames_entry_exists is defined and not tnsnames_entry_exists) or (get_slack_channel is defined) or (copy_script | default(false) | bool) |
| 21 | + block: |
| 22 | + - name: Copy Get Facts Script |
| 23 | + template: |
| 24 | + src: get_facts_script.sh.j2 |
| 25 | + dest: /u02/stage/get_facts_script.sh |
| 26 | + mode: "0700" |
26 | 27 |
|
27 |
| -- name: Set password facts |
28 |
| - set_fact: |
29 |
| - sysman_password: "{{ secretsmanager_passwords_dict['emrep'].passwords['sysman'] }}" |
30 |
| - rcvcatowner_password: "{{ secretsmanager_passwords_dict['catalog'].passwords['rcvcatowner'] }}" |
31 |
| - getslacktoken: "{{ secretsmanager_passwords_dict['emrep'].passwords['slack_token'] }}" |
| 28 | + - name: Catalog Host Name |
| 29 | + when: |
| 30 | + - tnsnames_entry_exists is defined |
| 31 | + - not tnsnames_entry_exists |
| 32 | + block: |
| 33 | + - name: Set Emcli Catalog Host Name Command |
| 34 | + set_fact: |
| 35 | + emcli_commands: | |
| 36 | + {{ emcli }} get_targets -noheader -targets="%:oracle_oms" | awk '{print $NF}' | cut -d: -f1 |
32 | 37 |
|
33 |
| -- name: Catalog Host Name |
34 |
| - when: |
35 |
| - - tnsnames_entry_exists is defined |
36 |
| - - not tnsnames_entry_exists |
37 |
| - block: |
38 |
| - - name: Get Catalog Host Name |
39 |
| - shell: | |
40 |
| - . ~/.bash_profile |
41 |
| - export PATH=$PATH:/u01/app/oracle/product/oem-agent/agent_{{ OEM_AGENT_VERSION }}/oracle_common/jdk/jre/bin |
42 |
| - {{ emcli }} sync 1>/dev/null 2>&1 || ( {{ emcli }} login -username=sysman -password=${SYSMAN_PASSWORD} -force && {{ emcli }} sync ) 1>/dev/null 2>&1 |
43 |
| - {{ emcli }} get_targets -noheader -targets="%:oracle_oms" | awk '{print $NF}' | cut -d: -f1 |
44 |
| - environment: |
45 |
| - SYSMAN_PASSWORD: "{{ sysman_password }}" |
46 |
| - register: getcataloghostname |
| 38 | + - name: Get Catalog Host Name |
| 39 | + ansible.builtin.command: > |
| 40 | + /u02/stage/get_facts_script.sh |
| 41 | + environment: |
| 42 | + ACCOUNT_NAME: "{{ account_name }}" |
| 43 | + ASSUME_ROLE_NAME: "{{ assume_role_name }}" |
| 44 | + EMCLI_COMMANDS: "{{ emcli_commands }}" |
| 45 | + register: getcataloghostname |
| 46 | + changed_when: false |
47 | 47 |
|
48 |
| - - name: Set Catalog Host Name |
49 |
| - set_fact: |
50 |
| - catalog_hostname: "{{ getcataloghostname.stdout }}" |
| 48 | + - name: Set Catalog Host Name |
| 49 | + set_fact: |
| 50 | + catalog_hostname: "{{ getcataloghostname.stdout }}" |
51 | 51 |
|
52 |
| -- name: Slack Channel |
53 |
| - when: get_slack_channel is defined |
54 |
| - block: |
55 |
| - - name: Get Slack Channel |
56 |
| - shell: | |
57 |
| - . ~/.bash_profile |
58 |
| - export PATH=$PATH:/u01/app/oracle/product/oem-agent/agent_{{ OEM_AGENT_VERSION }}/oracle_common/jdk/jre/bin |
59 |
| - {{ emcli }} sync 1>/dev/null 2>&1 || ( {{ emcli }} login -username=sysman -password=${SYSMAN_PASSWORD} -force && {{ emcli }} sync ) 1>/dev/null 2>&1 |
60 |
| - {{ emcli }} list -resource=TargetProperties -search="TARGET_NAME='{{ database_sid }}'" -search="PROPERTY_NAME='orcl_gtp_contact'" -columns="PROPERTY_VALUE" -colsize="PROPERTY_VALUE:30" -noheader -format="name:script" |
61 |
| - environment: |
62 |
| - SYSMAN_PASSWORD: "{{ sysman_password }}" |
63 |
| - register: getslackchannel |
| 52 | + - name: Slack Channel |
| 53 | + when: get_slack_channel is defined |
| 54 | + block: |
| 55 | + - name: Set Emcli Slack Channel Command |
| 56 | + set_fact: |
| 57 | + emcli_commands: | |
| 58 | + {{ emcli }} list -resource=TargetProperties -search="TARGET_NAME='{{ database_sid }}'" -search="PROPERTY_NAME='orcl_gtp_contact'" -columns="PROPERTY_VALUE" -colsize="PROPERTY_VALUE:30" -noheader -format="name:script" |
| 59 | +
|
| 60 | + - name: Get Slack Channel |
| 61 | + ansible.builtin.command: > |
| 62 | + /u02/stage/get_facts_script.sh |
| 63 | + environment: |
| 64 | + ACCOUNT_NAME: "{{ account_name }}" |
| 65 | + ASSUME_ROLE_NAME: "{{ assume_role_name }}" |
| 66 | + CATALOG_SECRET: "{{ secretsmanager_passwords['catalog'].secret }}" |
| 67 | + EMCLI_COMMANDS: "{{ emcli_commands }}" |
| 68 | + register: getslackchannel |
| 69 | + changed_when: false |
64 | 70 |
|
65 |
| - - name: Setup Slack Configuration |
66 |
| - set_fact: |
67 |
| - slack_channel: "{{ getslackchannel.stdout }}" |
| 71 | + - name: Setup Slack Configuration |
| 72 | + set_fact: |
| 73 | + slack_channel: "{{ getslackchannel.stdout }}" |
0 commit comments