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

WIP: Basic support for -connection-info flag #6863

Closed

Conversation

rickard-von-essen
Copy link
Collaborator

This adds the -connection-info flag to the build command causing all
relevant connection information (IPs, username, passwords, temporary
keys, etc) to be printed out for troubleshooting.

Currently only supports amazon-ebs

Closes #5107

@rickard-von-essen rickard-von-essen requested review from jen20 and a team as code owners October 16, 2018 20:13
@rickard-von-essen rickard-von-essen added enhancement core Core components of Packer labels Oct 16, 2018
@rickard-von-essen
Copy link
Collaborator Author

Example output:

$ AWS_PROFILE=packer-demo packer build -connection-info -only amazon-ebs cloud.json                                              
amazon-ebs output will be in this color.

==> amazon-ebs: Prevalidating AMI Name: packer-demo-1539718742
    amazon-ebs: Found Image ID: ami-6e28b517
==> amazon-ebs: Creating temporary keypair: packer_5bc63e56-cb43-f901-8f9b-6e2127e8fcc0
    amazon-ebs: Saving key for debug purposes: ec2_amazon-ebs.pem
==> amazon-ebs: Creating temporary security group for this instance: packer_5bc63e59-cc3b-fefd-7e3e-23706d803d05
==> amazon-ebs: Authorizing access to port 22 from 0.0.0.0/0 in the temporary security group...
==> amazon-ebs: Launching a source AWS instance...
==> amazon-ebs: Adding tags to source instance
    amazon-ebs: Adding tag: "Name": "Packer Builder"
    amazon-ebs: Instance ID: i-0c7e06e3b40dffe5e
==> amazon-ebs: Waiting for instance (i-0c7e06e3b40dffe5e) to become ready...
    amazon-ebs: Public DNS: ec2-18-202-195-108.eu-west-1.compute.amazonaws.com
    amazon-ebs: Public IP: 18.202.195.108
    amazon-ebs: Private IP: 172.31.34.253
==> amazon-ebs: Using ssh communicator to connect: 18.202.195.108
==> amazon-ebs: Waiting for SSH to become available...
==> amazon-ebs: Trying to connect with SSH to: 18.202.195.108:22
==> amazon-ebs: Using username "centos" and password ""
==> amazon-ebs: Connected to SSH!
==> amazon-ebs: Provisioning with shell script: scripts/cloud/puppet_install.sh
    amazon-ebs: + set -o nounset
    amazon-ebs: + exit 0
==> amazon-ebs: Provisioning with shell script: /var/folders/_t/lsk64yf93xs3slvvtc6b_6mr0000gn/T/packer-shell274805107
==> amazon-ebs: Pausing 1s before the next provisioner...
==> amazon-ebs: Provisioning with shell script: /var/folders/_t/lsk64yf93xs3slvvtc6b_6mr0000gn/T/packer-shell576167343
    amazon-ebs:  19:40:09 up 0 min,  1 user,  load average: 1.45, 0.34, 0.11
==> amazon-ebs: Stopping the source instance...
    amazon-ebs: Stopping instance, attempt 1
==> amazon-ebs: Waiting for the instance to stop...
==> amazon-ebs: Creating unencrypted AMI packer-demo-1539718742 from instance i-0c7e06e3b40dffe5e
    amazon-ebs: AMI: ami-074fd2e4e6b966c45
==> amazon-ebs: Waiting for AMI to become ready...
==> amazon-ebs: Adding tags to AMI (ami-074fd2e4e6b966c45)...
==> amazon-ebs: Tagging snapshot: snap-0b89cb4e197261ef6
==> amazon-ebs: Creating AMI tags
    amazon-ebs: Adding tag: "Release": "7.5"
    amazon-ebs: Adding tag: "OS_Version": "CentOS"
==> amazon-ebs: Creating snapshot tags
==> amazon-ebs: Terminating the source AWS instance...
==> amazon-ebs: Cleaning up any extra volumes...
==> amazon-ebs: Destroying volume (vol-0e3d228dc2340af32)...
==> amazon-ebs: Deleting temporary security group...
==> amazon-ebs: Deleting temporary keypair...
Build 'amazon-ebs' finished.

==> Builds finished. The artifacts of successful builds are:
--> amazon-ebs: AMIs were created:
eu-west-1: ami-074fd2e4e6b966c45

