Add SAR script support for Openshift apps

Signed-off-by: Michal Konečný <mkonecny@redhat.com>
This commit is contained in:
Michal Konečný 2020-07-15 17:10:16 +02:00 committed by pingou
parent 2af20e5906
commit 04863be9e5
3 changed files with 34 additions and 0 deletions

View file

@ -14,3 +14,16 @@ nagios_Check_Services:
#
bodhi_version: 5.4.1
bodhi_openshift_pods: 2
# GDPR SAR related dictionary
sar_openshift:
# Name of the app
release-monitoring:
# Location of the script
sar_script: /usr/local/bin/sar.py
# Output file on local machine
sar_output_file: anitya.json
# Openshift namespace where the app runs
openshift_namespace: release-monitoring
# Name of openshift pod - will be used for label search
openshift_pod: release-monitoring-web

View file

@ -44,6 +44,12 @@
delegate_to: localhost
when: "sar_huge is defined and sar_huge"
- name: Gather SAR data - openshift apps
hosts: os_masters[0]
tasks:
- include_tasks: sar_openshift.yml
loop: "{{ lookup('dict', sar_openshift, wantlist=True) }}"
- name: Create the archive
hosts: localhost
tasks:

View file

@ -0,0 +1,15 @@
# Retrieve GDPR data from single openshift app.
# Get the correct pod
- name: Retrieve the id of the running container/pod
shell: "oc get -n {{ item.value.openshift_namespace }} -o name -l app={{ item.value.openshift_pod }} pods | cut -f 2 -d '/'"
register: pod_id
# Run the SAR script
- name: Run oc exec in container to extract the data
command: "oc -n {{ item.value.openshift_namespace }} rsh {{ pod_id.stdout }} bash -c 'SAR_USERNAME={{ sar_fas_user }} SAR_EMAIL={{ sar_email }} {{ item.value.sar_script }}'"
register: sar_data
# Store the result on disk
- name: Copy the output data locally
copy:
content: "{{ sar_data['stdout'] }}"
dest: "{{ hostvars['localhost']['sar_tmp_dir'] }}/{{ item.value.sar_output_file }}"
delegate_to: localhost