Skip to content

Commit 38d9ad3

Browse files
committed
Restrict test log outputs
This to avoid printing secrets into logs, as another layer of security, even though the CI environments are isolated and short-lived. The change does the following: * Default `use_no_log: true`. * Add `use_no_log` onto more tasks. * Disable xtrace (`set -x`) on such tasks as another precaution. This is done via a new `shell_header_no_xtrace` variable so that the behavior is not hardcoded. If debugging of the relevant tasks is necessary, it can be done by tweaking these variables for a testproject. Assisted by: goose+gemini
1 parent 49689b0 commit 38d9ad3

11 files changed

Lines changed: 44 additions & 1 deletion

File tree

tests/roles/backend_services/tasks/main.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
- name: create osp-secret
2+
no_log: "{{ use_no_log }}"
23
ansible.builtin.shell: |
34
{{ shell_header }}
5+
{{ shell_header_no_xtrace }}
46
{{ oc_header }}
57
cd {{ install_yamls_path }}
68
make input
@@ -15,6 +17,7 @@
1517
no_log: "{{ use_no_log }}"
1618
ansible.builtin.shell: |
1719
{{ shell_header }}
20+
{{ shell_header_no_xtrace }}
1821
{{ oc_header }}
1922
{% if aodh_password %}
2023
oc set data secret/osp-secret "AodhPassword={{ aodh_password }}"

tests/roles/backend_services/tasks/ospdo_backend_services.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
- name: get service passwords
2+
no_log: "{{ use_no_log }}"
23
ansible.builtin.shell: |
4+
{{ shell_header_no_xtrace }}
35
oc get secret tripleo-passwords -o jsonpath='{.data.*}' | base64 -d>~/tripleo-standalone-passwords.yaml
46
cp ~/tripleo-standalone-passwords.yaml {{ tripleo_passwords['default'] | replace("~", "$HOME") }}
57
when: get_svc_pass| default(false) | bool

tests/roles/barbican_adoption/tasks/main.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
- name: patch osp-secret with kek
2+
no_log: "{{ use_no_log }}"
23
ansible.builtin.shell: |
34
{{ shell_header }}
5+
{{ shell_header_no_xtrace }}
46
{{ oc_header }}
57
CONTROLLER1_SSH="{{ controller1_ssh }}"
68
oc set data secret/osp-secret "BarbicanSimpleCryptoKEK=$($CONTROLLER1_SSH \
@@ -10,8 +12,10 @@
1012
1113
- name: Create HSM login secret for Barbican
1214
when: barbican_hsm_enabled|default(false)
15+
no_log: "{{ use_no_log }}"
1316
ansible.builtin.shell: |
1417
{{ shell_header }}
18+
{{ shell_header_no_xtrace }}
1519
{{ oc_header }}
1620
cat <<EOF | oc apply -f -
1721
apiVersion: v1

tests/roles/common_defaults/defaults/main.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Whether to use no_log on tasks which may output potentially
22
# sensitive data.
3-
use_no_log: false
3+
use_no_log: true
44

55
# Network configuration for IPv4/IPv6 support
66
ipv6_enabled: false
@@ -29,6 +29,10 @@ renamed_cells: "{{ [default_cell_name] + cells | difference(['default']) }}"
2929
shell_header: |
3030
set -euxo pipefail
3131
32+
# Header to disable command tracing in tasks that handle sensitive data.
33+
shell_header_no_xtrace: |
34+
set +x
35+
3236
# Snippet to get the desired 'oc' command onto $PATH.
3337
oc_header: |
3438
eval $(crc oc-env)
@@ -133,6 +137,7 @@ mariadb_client_network_annotation: >-
133137
}}
134138
mariadb_copy_shell_vars_src: |-
135139
{{ shell_header }}
140+
{{ shell_header_no_xtrace }}
136141
137142
PASSWORD_FILE="{{ tripleo_passwords['default'] | replace("~", "$HOME") }}"
138143
@@ -170,6 +175,7 @@ mariadb_copy_shell_vars_src: |-
170175
# for any tables that are created in the future as part of db sync
171176
mariadb_copy_shell_vars_dst: |
172177
{{ shell_header }}
178+
{{ shell_header_no_xtrace }}
173179
{{ oc_header }}
174180
{{ mariadb_image_env }}
175181
{{ cells_env }}

tests/roles/dataplane_adoption/tasks/nova_ffu.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
- name: wait for Compute data plane services version updated for all cells
2+
no_log: "{{ use_no_log }}"
23
ansible.builtin.shell: |
4+
{{ shell_header_no_xtrace }}
35
{{ mariadb_copy_shell_vars_dst }}
46
for CELL in $(echo $RENAMED_CELLS); do
57
oc exec openstack-$CELL-galera-0 -c galera -- mysql -rs -uroot -p"${PODIFIED_DB_ROOT_PASSWORD[$CELL]}" \

tests/roles/dataplane_adoption/tasks/ospdo_dataplane.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Take the private ssh key (id_ra) from the /home/cloud-admin/.ssh/ directory of the openstackclient pod and create a secret in the osp18 namespace
22
- name: Create secret from openstackclient pod
3+
no_log: "{{ use_no_log }}"
34
ansible.builtin.shell: |
45
{{ shell_header }}
6+
{{ shell_header_no_xtrace }}
57
{{ oc_header }}
68
oc apply -f - <<EOF
79
apiVersion: v1
@@ -16,7 +18,12 @@
1618
1719
# needed for : https://github.com/openstack-k8s-operators/openstack-operator/blob/37f12745cc6971241f6d24fa9b0a28d39a428be7/config/services/dataplane_v1beta1_openstackdataplaneservice_libvirt.yaml#L8
1820
- name: Create secret for OpenStackDataPlaneService
21+
no_log: "{{ use_no_log }}"
1922
ansible.builtin.shell: |
23+
{{ shell_header }}
24+
{{ shell_header_no_xtrace }}
25+
{{ oc_header }}
26+
2027
LIBVIRT_PASSWORD=$(grep <"${PASSWORD_FILE}" ' LibvirtTLSPassword:' | awk -F ': ' '{ print $2; }')
2128
2229
oc apply -f - <<EOF

