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

nomis-misload secrets #408

Merged
merged 1 commit into from
Nov 21, 2023
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
6 changes: 3 additions & 3 deletions ansible/roles/nomis-misload/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ misload_monitoring_cron:
job: "su oracle -c '/home/oracle/admin/misload_scripts/{{ misload_monitoring_script }}' | logger -p local3.info -t misload"

misload_dbname: "{{ ec2.tags['misload-dbname'] }}"
misload_secret_parameter: "/oracle/database/{{ misload_dbname }}/misload-config"
misload_secret_name: "/oracle/database/{{ misload_dbname }}/misload-config"
use_ssm_params: false
misload_secretsmanager_passwords:
misload:
parameter: "{{ misload_secret_parameter }}"
secret: "{{ misload_secret_parameter }}"
parameter: "{{ misload_secret_name }}"
secret: "{{ misload_secret_name }}"
users:
- target:
- username:
Expand Down
10 changes: 0 additions & 10 deletions ansible/roles/nomis-misload/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
# needs testing
# - name: Get secretsmanager passwords
# block:
# - name: secretsmanager passwords
Expand Down Expand Up @@ -40,15 +39,6 @@

# when: use_ssm_params

- name: Get misload config
import_role:
name: ssm-passwords
vars:
ssm_passwords: "{{ misload_ssm_passwords }}"
tags:
- always
when: ec2.tags['misload-dbname'] is defined and ansible_facts['distribution'] == "RedHat"

# included to prevent having to debug connections in the actual task if the target is not reachable
- import_tasks: "misload-connection-check.yml"
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

export PATH=$PATH:/usr/local/bin

target=$(aws ssm get-parameter --name "{{ misload_secret_parameter }}" --query Parameter.Value --with-decryption --output text | jq -r .target)
username=$(aws ssm get-parameter --name "{{ misload_secret_parameter }}" --query Parameter.Value --with-decryption --output text | jq -r .username)
password=$(aws ssm get-parameter --name "{{ misload_secret_parameter }}" --query Parameter.Value --with-decryption --output text | jq -r .password)
secret_data=$(aws secretsmanager get-secret-value --secret-id "{{ misload_secret_name }}" --query SecretString --output text)
target=$(echo $secret_data | jq -r .target)
username=$(echo $secret_data | jq -r .username)
password=$(echo $secret_data | jq -r .password)

{{ ansible_python_interpreter }} /usr/local/share/winrm_connection_check.py -u "$username" -p "$password" -t "$target"
10 changes: 6 additions & 4 deletions ansible/roles/nomis-misload/templates/trigger_mis_load.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

export PATH=$PATH:/usr/local/bin

target=$(aws ssm get-parameter --name "{{ misload_secret_parameter }}" --query Parameter.Value --with-decryption --output text | jq -r .target)
username=$(aws ssm get-parameter --name "{{ misload_secret_parameter }}" --query Parameter.Value --with-decryption --output text | jq -r .username)
password=$(aws ssm get-parameter --name "{{ misload_secret_parameter }}" --query Parameter.Value --with-decryption --output text | jq -r .password)
secret_data=$(aws secretsmanager get-secret-value --secret-id "{{ misload_secret_name }}" --query SecretString --output text)
target=$(echo $secret_data | jq -r .target)
username=$(echo $secret_data | jq -r .username)
password=$(echo $secret_data | jq -r .password)


if [[ -z $target || $target == "null" || $target == "None" ||
-z $username || $username == "null" || $username == "None" ||
-z $password || $password == "null" || $password == "None" ]]; then
echo "Could not retrieve config from {{ misload_secret_parameter }}"
echo "Could not retrieve config from {{ misload_secret_name }}"
echo "misload_status 1" > /opt/textfile_monitoring/misload_status.prom
exit 1
fi
Expand Down
Loading