F5Networks / f5-google-gdm-templates-v2

Google Deployment Templates for quickly deploying BIG-IP services in Google Cloud Platform
5 stars 13 forks source link

Example - failover: error on getting secret for BIGIP_PASSWORD #5

Closed curtkersey closed 2 years ago

curtkersey commented 2 years ago

Describe the bug

Once the deployment was completed, I was looking for password for BIG-IP devices. I could not find it any where - no new entry created in Secret Manager in GCP console. I was able to SSH into the BIG-IP, and I found an error in the bigIpRuntimeInit.log file:

2022-03-15T14:41:24.640Z [19216]: info: Configuration file: /config/cloud/runtime-init-conf.yaml 2022-03-15T14:41:24.667Z [19216]: info: Validating provided declaration 2022-03-15T14:41:24.663Z [19216]: info: Processing controls parameters 2022-03-15T14:41:24.790Z [19216]: info: Successfully validated declaration 2022-03-15T14:41:24.858Z [19216]: info: Resolving parameters 2022-03-15T14:41:26.187Z [19216]: error: Error getting secret from mySecretId Secret [projects/326061033782/secrets/mySecretId] not found or has no versions. 2022-03-15T14:41:26.188Z [19216]: info: Sending F5 Teem report for failure case. 2022-03-15T14:41:26.933Z [19216]: info: {"id":"a71fd2d5-c4fd-dc9c-f404bdbd31ef","product":"BIG-IP","cpuCount":8,"diskSize":81920,"memoryInMb":30160,"version":"16.1.0","nicCount":3,"regKey":"DIVTH-AGXAH-NWJPK-JIVCY-PFMWMHA","platformId":"Z100","hostname":"bigip1","management":"10.0.0.11/32","provisionedModules":{"ltm":"nominal"},"installedPackages":{},"environment":{"pythonVersion":"Python 2.7.5","pythonVersionDetailed":"2.7.5 (default, Jun 22 2021, 22:47:51) \n[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]","nodeVersion":"v6.9.1","libraries":{"ssh":"OpenSSH_7.4p1, OpenSSL 1.0.2u-fips 20 Dec 2019"}}} 2022-03-15T14:41:38.463Z [19216]: info: F5 Teem report was successfully sent for failure case. 2022-03-15T14:41:38.464Z [19216]: info: Error getting secret from mySecretId Secret [projects/326061033782/secrets/mySecretId] not found or has no versions.

Expected behavior

Create secret for BIG-IP password.

Current behavior

Error message regarding secret in log file -- see above.

Possible solution

TBD.

Steps to reproduce

will add YAML file that was used by deployments manager is below. I ran that via gcloud CLI command.

Context

Trying to deploy HA pair using templates.

Your Environment

Running gcloud CLI from generic Ubuntu 18.04LTS host.

curtkersey commented 2 years ago

yamllint disable rule:line-length

Copyright 2021 F5 Networks All rights reserved.

#

Version 2.0.0.0

#

NOTE: When filling out the parameter values for this deployment:

Deployments leverage .schema files to help enforce requirements/parameter typing and defaults.

'###' Will be used above each parameter and contain description of values required

REQUIRED parameters values are left empty and value MUST be entered.

OPTIONAL parameters contain defaults (same default from schema file). However, some are deployment specific and generally should be modified to match your environment.

#

CAUTION:

Use single quotes around strings when supplying special characters or list of values. Example: applicationPort '443 444 445'.

Required fields left empty or faulty values (ex. typos, incorrect timezone strings, etc.)

can result in various classes of failures, from template launch failures to silent BIG-IP deployment failures.

Use the Troubleshooting section at the bottom of this .yaml to understand if the template and BIG-IP deployed correctly.

imports:

f5-applebaum commented 2 years ago

Created ESECLDTPLT-3024.

