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

Allow JSON input as parameter #109

Closed
grantomation opened this issue Jul 16, 2022 · 1 comment
Closed

Allow JSON input as parameter #109

grantomation opened this issue Jul 16, 2022 · 1 comment
Assignees
Labels
need-to-triage Requires investigation

Comments

@grantomation
Copy link

Hello there,
I am trying to use your module to deploy an Azure Red Hat OpenShift. To deploy a cluster correctly the deployment requires the use of a pull secret from Red Hat which is in json format (structure below). Unforuntately I cannot seem to get the bicep module finish using github actions unless I hard code the pull secret in the bicep file itself. This is obviously not ideal. I have tried using github envs and github secrets but they result in the bicep file failing due to "an invalid secret", through troubleshooting this is because github actions places *** throughout the json.

pullSecret.json

{
  "auths": {
     "cloud.openshift.com" : {
         "auth": "XXXXXXX",
         "email": "user@email.com"
     },
     "quay.io" : {
         "auth": "XXXXXXX",
         "email": "user@email.com"
     },
     "registry.connect.redhat.com" : {
         "auth": "XXXXXXX",
         "email": "user@email.com"
     },
     "registry.redhat.com" : {
         "auth": "XXXXXXX",
         "email": "user@email.com"
     }
  }
}

The job from the github action workflow;

jobs:
   deploy_aro:
   runs_on: ubuntu-latest
   steps:
    - name: checkout code
      uses: actions/checkout@main

    - name: azure login
      uses: azure/login@v1
      with:
        creds: ${{ secrets.AZURE_CREDENTIALS }}

    - name: aro_cluster
      uses: azure/arm-deploy@v1
      with:
        scope: resourcegroup
        subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }}
        resourceGroupName: ${{ secrets.RG_NAME }}
        template: aro.bicep
        parameters: parameters.json pullSecret="${{ secrets.PULL_SECRET }}" location="${{ env.LOCATION }}" 

I have experimented writing the secret to a json file on the runner and then trying extract the contents to a parameter, but again no success. In the OpenShift documentation the pullsecret file is referenced using the "@" symbol[1], or as a parameter override with the pull secret contents in an environment file[2].

  1. Using the @ symbol to reference the file
az aro create \
  --resource-group $RESOURCEGROUP \
  --name $CLUSTER \
  --vnet aro-vnet \
  --master-subnet master-subnet \
  --worker-subnet worker-subnet --pull-secret @pullSecret.json
  1. Using the contents of the pullsecret as an override when deploying a bicep module.
az deployment group create \
    --name aroDeployment \
    --resource-group $RESOURCEGROUP \
    --template-file azuredeploy.json \
    --parameters location=$LOCATION \
    --parameters domain=$DOMAIN \
    --parameters pullSecret=$PULL_SECRET \
    --parameters clusterName=$ARO_CLUSTER_NAME \
    --parameters aadClientId=$SP_CLIENT_ID \
    --parameters aadObjectId=$SP_OBJECT_ID \
    --parameters aadClientSecret=$SP_CLIENT_SECRET \
    --parameters rpObjectId=$ARO_RP_SP_OBJECT_ID

Is there a way to use the contents of a json file as a parameter in this module?
Perhaps if this cannot be done then you could advise on another appropriate way using this module?

Reference links;
[1] https://docs.microsoft.com/en-au/azure/openshift/tutorial-create-cluster#get-a-red-hat-pull-secret-optional
[2] https://docs.microsoft.com/en-au/azure/openshift/quickstart-openshift-arm-bicep-template?pivots=aro-bicep#deploy-the-cluster---azure-cli

@grantomation grantomation added the need-to-triage Requires investigation label Jul 16, 2022
@grantomation
Copy link
Author

I escaped the quotes in the github secret using the advice posted in the other post #36 (comment).

This worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-to-triage Requires investigation
Projects
None yet
Development

No branches or pull requests

3 participants