github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/e2e/terraform/packer/README.md (about)

     1  # Packer Builds
     2  
     3  These builds are run as-needed to update the AMIs used by the end-to-end test infrastructure.
     4  
     5  
     6  ## What goes here?
     7  
     8  * steps that aren't specific to a given Nomad build: ex. all Linux instances need `jq` and `awscli`.
     9  * steps that aren't specific to a given EC2 instance: nothing that includes an IP address.
    10  * steps that infrequently change: the version of Consul or Vault we ship.
    11  
    12  
    13  ## Running Packer builds
    14  
    15  ```sh
    16  $ packer --version
    17  1.4.4
    18  
    19  # build linux AMI
    20  $ packer build packer.json
    21  
    22  # build Windows AMI
    23  $ packer build packer-windows.json
    24  ```
    25  
    26  ## Debugging Packer Builds
    27  
    28  You'll need the Windows administrator password in order to access Windows machines via `winrm` as Packer does. You can get this by enabling `-debug` on your Packer build.
    29  
    30  ```sh
    31  packer build -debug -on-error=abort packer-windows.json
    32  ...
    33  ==> amazon-ebs: Pausing after run of step 'StepRunSourceInstance'. Press enter to continue.
    34  ==> amazon-ebs: Waiting for auto-generated password for instance...
    35      amazon-ebs: Password (since debug is enabled): <redacted>
    36  ```
    37  
    38  Alternately, you can follow the steps in the [AWS documentation](https://aws.amazon.com/premiumsupport/knowledge-center/retrieve-windows-admin-password/). Note that you'll need the `ec2_amazon-ebs.pem` file that Packer drops in this directory.
    39  
    40  
    41  Then in powershell (note the leading `$` here indicate variable declarations, not shell prompts!):
    42  
    43  ```
    44  $username = "Administrator"
    45  $password = "<redacted>"
    46  $securePassword = ConvertTo-SecureString -AsPlainText -Force $password
    47  $remoteHostname = "54.x.y.z"
    48  $port = 5986
    49  $cred = New-Object System.Management.Automation.PSCredential ($username, $securePassword)
    50  $so = New-PSSessionOption -SkipCACheck -SkipCNCheck
    51  
    52  Enter-PsSession `
    53      -ComputerName $remoteHostname `
    54      -Port $port `
    55      -Credential $cred `
    56      -UseSSL `
    57      -SessionOption $so `
    58      -Authentication Basic
    59  ```
    60  
    61  Packer doesn't have a cleanup command if you've run `-on-error=abort`. So when you're done, clean up the machine by looking for "Packer" in the AWS console:
    62  * [EC2 instances](https://console.aws.amazon.com/ec2/home?region=us-east-1#Instances:search=Packer;sort=tag:Name)
    63  * [Key pairs](https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#KeyPairs:search=packer;sort=keyName)
    64  * [Security groups](https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#SecurityGroups:search=packer;sort=groupName)