specinfra 2.89.0 → 2.90.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e50bdeee324833215a1b15370cfc44ef242b6c52dfd9dac888bd2391fb9e7de
4
- data.tar.gz: a99274248ab6323eea1f84a5692bb73aab86288169e70ee71d743a981b0a5e13
3
+ metadata.gz: 067d190ae11b7f8fe5c498d4ff1ede90d0fb31a61433949aa36bc15451694385
4
+ data.tar.gz: 5c9e782c260030df5eab0731ce69ee76d6282992706ba9babd3b20f92a6437f0
5
5
  SHA512:
6
- metadata.gz: 9fa6eacae5f42b7dca7743d83b052e0bdd9e3077649baa0638c3ba9bc7e7f6f3d2f8faa743c5bf3a36fdda7e7d068868f57830cdcf19b33a21f3519aa08a3849
7
- data.tar.gz: 97227f5e2114863c8afee052c8dd207fa4a2f20bc07b5e4c8b43a030cd44811764f7fb1ab0c16267dfc4bcf2c8968d6b87cd7c0944b567db0f8d0a025edac503
6
+ metadata.gz: fb85dc153cb2b1f09e7cc3fa3a2e08ddb0512814df16b5ef74a644a76ede812667ca2f9dbcaae54d5f1e271d185b3f31ab36647d0cbad3d4cf238184b271cdf2
7
+ data.tar.gz: 8b149adf18beb0647e019580851ba742698593db56ae8e671a858f6310ef9cd6febe4225b7a11a880a8dadd97c67abe5954dc59238da7b532b065dcdab242aa3
@@ -5,10 +5,13 @@ module Specinfra
5
5
  @host_inventory = host_inventory
6
6
 
7
7
  @base_uri = 'http://169.254.169.254/latest/meta-data/'
8
+ @token_uri = 'http://169.254.169.254/latest/api/token'
9
+ @token = ''
8
10
  @metadata = {}
9
11
  end
10
12
 
11
13
  def get
14
+ @token = get_token
12
15
  @metadata = get_metadata
13
16
  self
14
17
  end
@@ -64,7 +67,7 @@ module Specinfra
64
67
  def get_metadata(path='')
65
68
  metadata = {}
66
69
 
67
- keys = @host_inventory.backend.run_command("curl -s #{@base_uri}#{path}").stdout.split("\n")
70
+ keys = @host_inventory.backend.run_command("curl -H \"X-aws-ec2-metadata-token: #{@token}\" -s #{@base_uri}#{path}").stdout.split("\n")
68
71
 
69
72
  keys.each do |key|
70
73
  if key =~ %r{/$}
@@ -84,7 +87,16 @@ module Specinfra
84
87
  end
85
88
 
86
89
  def get_endpoint(path)
87
- ret = @host_inventory.backend.run_command("curl -s #{@base_uri}#{path}")
90
+ ret = @host_inventory.backend.run_command("curl -H \"X-aws-ec2-metadata-token: #{@token}\" -s #{@base_uri}#{path}")
91
+ if ret.success?
92
+ ret.stdout
93
+ else
94
+ nil
95
+ end
96
+ end
97
+
98
+ def get_token
99
+ ret = @host_inventory.backend.run_command("curl -X PUT -H \"X-aws-ec2-metadata-token-ttl-seconds: 21600\" -s #{@token_uri}")
88
100
  if ret.success?
89
101
  ret.stdout
90
102
  else
@@ -1,5 +1,5 @@
1
1
  module Specinfra
2
- VERSION = "2.89.0"
2
+ VERSION = "2.90.0"
3
3
 
4
4
  def self.ruby_is_older_than?(*version)
5
5
  (RUBY_VERSION.split('.').map(&:to_i) <=> version) < 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.89.0
4
+ version: 2.90.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-13 00:00:00.000000000 Z
11
+ date: 2024-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-scp