The lines that appear because of -connection-info is:

    amazon-ebs: Saving key for debug purposes: ec2_amazon-ebs.pem
[...]
==> amazon-ebs: Trying to connect with SSH to: 18.202.195.108:22
==> amazon-ebs: Using username "centos" and password ""

(I'll change the last two lines to be ui.Say, and improve language and formatting).

@rickard-von-essen
Copy link
Collaborator Author

@azr @SwampDragons It would be great if you could have some input on this before I proceed. Especially the naming of the flags etc.

@@ -293,7 +293,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
state := new(multistep.BasicStateBag)
state.Put("cache", cache)
state.Put("config", &b.config)
state.Put("debug", b.config.PackerDebug)
state.Put("debug", b.config.PackerDebug) // TODO rickard remove
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commenting on TODO so that we don't forget, just resolve me !

command/build.go Outdated
var cfgOnError string
flags := c.Meta.FlagSet("build", FlagSetBuildFilter|FlagSetVars)
flags.Usage = func() { c.Ui.Say(c.Help()) }
flags.BoolVar(&cfgColor, "color", true, "")
flags.BoolVar(&cfgDebug, "debug", false, "")
flags.BoolVar(&cfgConnInfo, "connection-info", false, "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find connection-info a bit vague, it could also mean "show connection-info of provider".
Alternative names in order of preference:

--show-communication-credentials
--show-communicator-credentials
--communication-credentials
--communicator-credentials

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think communication-credentials includes all the things this does, it also prints IPs ports etc. Maybe something like --communication-details? It be awesome if this was a bit shorter since this will probably most used by humans troubleshooting and developing builds.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree 🙂 may be: comm-credentials ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a side note; it also feels with comm-credentials that I could pass a parameter:

packer build --com-credentials login=azr,pass=s3cure  file.json

@azr
Copy link
Contributor

azr commented Oct 17, 2018

LGTM otherwise 🙂

@rickard-von-essen
Copy link
Collaborator Author

LGTM otherwise 🙂

After we have decided on the UX, I'll work through both communicators and all builders to output relevant details. So this will take some more time..

@SwampDragons
Copy link
Contributor

If the purpose is debugging, why not debug-connection?

@SwampDragons SwampDragons added this to the v1.4.0 milestone Oct 17, 2018
@rickard-von-essen
Copy link
Collaborator Author

If the purpose is debugging, why not debug-connection?

Hmm that's not so bad.

@SwampDragons
Copy link
Contributor

haha I aspire to be "not so bad". The reality is, I trust you and don't want to bikeshed this too hard. I'm in favor of making the debug aspect explicit, but as long as we have clear docs, I think any of the names we've brainstormed are fine (including your original). Pick whichever one feels right in your gut and we'll move from there.

@SwampDragons
Copy link
Contributor

@rickard-von-essen are you still waiting for an explicit 👍 from us or are you just busy with other things? I like the direction this was going and still find myself leaning towards debug-connection but will defer to you if you have something you like better.

@rickard-von-essen
Copy link
Collaborator Author

Just got other thinks needed to handled. I'll go with -debug-connection. I might have some time today.

This adds the -connection-info flag to the build command causing all
relevant connection information (IPs, username, passwords, temporary
keys, etc) to be printed out for troubleshooting.

Currently only supports amazon-ebs
@SwampDragons SwampDragons removed this from the v1.4.0 milestone Apr 11, 2019
@jen20 jen20 removed their request for review May 15, 2019 13:15
@zicodes
Copy link

zicodes commented Sep 23, 2019

Any possibility to get this included for next couple of versions?

@rickard-von-essen
Copy link
Collaborator Author

I won't have any time to work on this for at lest a month. Maybe someone else would like to pick it up?

@SwampDragons
Copy link
Contributor

looking back at this issue, I think printing the info from inside of the step_connect may make more sense; that way we can implement it for basically all our builders at once since it's a common step.

@rickard-von-essen
Copy link
Collaborator Author

rickard-von-essen commented Oct 2, 2019 via email

@SwampDragons
Copy link
Contributor

Closing since this has gone stale; we can reopen if you ever get the bug to finish it up.

@ghost
Copy link

ghost commented Apr 1, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
core Core components of Packer enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: add -connection-info flag to build command
4 participants