Creating Secret needs to be emphasized more, added to Pre-Req section (like have in AWS https://github.com/F5Networks/f5-aws-cloudformation-v2/tree/main/examples/failover#prerequisites)

https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets#create ex.

$ vim password.txt

$ gcloud secrets create mySecretId --data-file="password.txt"
curtkersey commented 2 years ago

I used the command to create the mySecretId secret, and it got further; however, it did not complete. BIG-IP devices are still in standalone state with no configuration. The password was also not set to the value of mySecretId. I ssh'ed into the instance to set it manually, and then I could login to TMUI.

Here is output of /var/log/cloud/bigIpRuntimeInit.log:

2022-03-16T14:47:37.362Z [19082]: info: Configuration file: /config/cloud/runtime-init-conf.yaml 2022-03-16T14:47:37.391Z [19082]: info: Validating provided declaration 2022-03-16T14:47:37.387Z [19082]: info: Processing controls parameters 2022-03-16T14:47:37.512Z [19082]: info: Successfully validated declaration 2022-03-16T14:47:37.604Z [19082]: info: Resolving parameters 2022-03-16T14:47:38.972Z [19082]: info: Executing install operations. 2022-03-16T14:47:38.985Z [19082]: info: Installing - do 1.27.0 2022-03-16T14:47:41.517Z [19082]: info: Validating - do extension is available. 2022-03-16T14:47:51.552Z [19082]: info: Installing - as3 3.34.0 2022-03-16T14:47:55.286Z [19082]: info: Validating - as3 extension is available. 2022-03-16T14:48:18.182Z [19082]: info: Installing - cf 1.10.0 2022-03-16T14:48:24.401Z [19082]: info: Validating - cf extension is available. 2022-03-16T14:48:37.443Z [19082]: info: Executing service operations. 2022-03-16T14:48:37.447Z [19082]: error: Unexpected token in JSON at position 778 2022-03-16T14:48:37.448Z [19082]: info: Sending F5 Teem report for failure case. 2022-03-16T14:48:38.109Z [19082]: info: {"id":"f27aafba-b112-1ed3-4e4dae55bd42","product":"BIG-IP","cpuCount":8,"diskSize":81920,"memoryInMb":30160,"version":"16.1.0","nicCount":3,"regKey":"DIVTH-AGXAH-NWJPK-JIVCY-PFMWMHA","platformId":"Z100","hostname":"bigip1","management":"10.0.0.11/32","provisionedModules":{"ltm":"nominal"},"installedPackages":{"f5-service-discovery-1.10.6-1.noarch":"1.10.6","f5-declarative-onboarding-1.27.0-6.noarch":"1.27.0","f5-cloud-failover-1.10.0-0.noarch":"1.10.0","f5-appsvcs-3.34.0-4.noarch":"3.34.0"},"environment":{"pythonVersion":"Python 2.7.5","pythonVersionDetailed":"2.7.5 (default, Jun 22 2021, 22:47:51) \n[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]","nodeVersion":"v6.9.1","libraries":{"ssh":"OpenSSH_7.4p1, OpenSSL 1.0.2u-fips 20 Dec 2019"}}} 2022-03-16T14:48:49.515Z [19082]: info: F5 Teem report was successfully sent for failure case. 2022-03-16T14:48:49.516Z [19082]: info: Unexpected token in JSON at position 778

After logging in and going thru the initial configuration via TMUI, I was able to confirm that AS3, DO, CFE, and Service Discovery were installed on the instance.

I will also attach the full log file: startup-script-post-swap-nic.log

curtkersey commented 2 years ago

When using the command above to set password via a file, password.txt, the editor (vi in this case) is adding a NEWLINE character to the end of the password. This causes an error when the BIG-IP runtime init is running since the password has the illegal character in it. To work around this problem, I set the secret via command line (see command below), and everything worked well:

% echo -n "MyPassw0rd" | gcloud secrets versions add mySecretId --data-file=-

Note: I used 'versions add' since I had already created mySecretId in the previous step.

alexapplebaum commented 2 years ago

Thanks for the notice re: newline. We will make sure we put a note to ensure there is no newline at the end of the file.

KrithikaChidambaram commented 2 years ago

This was fixed in the v2.2.0.0 release. Closing this.