gogetit 0.11.0 → 0.12.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
  SHA1:
3
- metadata.gz: 74c7dc23671b41961916855a8ccb7129d67ca051
4
- data.tar.gz: 366f2f5e0dfee9692e40e9ea96401ce69b627a9d
3
+ metadata.gz: 5df3c7e2708fbc2aab8624208af8e66b1799d938
4
+ data.tar.gz: faa1cd7100db42852572c149576c53b768d69817
5
5
  SHA512:
6
- metadata.gz: d73e3e77111979f7770c8337dfded6e948d3a949f1891e2548bfef6c3c2d5c6166e07bc779422d1557a66a02be4347e1346b8398573d95e933585ae6e793dc82
7
- data.tar.gz: b3b508fe66965b6a3e21abc16ae22ef324a19d84fa7ec716a70c9ea98f78e6ee1af8c06a1bed74d0d51e6c7f08d9eb7b2ea3b576e46adbd83964fc07822add32
6
+ metadata.gz: db901044d47f43dc044e353c2995e61b63b4c486d1ed7b0f881ecb33e2c10515e2378046a1ecebf7c68803760b89c392e7d7e15ac8fad83bff9ced69664f0be1
7
+ data.tar.gz: 3a570bd71ce4d20413dfd21f2c15bc0e18127a3b0cd8582400bfcd8346f4750b746673789b8612dd26d22e44a29ea2f3a057de65cdc0317d25a99c9972cc2fd8
data/gogetit.gemspec CHANGED
@@ -40,4 +40,5 @@ Gem::Specification.new do |spec|
40
40
  spec.add_runtime_dependency 'oga', '~> 2.10'
41
41
  spec.add_runtime_dependency 'net-ssh', '~> 4.1.0'
42
42
  spec.add_runtime_dependency 'thor', '~> 0.19.0'
43
+ spec.add_runtime_dependency 'hashie', '~> 3.5.5'
43
44
  end
@@ -2,6 +2,7 @@ require 'yaml'
2
2
  require 'logger'
3
3
  require 'gogetit/util'
4
4
  require 'gogetit/multilogger'
5
+ require 'hashie'
5
6
 
6
7
  module Gogetit
7
8
  module Config
@@ -60,6 +61,6 @@ module Gogetit
60
61
  FileUtils.cp(src, dst)
61
62
  abort('Please define default configuration for GoGetIt at ~/.gogetit/gogetit.yml.')
62
63
  end
63
- config.merge!(symbolize_keys(YAML.load_file(conf_file)))
64
+ config.merge!(Hashie.symbolize_keys YAML.load_file(conf_file))
64
65
  end
65
66
  end
data/lib/gogetit/util.rb CHANGED
@@ -144,19 +144,6 @@ module Gogetit
144
144
  end
145
145
  end
146
146
 
147
- # taken from https://gist.github.com/andrewpcone/11359798
148
- def symbolize_keys(thing)
149
- case thing
150
- when Array
151
- thing.map{|v| symbolize_keys(v)}
152
- when Hash
153
- inj = thing.inject({}) {|h, (k,v)| h[k] = symbolize_keys(v); h}
154
- inj.symbolize_keys
155
- else
156
- thing
157
- end
158
- end
159
-
160
147
  def wait_until_available(ip_or_fqdn, distro_name, logger)
161
148
  logger.info("Calling <#{__method__.to_s}>")
162
149
  until ping_available?(ip_or_fqdn, logger)
@@ -1,3 +1,3 @@
1
1
  module Gogetit
2
- VERSION = "0.11.0"
2
+ VERSION = "0.12.0"
3
3
  end
data/lib/providers/lxd.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'hyperkit'
2
2
  require 'gogetit/util'
3
3
  require 'yaml'
4
+ require 'hashie'
4
5
 
5
6
  module Gogetit
6
7
  class GogetLXD
@@ -77,12 +78,24 @@ module Gogetit
77
78
  args[:config][:'user.user-data']['package_update'] = false
78
79
  args[:config][:'user.user-data']['package_upgrade'] = false
79
80
 
81
+ generate_cloud_init_config(config, args)
82
+
83
+ args[:config][:"user.user-data"] = \
84
+ "#cloud-config\n" + YAML.dump(args[:config][:"user.user-data"])[4..-1]
85
+
86
+ return args
87
+ end
88
+
89
+ def generate_cloud_init_config(config, args)
90
+ logger.info("Calling <#{__method__.to_s}>")
80
91
  # To add truested root CA certificates
81
- if config[:'cloud-config'] && config[:'cloud-config'][:'ca-certs']
92
+ # https://cloudinit.readthedocs.io/en/latest/topics/examples.html
93
+ # #configure-an-instances-trusted-ca-certificates
94
+ if config[:cloud_init] && config[:cloud_init][:ca_certs]
82
95
  args[:config][:'user.user-data']['ca-certs'] = {}
83
96
  certs = []
84
97
 
85
- config[:'cloud-config'][:'ca-certs'][:trusted].each do |ca|
98
+ config[:cloud_init][:ca_certs].each do |ca|
86
99
  content = get_http_content(ca)
87
100
  certs.push(
88
101
  /^-----BEGIN CERTIFICATE-----.*-/m.match(content).to_s
@@ -92,8 +105,55 @@ module Gogetit
92
105
  args[:config][:'user.user-data']['ca-certs'] = { 'trusted' => certs }
93
106
  end
94
107
 
95
- args[:config][:"user.user-data"] = \
96
- "#cloud-config\n" + YAML.dump(args[:config][:"user.user-data"])[4..-1]
108
+ # To get CA public key to be used for SSH authentication
109
+ # https://cloudinit.readthedocs.io/en/latest/topics/examples.html
110
+ # #writing-out-arbitrary-files
111
+ if config[:cloud_init] && config[:cloud_init][:ssh_ca_public_key]
112
+ args[:config][:'user.user-data']['write_files'] = []
113
+ content = get_http_content(config[:cloud_init][:ssh_ca_public_key][:key_url])
114
+ if content
115
+ file = {
116
+ 'content' => content.chop!,
117
+ 'path' => config[:cloud_init][:ssh_ca_public_key][:key_path],
118
+ 'owner' => config[:cloud_init][:ssh_ca_public_key][:owner],
119
+ 'permissions' => config[:cloud_init][:ssh_ca_public_key][:permissions]
120
+ }
121
+ args[:config][:'user.user-data']['write_files'].push(file)
122
+ args[:config][:'user.user-data']['bootcmd'] = []
123
+ args[:config][:'user.user-data']['bootcmd'].push(
124
+ "cloud-init-per once ssh-ca-pub-key \
125
+ echo \"TrustedUserCAKeys #{file['path']}\" >> /etc/ssh/sshd_config"
126
+ )
127
+ end
128
+
129
+ if config[:cloud_init][:ssh_ca_public_key][:revocation_url]
130
+ content = get_http_content(config[:cloud_init][:ssh_ca_public_key][:revocation_url])
131
+ if content
132
+ args[:config][:'user.user-data']['bootcmd'].push(
133
+ "cloud-init-per once download-key-revocation-list \
134
+ curl -o #{config[:cloud_init][:ssh_ca_public_key][:revocation_path]} \
135
+ #{config[:cloud_init][:ssh_ca_public_key][:revocation_url]}"
136
+ )
137
+ args[:config][:'user.user-data']['bootcmd'].push(
138
+ "cloud-init-per once ssh-user-key-revocation-list \
139
+ echo \"RevokedKeys #{config[:cloud_init][:ssh_ca_public_key][:revocation_path]}\" \
140
+ >> /etc/ssh/sshd_config"
141
+ )
142
+ end
143
+ end
144
+ end
145
+
146
+ # To add users
147
+ # https://cloudinit.readthedocs.io/en/latest/topics/examples.html
148
+ # #including-users-and-groups
149
+ if config[:cloud_init] && config[:cloud_init][:users]
150
+ args[:config][:'user.user-data']['users'] = []
151
+ args[:config][:'user.user-data']['users'].push('default')
152
+
153
+ config[:cloud_init][:users].each do |user|
154
+ args[:config][:'user.user-data']['users'].push(Hashie.stringify_keys user)
155
+ end
156
+ end
97
157
 
98
158
  return args
99
159
  end
@@ -2,14 +2,23 @@ default:
2
2
  user: ubuntu
3
3
  root_bridge: $root_bridge
4
4
 
5
- #cloud-init
6
- cloud-config:
7
- write_files:
8
- - ca_public_key_url: http://pki.example.com/site/ssh_ca.pub
9
- path: /etc/ssh/ca.pub
10
- ca-certs:
11
- trusted:
12
- - http://pki.example.com/site/root_ca.crt
5
+ cloud_init:
6
+ users:
7
+ - name: usera
8
+ gecos: usera
9
+ sudo: ALL=(ALL) NOPASSWD:ALL
10
+ groups: users, admin
11
+ shell: /bin/bash
12
+ lock_passwd: true
13
+ ca_certs:
14
+ - http://pki.example.com/site/root_ca.crt
15
+ ssh_ca_public_key:
16
+ key_url: http://pki.example.com/site/ssh_ca.pub
17
+ key_path: /etc/ssh/ca.pub
18
+ revocation_url: http://pki.example.com/site/ssh-revoked-keys
19
+ revocation_path: /etc/ssh/ca.pub
20
+ owner: root:root
21
+ permissions: '0640'
13
22
 
14
23
  maas:
15
24
  key: K:E:Y
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gogetit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Don Draper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-08 00:00:00.000000000 Z
11
+ date: 2018-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: 0.19.0
181
+ - !ruby/object:Gem::Dependency
182
+ name: hashie
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 3.5.5
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: 3.5.5
181
195
  description: |2
182
196
  This provides the ways that deal with mutiple virtualized and containerized solutions such as Libvirt(KVM) and LXD.
183
197
  This uses MAAS for bare-metal provision(KVM machine using Libvirt), DHCP and DNS.