tests/roles/designate_adoption/tasks/designate_cr_config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
- name: Retrieve the known ns_record values from the designate database
2+
no_log: "{{ use_no_log }}"
23
ansible.builtin.shell: |
34
{{ shell_header }}
5+
{{ shell_header_no_xtrace }}
46
{{ oc_header }}
57
DB_ROOT_PASSWORD=$(oc get -o json secret/osp-secret | jq -r .data.DbRootPassword | base64 -d)
68
oc exec openstack-galera-0 -c galera -- mysql -rs -uroot -p"$DB_ROOT_PASSWORD" \

tests/roles/get_services_configuration/tasks/main.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- name: create mariadb-client container
2222
no_log: "{{ use_no_log }}"
2323
ansible.builtin.shell: |
24+
{{ shell_header_no_xtrace }}
2425
{{ oc_header }}
2526
{{ mariadb_copy_shell_vars_src }}
2627
# delete existing mariadb-client pods
@@ -31,6 +32,7 @@
3132
- name: wait until SOURCE_MARIADB_IP is reachable
3233
no_log: "{{ use_no_log }}"
3334
ansible.builtin.shell: |
35+
{{ shell_header_no_xtrace }}
3436
{{ oc_header }}
3537
{{ mariadb_copy_shell_vars_src }}
3638
oc rsh mariadb-client mysql -rsh ${SOURCE_MARIADB_IP[default]} -uroot -p${SOURCE_DB_ROOT_PASSWORD[default]} -e 'select 1;'
@@ -45,6 +47,7 @@
4547
- name: test connection to the original DB
4648
no_log: "{{ use_no_log }}"
4749
ansible.builtin.shell: |
50+
{{ shell_header_no_xtrace }}
4851
{{ oc_header }}
4952
{{ mariadb_copy_shell_vars_src }}
5053
unset PULL_OPENSTACK_CONFIGURATION_DATABASES
@@ -57,6 +60,7 @@
5760
- name: run mysqlcheck on the original DB to look for things that are not OK
5861
no_log: "{{ use_no_log }}"
5962
ansible.builtin.shell: |
63+
{{ shell_header_no_xtrace }}
6064
{{ oc_header }}
6165
{{ mariadb_copy_shell_vars_src }}
6266
unset PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK
@@ -86,6 +90,7 @@
8690
block:
8791
- name: get Nova cells mappings from database
8892
ansible.builtin.shell: |
93+
{{ shell_header_no_xtrace }}
8994
{{ oc_header }}
9095
{{ mariadb_copy_shell_vars_src }}
9196
export PULL_OPENSTACK_CONFIGURATION_NOVADB_MAPPED_CELLS=$(oc rsh mariadb-client \
@@ -94,6 +99,7 @@
9499
95100
- name: get the host names of the registered Nova compute services
96101
ansible.builtin.shell: |
102+
{{ shell_header_no_xtrace }}
97103
{{ oc_header }}
98104
{{ mariadb_copy_shell_vars_src }}
99105
unset PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES
@@ -113,6 +119,7 @@
113119
- name: store exported variables for future use
114120
no_log: "{{ use_no_log }}"
115121
ansible.builtin.shell: |
122+
{{ shell_header_no_xtrace }}
116123
{{ oc_header }}
117124
{{ mariadb_copy_shell_vars_src }}
118125
for CELL in $(echo $CELLS); do

tests/roles/heat_adoption/tasks/main.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
- name: Encode the heat_auth_encryption_key to base64 format
2+
no_log: "{{ use_no_log }}"
23
ansible.builtin.shell: |
34
{{ shell_header }}
5+
{{ shell_header_no_xtrace }}
46
echo {{ heat_auth_encryption_key }} | base64
57
register: heat_encoded_auth_key
68

79
- name: Patch osp-secret for HeatAuthEncryptionKey
10+
no_log: "{{ use_no_log }}"
811
ansible.builtin.shell: |
912
{{ shell_header }}
13+
{{ shell_header_no_xtrace }}
1014
{{ oc_header }}
1115
oc patch secret osp-secret --type='json' -p='[{"op" : "replace" ,"path" : "/data/HeatAuthEncryptionKey" ,"value" : "{{ heat_encoded_auth_key.stdout }}"}]'
1216

tests/roles/keystone_adoption/tasks/main.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,10 @@
199199
- enable_federation | default(false) | bool
200200
block:
201201
- name: Generate OIDC token after adoption
202+
no_log: "{{ use_no_log }}"
202203
ansible.builtin.shell: |
203204
{{ shell_header }}
205+
{{ shell_header_no_xtrace }}
204206
{{ oc_header }}
205207
206208
oc exec openstackclient -- bash -c "cat > /tmp/oidc_cloudrc" <<'EOF'
@@ -243,8 +245,10 @@
243245
failed_when: after_adoption_credential.stdout != 'test'
244246

245247
- name: get ldap user token
248+
no_log: "{{ use_no_log }}"
246249
ansible.builtin.shell: |
247250
{{ shell_header }}
251+
{{ shell_header_no_xtrace }}
248252
{{ oc_header }}
249253
250254
alias openstack="oc exec -t openstackclient -- openstack"

0 commit comments

Comments
 (0)