Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6025

Azure Image Builder (AIB): 'sudo apt update -y' fails with 'ERROR: Bad port'

$
0
0

Executing sudo apt update -y as part of a shell script from a Customizer "Shell" action fails with the following error message (packer logs):

ui:     azure-arm: + sudo apt update -yui:     azure-arm: Hit:1 http://azure.archive.ubuntu.com/ubuntu bionic InRelease... (truncated)ui:     azure-arm: 7Progress: [ 98%] [########################################################..] 87Progress: [ 99%] [#########################################################.] rocessing triggers for systemd (237-3ubuntu10.57) ...ui:     azure-arm: Processing triggers for man-db (2.8.3-2ubuntu0.1) ...ui:     azure-arm: Processing triggers for ufw (0.36-0ubuntu0.18.04.2) ...ui:     azure-arm: Processing triggers for ureadahead (0.100.0-21) ...ui:     azure-arm: Processing triggers for libc-bin (2.27-3ubuntu1.6) ...ui:     azure-arm:ui:     azure-arm: 'ui:     azure-arm: ERROR: Bad port

But when I execute the same command as an inline script it succeeds:

...    customize: [      {        name: 'Update System'        type: 'Shell'        inline: ['sudo apt update -y''DEBIAN_FRONTEND=noninteractive sudo apt install -y --no-install-recommends nginx''sudo ufw allow "Nginx HTTP"'        ]      }    ]...

Here are the Detailed Scripts

install.sh:

#!/bin/bashset -x;sudo apt update -yDEBIAN_FRONTEND=noninteractive sudo apt install -y --no-install-recommends nginxsudo ufw allow "Nginx HTTP"

.bicep template:

param ImageVersion string // = '0.0.4'param WorkspaceUri string // = 'https://bart.blob.core.windows.net/workspaces/fantastic.tar.gz'... (truncated)resource imageTemplate 'Microsoft.VirtualMachineImages/imageTemplates@2022-02-14' = {  location: resourceGroup().location  name: 'fantastic-image-template-${replace(ImageVersion, '.', '-')}'  identity: {    type: 'UserAssigned'    userAssignedIdentities: {'${resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', managedIdentity.name)}': {}    }  }  properties: {    vmProfile: {      vmSize: 'Standard_D4_v3'      osDiskSizeGB: 30    }    source: {      type: 'PlatformImage'      publisher: 'Canonical'      offer: 'UbuntuServer'      sku: '18.04-LTS'      version: 'latest'    }    customize: [    {       type: 'File'      name: 'download bundle'      sourceUri: WorkspaceUri      destination: '/tmp/fantastic.tar.gz'    }    {      name: 'unpack bundle'      type: 'Shell'      inline: ['mkdir -p /home/azureuser/fantastic''if [ $? -ne 0 ]; then exit 1; fi''tar -xvf /tmp/fantastic.tar.gz -C /home/azureuser/fantastic/''if [ $? -ne 0 ]; then exit 1; fi''chmod +x /home/azureuser/fantastic/*.sh''if [ $? -ne 0 ]; then exit 1; fi'      ]    }    {      name: 'execute scripts'      type: 'Shell'      inline: ['/home/azureuser/fantastic/install.sh''if [ $? -ne 0 ]; then exit 1; fi''rm -rf /home/azureuser/fantastic' // cleanup      ]    }    ]    distribute: [      {        type: 'VHD'        runOutputName: 'fantastic-vhd-${replace(ImageVersion, '.', '-')}'      }    ]  }}

Viewing all articles
Browse latest Browse all 6025

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>