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

Add certname option to pe_agent provisioner #106

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ccaum
Copy link
Contributor

@ccaum ccaum commented Nov 3, 2015

Previous to this commit, the frictionless agent installer used by the
pe_agent provisioniner defaulted to the FQDN of the VM. This can cause
inconsistent VM certnames based on what network the user is on.

This commit introduces a new role config parameter called 'certname'
that accepts three possible values:

  • hostname - uses the value of host's hostname setting in Vagrant
  • vm_name - uses the VM's name as set in Vagrant
  • fqdn - uses the host's fqdn

Previous to this commit, the frictionless agent installer used by the
pe_agent provisioniner defaulted to the FQDN of the VM.  This can cause
inconsistent VM certnames based on what network the user is on.

This commit introduces a new role config parameter called 'certname'
that accepts three possible values:

* hostname - uses the value of host's hostname setting in Vagrant
* vm_name  - uses the VM's name as set in Vagrant
* fqdn     - uses the host's fqdn
@@ -51,6 +57,7 @@ def finalize!
@autosign = (not @master_vm.nil?) if @autosign == UNSET_VALUE
@autopurge = (not @master_vm.nil?) if @autopurge == UNSET_VALUE
@version = 'current' if @version == UNSET_VALUE
@certname = 'vm_name' if @certname = UNSET_VALUE
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't include validation. Is that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just saw how validation and defaults are intended to be done. I'll update my PR when I get a chance

@Sharpie
Copy link
Member

Sharpie commented Nov 3, 2015

This does have some overlap with #96, as the certname could be handled using frictionless installer options:

curl ... | bash -s agent:certname=pick.a.name.any.name

I'm kind of leaning towards handling this there, as it would be good to introduce users to the existence of the install options --- that way they know how to handle this situation when it pops up outside of a Vagrant environment.

@Sharpie
Copy link
Member

Sharpie commented Nov 3, 2015

Ah, which is precisely how this PR ends up implementing it. However, I still think that if we do one install option, we might as well do them all unless there is a benefit to singling out the certname.

@ccaum
Copy link
Contributor Author

ccaum commented Nov 3, 2015

@Sharpie, I started out doing just that, but it gets messy. In an ideal world, you'll use PE to modify any other agent configs. This is one, along with CSR atributes, that really must be set during install.

@ccaum
Copy link
Contributor Author

ccaum commented Nov 3, 2015

@Sharpie To elaborate, the certname can't (and shouldn't) be a static string setting since you'll want to set its value in the VM's role. Since roles are reused, and certname must be unique, you'll need a dynamic way of determing the certname's value. This behavior is unique to certname, which is why it should be its own setting.

ccaum added 2 commits November 4, 2015 22:19
Previous to this commit, defaults were not being set using the
set_default provided set_default method.  Also, the certname option for
the pe_agent config builder was not being validated.

This commit sets all default values for the pe_agent config build
parameters using the PEBuild::ConfigDefault#set_default method. This
commit also validates the value of the certname parameter matches one of
*vm_name*, *hostname*, or *fqdn*.
Previous to this commit, if a bad value for certname somehow made it
passed validation, the
PEBuild::Provisioner::PEAgent#provsion_posix_agent method would simply
accept it, causing the default behavior for the
pe_frictionless_installer.sh script to be used.  While not catastrophic,
this could cause considerable confusion.

This commit throws an exception if a bad value makes it passed
validation. It also prints output showing what value of certname is
being used, if the value can be predetermined.
@ccaum
Copy link
Contributor Author

ccaum commented Nov 5, 2015

@adrienthebo and @Sharpie, take a look at this PR now.

@Sharpie
Copy link
Member

Sharpie commented Nov 7, 2015

Ok, I see the use for a static token that gets dynamically transformed into a machine-specific value.

However, I still think we'll end up needing a generic install_options setting as main:dns_alt_names will definitely be needed for compile master support. If possible, I'd rather bring this all under one setting in order to keep the logic in one place.

Would something like the following work?

roles:
  - name: pe-agent
    provisioners:
      - type: pe-agent
        install_options:
          agent:
            certname: :vm_name # Or :hostname

@Sharpie Sharpie added this to the 0.14.0 milestone Nov 7, 2015
@Sharpie Sharpie modified the milestones: 0.14.0, 0.15.0 Mar 20, 2016
@Sharpie Sharpie modified the milestones: 0.16.0, 0.15.0 May 11, 2016
@Sharpie Sharpie modified the milestones: 0.16.0, 0.17.0 Oct 22, 2016
@Sharpie Sharpie modified the milestones: 0.17.0, 0.18.0 Dec 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants