ami_kickstart 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +22 -0
- data/Rakefile +2 -0
- data/ami_kickstart.gemspec +22 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/ami-ks +13 -0
- data/lib/ami_kickstart.rb +4 -0
- data/lib/ami_kickstart/centos.rb +59 -0
- data/lib/ami_kickstart/version.rb +3 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d8f721de9dad6b0f9e37eb9000af3708b00137e9
|
4
|
+
data.tar.gz: e258edc170de606bf5a2f8e2cb9569e59dcc1302
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: addea4cae42ac496ea0b17f266b083a7cb6255801b761423a57af84f054a6bb861da3b30b2f5226fc40934d5764d8fe1eb6369a57b8033e3e23af03122af102d
|
7
|
+
data.tar.gz: 22257c029548c2e6c3431e459f3f09300439e388ce6aefac428e237499c116e8f2e482fa04de22de7451454cb0c461edadea30ea7f455e7f97dde570f17aad19
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Neeraj Bhunwal
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# AmiKickstart
|
2
|
+
## Installation
|
3
|
+
|
4
|
+
$ gem install ami_kickstart
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
1. Your kickstart file should have "halt" as part of the %post snippet
|
9
|
+
2. Host your kickstart file at some public url
|
10
|
+
3. Launch a centos instance with the same disk size as specified in your kickstart file
|
11
|
+
4. Install this gem on that centos instance
|
12
|
+
5. Execute the following command as root to start the installation
|
13
|
+
|
14
|
+
$ ami-ks <vncpassword> <kickstart url>
|
15
|
+
6. Connect using the vncpassword to monitor progress
|
16
|
+
7. The instance will halt once the install completes
|
17
|
+
8. Register an ami using this instance.
|
18
|
+
|
19
|
+
## License
|
20
|
+
|
21
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
22
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ami_kickstart/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ami_kickstart"
|
8
|
+
spec.version = AMIKickstart::VERSION
|
9
|
+
spec.authors = ["Neeraj"]
|
10
|
+
|
11
|
+
spec.summary = %q{A tool to build AMIs using kickstart}
|
12
|
+
spec.description = %q{A tool to build AMIs using kickstart}
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ami_kickstart"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/exe/ami-ks
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
vncpass = ARGV.shift
|
3
|
+
abort "please specify vncpassword as first argument" if not vncpass
|
4
|
+
ks_url = ARGV.shift
|
5
|
+
abort "please specify kickstart url as second argument" if not ks_url
|
6
|
+
|
7
|
+
require 'uri'
|
8
|
+
if not ks_url =~ /\A#{URI::regexp(['http', 'https'])}\z/
|
9
|
+
abort "specified kickstart url is invalid"
|
10
|
+
end
|
11
|
+
require 'ami_kickstart/centos'
|
12
|
+
ami = AMIKickstart::Centos.new(vncpass, ks_url)
|
13
|
+
ami.kickstart
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
module AMIKickstart
|
3
|
+
class Centos
|
4
|
+
|
5
|
+
KERNEL_PATH = "/boot/vmlinuz"
|
6
|
+
INITRD_PATH = "/boot/initrd.img"
|
7
|
+
|
8
|
+
def initialize(vncpassword, ks_url)
|
9
|
+
@vncpassword = vncpassword
|
10
|
+
@ks_url = ks_url
|
11
|
+
end
|
12
|
+
|
13
|
+
def kickstart
|
14
|
+
download_kernel
|
15
|
+
download_initrd
|
16
|
+
remove_kernel_from_grub
|
17
|
+
add_kernel_to_grub
|
18
|
+
reboot
|
19
|
+
end
|
20
|
+
|
21
|
+
def system!(command)
|
22
|
+
ok = system command
|
23
|
+
raise "Error running command #{command}" if not ok
|
24
|
+
end
|
25
|
+
|
26
|
+
def download(url, outfile)
|
27
|
+
return if File.exist? outfile
|
28
|
+
system! "curl '#{url}' > /tmp/amif"
|
29
|
+
FileUtils.mv "/tmp/amif", outfile
|
30
|
+
end
|
31
|
+
|
32
|
+
def download_kernel
|
33
|
+
url = "http://mirror.centos.org/centos/7/os/x86_64/isolinux/vmlinuz"
|
34
|
+
download url, KERNEL_PATH
|
35
|
+
end
|
36
|
+
|
37
|
+
def download_initrd
|
38
|
+
url = "http://mirror.centos.org/centos/7/os/x86_64/isolinux/initrd.img"
|
39
|
+
download url, INITRD_PATH
|
40
|
+
end
|
41
|
+
|
42
|
+
def remove_kernel_from_grub
|
43
|
+
system! "grubby --remove-kernel #{KERNEL_PATH}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def add_kernel_to_grub
|
47
|
+
args = "vnc vncpassword=#{@vncpassword} ip=dhcp ks=#{@ks_url} method=http://mirror.centos.org/centos/7/os/x86_64/"
|
48
|
+
system! %(grubby --make-default --add-kernel #{KERNEL_PATH} --initrd #{INITRD_PATH} --title="Centos Kickstart" --args="#{args}")
|
49
|
+
end
|
50
|
+
|
51
|
+
def reboot
|
52
|
+
print "Reboot(y/n): "
|
53
|
+
answer = gets.chomp.strip.downcase
|
54
|
+
if answer == "y"
|
55
|
+
system "/sbin/reboot"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ami_kickstart
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Neeraj
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: A tool to build AMIs using kickstart
|
42
|
+
email:
|
43
|
+
executables:
|
44
|
+
- ami-ks
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- ami_kickstart.gemspec
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- exe/ami-ks
|
57
|
+
- lib/ami_kickstart.rb
|
58
|
+
- lib/ami_kickstart/centos.rb
|
59
|
+
- lib/ami_kickstart/version.rb
|
60
|
+
homepage:
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.5.1
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: A tool to build AMIs using kickstart
|
84
|
+
test_files: []
|