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

Support 'xenhvm' for AWS instances #2758

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

treydock
Copy link

@treydock treydock commented Sep 19, 2024

This is on fresh EC2 instance using xenhvm:

$ sudo facter -p virtual
xenhvm

$ sudo facter -p cloud.provider
$

$ sudo facter -p ec2_metadata.system
xen-on-nitro

@treydock treydock requested a review from a team as a code owner September 19, 2024 19:40
@puppetlabs-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@joshcooper
Copy link
Contributor

$ sudo facter -p cloud.provider
$

I would have expected this to return aws

Can you update your commit message to describe how facter behaved before? And how xen-on-nitro is different than xen?

Does /opt/puppetlabs/puppet/bin/virt-what return the expected output?

Currently this happens:

```
$ sudo facter -p cloud

$ sudo facter -p virtual
xenhvm

$ sudo /opt/puppetlabs/puppet/bin/virt-what
xen
xen-hvm
aws
```
@treydock
Copy link
Author

Updated commit message, will paste here for completeness:

$ sudo facter -p cloud

$ sudo facter -p virtual
xenhvm

$ sudo /opt/puppetlabs/puppet/bin/virt-what
xen
xen-hvm
aws

We have pushed this custom fact to our systems that mimics the logic Facter uses with this PR's addition:

Facter.add('cloud') do
  setcode do
    value = nil
    provider = Facter::Util::Facts::Posix::VirtualDetector.platform
    if ['xenhvm', 'xen', 'kvm'].include?(provider)
      metadata = Facter::Resolvers::Ec2.resolve(:metadata)
      value = 'aws' unless metadata.nil? || metadata.empty?
    elsif ['gce'].include?(provider)
      metadata = Facter::Resolvers::Gce.resolve(:metadata)
      value = 'gce' unless metadata.nil? || metadata.empty?
    end
    if value.nil?
      value
    else
      { 'provider' => value }
    end
  end
end

Using that custom fact that accounts for xenhvm we get this:

$ sudo facter -p cloud
{
  provider => "aws"
}
$ sudo puppet facts show cloud
{
  "cloud": {
    "provider": "aws"
  }
}

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