imagemaster3000 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +38 -0
  5. data/.travis.yml +22 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +4 -0
  8. data/LICENSE.txt +13 -0
  9. data/README.md +60 -0
  10. data/Rakefile +17 -0
  11. data/bin/imagemaster3000 +4 -0
  12. data/config/definitions/centos-7.json +29 -0
  13. data/config/definitions/debian-8.json +33 -0
  14. data/config/definitions/files/.gitkeep +0 -0
  15. data/config/definitions/files/centos-cloud.cfg +95 -0
  16. data/config/definitions/files/debian-cloud.cfg +101 -0
  17. data/config/definitions/files/serial-getty@ttyS0.service +35 -0
  18. data/config/definitions/files/ttyS0.conf +22 -0
  19. data/config/definitions/files/ubuntu-cloud.cfg +111 -0
  20. data/config/definitions/ubuntu-14.04.json +30 -0
  21. data/config/definitions/ubuntu-16.04.json +30 -0
  22. data/config/imagemaster3000.yml +15 -0
  23. data/imagemaster3000.gemspec +42 -0
  24. data/lib/imagemaster3000/actions/copy.rb +45 -0
  25. data/lib/imagemaster3000/actions/remove.rb +24 -0
  26. data/lib/imagemaster3000/actions.rb +6 -0
  27. data/lib/imagemaster3000/cli.rb +115 -0
  28. data/lib/imagemaster3000/definitions/parser.rb +45 -0
  29. data/lib/imagemaster3000/definitions/schemas/imagemaster3000-definition-schema.json +238 -0
  30. data/lib/imagemaster3000/definitions.rb +5 -0
  31. data/lib/imagemaster3000/entities/downloadable.rb +47 -0
  32. data/lib/imagemaster3000/entities/image.rb +92 -0
  33. data/lib/imagemaster3000/entities.rb +6 -0
  34. data/lib/imagemaster3000/errors/action_error.rb +5 -0
  35. data/lib/imagemaster3000/errors/argument_error.rb +5 -0
  36. data/lib/imagemaster3000/errors/command_execution_error.rb +5 -0
  37. data/lib/imagemaster3000/errors/download_error.rb +5 -0
  38. data/lib/imagemaster3000/errors/parsing_error.rb +5 -0
  39. data/lib/imagemaster3000/errors/standard_error.rb +5 -0
  40. data/lib/imagemaster3000/errors/verification_error.rb +5 -0
  41. data/lib/imagemaster3000/errors.rb +11 -0
  42. data/lib/imagemaster3000/image_list/generator.rb +25 -0
  43. data/lib/imagemaster3000/image_list/signer.rb +18 -0
  44. data/lib/imagemaster3000/image_list/templates/image_list.erb +41 -0
  45. data/lib/imagemaster3000/image_list.rb +6 -0
  46. data/lib/imagemaster3000/main_process.rb +22 -0
  47. data/lib/imagemaster3000/settings.rb +19 -0
  48. data/lib/imagemaster3000/utils/command_executioner.rb +22 -0
  49. data/lib/imagemaster3000/utils/crypto.rb +28 -0
  50. data/lib/imagemaster3000/utils/tmp.rb +24 -0
  51. data/lib/imagemaster3000/utils.rb +7 -0
  52. data/lib/imagemaster3000/verification/hash.rb +45 -0
  53. data/lib/imagemaster3000/verification/signatures/clearsign.rb +16 -0
  54. data/lib/imagemaster3000/verification/signatures/detached.rb +18 -0
  55. data/lib/imagemaster3000/verification/signatures.rb +8 -0
  56. data/lib/imagemaster3000/verification/verifiable.rb +10 -0
  57. data/lib/imagemaster3000/verification.rb +7 -0
  58. data/lib/imagemaster3000/version.rb +3 -0
  59. data/lib/imagemaster3000.rb +18 -0
  60. metadata +347 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 44586ae5ff59b3b0fd2b69f3a68b10e986298e46
4
+ data.tar.gz: 4e031df88184d4fd4d683d2bbe42628a9afc0bb7
5
+ SHA512:
6
+ metadata.gz: 69b7ec75eb226bdbb807fb093808fb62ee08034a4f0615561dcd08d4160bdb1e57a3b8526668827a5a4dd44af93ac04f8eaa6c2794f56b5078fa987fd2eea30c
7
+ data.tar.gz: afc4dc785509a3e9ecf5777eb07345bb18ad1914a963c9a94789694712530f5ff5c6aa42ae1f22cdb883a7247f2b646d296c01e983760dcc3376d279ef8ee254
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ example
11
+ /vendor/
12
+ /coverage/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,38 @@
1
+ require: rubocop-rspec
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.0
5
+ Exclude:
6
+ - 'vendor/**/*'
7
+
8
+ Metrics/LineLength:
9
+ Max: 135
10
+
11
+ Metrics/MethodLength:
12
+ Max: 15
13
+
14
+ Metrics/AbcSize:
15
+ Max: 20
16
+
17
+ Style/Documentation:
18
+ Enabled: false
19
+
20
+ RSpec/MultipleExpectations:
21
+ Enabled: false
22
+
23
+ RSpec/ExampleLength:
24
+ Enabled: false
25
+
26
+ RSpec/NestedGroups:
27
+ Max: 3
28
+
29
+ Metrics/ParameterLists:
30
+ Exclude:
31
+ - 'lib/imagemaster3000/entities/*.rb'
32
+
33
+ Metrics/BlockLength:
34
+ Exclude:
35
+ - 'Rakefile'
36
+ - '**/*.rake'
37
+ - 'spec/**/*.rb'
38
+ - '*.gemspec'
data/.travis.yml ADDED
@@ -0,0 +1,22 @@
1
+ sudo: false
2
+
3
+ language: ruby
4
+ rvm:
5
+ - ruby-head
6
+ - 2.2.6
7
+ - 2.3.3
8
+ - 2.4.0
9
+
10
+ matrix:
11
+ allow_failures:
12
+ - rvm: ruby-head
13
+
14
+ fast_finish: true
15
+
16
+ branches:
17
+ only:
18
+ - master
19
+
20
+ before_install: 'gem install bundler -v 1.15.0'
21
+
22
+ script: 'bundle exec rake acceptance'
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at kimle.michal@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in imagemaster3000.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2017 Michal Kimle
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # imagemaster3000
2
+
3
+ Downloads and slightly modifies cloud images so they can be used in our extraordinary cloud. Simple as that.
4
+
5
+ ## Installation
6
+
7
+ ### From source (dev)
8
+ **Installation from source should never be your first choice! Especially, if you are not
9
+ familiar with RVM, Bundler, Rake and other dev tools for Ruby!**
10
+
11
+ **However, if you wish to contribute to our project, this is the right way to start.**
12
+
13
+ To build and install the bleeding edge version from master
14
+
15
+ ```bash
16
+ git clone git://github.com/Misenko/imagemaster3000.git
17
+ cd imagemaster3000
18
+ gem install bundler
19
+ bundle install
20
+ bundle exec rake spec
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```bash
26
+ Usage:
27
+ imagemaster3000 start --binaries-guestfish=BINARIES-GUESTFISH --binaries-virt-copy-in=BINARIES-VIRT-COPY-IN --certificate=CERTIFICATE --endpoint=ENDPOINT --group=GROUP --image-dir=IMAGE-DIR --image-list=IMAGE-LIST --key=KEY
28
+
29
+ Options:
30
+ [--definitions-dir=DEFINITIONS-DIR] # If set, definitions in this direcotry are used to download and modify images
31
+ --image-dir=IMAGE-DIR # Directory where to temporarily store images
32
+ # Default: /var/spool/imagemaster3000/images/
33
+ --group=GROUP # Group, images will be uploaded to
34
+ # Default: imagemaster3000
35
+ --image-list=IMAGE-LIST # Name and path of generated image list
36
+ # Default: /var/spool/imagemaster3000/image-list/imagemaster3000.list
37
+ --endpoint=ENDPOINT # Endpoint where image list will be available
38
+ # Default: http://localhost/
39
+ --certificate=CERTIFICATE # Certificate to sign image list with
40
+ # Default: /etc/grid-security/cert.pem
41
+ --key=KEY # Key to sign image list with
42
+ # Default: /etc/grid-security/key.pem
43
+ --binaries-virt-copy-in=BINARIES-VIRT-COPY-IN # Path to binary needed for 'copy' action
44
+ # Default: /usr/bin/virt-copy-in
45
+ --binaries-guestfish=BINARIES-GUESTFISH # Path to binary needed for 'remove' action
46
+ # Default: /usr/bin/guestfish
47
+ --logging-level=LOGGING-LEVEL
48
+ # Default: ERROR
49
+ # Possible values: DEBUG, INFO, WARN, ERROR, FATAL, UNKNOWN
50
+ [--logging-file=LOGGING-FILE] # File to write logs to
51
+ # Default: /var/log/imagemaster3000/imagemaster3000.log
52
+ [--debug], [--no-debug] # Runs in debug mode
53
+ ```
54
+
55
+ ## Contributing
56
+ 1. Fork it ( https://github.com/Misenko/imagemaster3000/fork )
57
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
58
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
59
+ 4. Push to the branch (`git push origin my-new-feature`)
60
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'rubocop/rake_task'
3
+ require 'bundler/gem_tasks'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ RuboCop::RakeTask.new
7
+
8
+ task default: :spec
9
+
10
+ desc 'Run acceptance tests (RSpec + Rubocop)'
11
+ task test: 'acceptance'
12
+
13
+ desc 'Run acceptance tests (RSpec + Rubocop)'
14
+ task :acceptance do |_t|
15
+ Rake::Task['spec'].invoke
16
+ Rake::Task['rubocop'].invoke
17
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'imagemaster3000'
3
+
4
+ Imagemaster3000::CLI.start(ARGV)
@@ -0,0 +1,29 @@
1
+ {
2
+ "name":"METACLOUD-CentOS-7.3-1704-x86_64@metacloud-dukan",
3
+ "url":"http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1704.qcow2",
4
+ "verification":{
5
+ "signature":{
6
+ "clearsign":{
7
+ "file":"http://cloud.centos.org/centos/7/images/sha256sum.txt.asc"
8
+ }
9
+ },
10
+ "hash":{
11
+ "function":"SHA256"
12
+ }
13
+ },
14
+ "distribution":"CentOS",
15
+ "version":"7.3-1704",
16
+ "actions":{
17
+ "copy":[
18
+ {
19
+ "source":"centos-cloud.cfg",
20
+ "target":"/etc/cloud/",
21
+ "name":"cloud.cfg"
22
+ },
23
+ {
24
+ "source":"serial-getty@ttyS0.service",
25
+ "target":"/etc/systemd/system/getty.target.wants/"
26
+ }
27
+ ]
28
+ }
29
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "name":"METACLOUD-Debian-8.7.1-x86_64@metacloud-dukan",
3
+ "url":"https://cdimage.debian.org/cdimage/openstack/current/debian-8.8.1-20170521-openstack-amd64.qcow2",
4
+ "verification":{
5
+ "signature":{
6
+ "detached":{
7
+ "signature": "https://cdimage.debian.org/cdimage/openstack/current/SHA256SUMS.sign",
8
+ "data": "https://cdimage.debian.org/cdimage/openstack/current/SHA256SUMS"
9
+ }
10
+ },
11
+ "hash":{
12
+ "function":"SHA256"
13
+ }
14
+ },
15
+ "distribution":"Debian",
16
+ "version":"8.8.1",
17
+ "actions":{
18
+ "remove":[
19
+ "/etc/cloud/cloud.cfg.d/90_dpkg.cfg"
20
+ ],
21
+ "copy":[
22
+ {
23
+ "source":"debian-cloud.cfg",
24
+ "target":"/etc/cloud/",
25
+ "name":"cloud.cfg"
26
+ },
27
+ {
28
+ "source":"serial-getty@ttyS0.service",
29
+ "target":"/etc/systemd/system/getty.target.wants/"
30
+ }
31
+ ]
32
+ }
33
+ }
File without changes
@@ -0,0 +1,95 @@
1
+ # If this is set, 'root' will not be able to ssh in and they
2
+ # will get a message to login instead as the above $user (ubuntu)
3
+ disable_root: False
4
+ user: root
5
+ ssh_pwauth: False
6
+ ssh_deletekeys: True
7
+ ssh_genkeytypes: ['rsa', 'dsa']
8
+ ssh_svcname: sshd
9
+
10
+ # This will cause the set+update hostname module to not operate (if true)
11
+ preserve_hostname: false
12
+ cc_ready_cmd: ['/bin/true']
13
+ mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']
14
+ syslog_fix_perms: ~
15
+ manage_etc_hosts: True
16
+
17
+ # Update and upgrade system on first boot
18
+ apt_preserve_sources_list: True
19
+ package_update: True
20
+ package_upgrade: True
21
+ package_reboot_if_required: True
22
+
23
+ # work only with OpenNebula, use network based datasource,
24
+ # so that we can successfully resolve IPv4 based hostname
25
+ disable_ec2_metadata: True
26
+ datasource_list: ['OpenNebula']
27
+ datasource:
28
+ OpenNebula:
29
+ dsmode: net
30
+
31
+ # The modules that run in the 'init' stage
32
+ cloud_init_modules:
33
+ - migrator
34
+ - seed_random
35
+ - bootcmd
36
+ - write-files
37
+ - growpart
38
+ - resizefs
39
+ - set_hostname
40
+ - update_hostname
41
+ - update_etc_hosts
42
+ - ca-certs
43
+ - rsyslog
44
+ - users-groups
45
+ - ssh
46
+
47
+ # The modules that run in the 'config' stage
48
+ cloud_config_modules:
49
+ # Emit the cloud config ready event
50
+ # this can be used by upstart jobs for 'start on cloud-config'.
51
+ - emit_upstart
52
+ - disk_setup
53
+ - mounts
54
+ - ssh-import-id
55
+ - locale
56
+ - set-passwords
57
+ - grub-dpkg
58
+ - apt-pipelining
59
+ - apt-configure
60
+ - package-update-upgrade-install
61
+ - landscape
62
+ - timezone
63
+ - puppet
64
+ - chef
65
+ - salt-minion
66
+ - mcollective
67
+ - disable-ec2-metadata
68
+ - runcmd
69
+ - byobu
70
+
71
+ # The modules that run in the 'final' stage
72
+ cloud_final_modules:
73
+ - rightscale_userdata
74
+ - scripts-per-once
75
+ - scripts-per-boot
76
+ - scripts-per-instance
77
+ - scripts-user
78
+ - ssh-authkey-fingerprints
79
+ - keys-to-console
80
+ - phone-home
81
+ - final-message
82
+ - power-state-change
83
+
84
+ # System and/or distro specific settings
85
+ # (not accessible to handlers/transforms)
86
+ system_info:
87
+ # This will affect which distro class gets used
88
+ distro: rhel
89
+ # Other config here will be given to the distro class and/or path classes
90
+ paths:
91
+ cloud_dir: /var/lib/cloud/
92
+ templates_dir: /etc/cloud/templates/
93
+ ssh_svcname: sshd
94
+
95
+ # vim:syntax=yaml
@@ -0,0 +1,101 @@
1
+ # If this is set, 'root' will not be able to ssh in and they
2
+ # will get a message to login instead as the above $user (ubuntu)
3
+ disable_root: False
4
+ user: root
5
+ ssh_pwauth: False
6
+ ssh_deletekeys: True
7
+ ssh_genkeytypes: ['rsa', 'dsa']
8
+ ssh_svcname: sshd
9
+
10
+ # This will cause the set+update hostname module to not operate (if true)
11
+ preserve_hostname: false
12
+ cc_ready_cmd: ['/bin/true']
13
+ mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']
14
+ syslog_fix_perms: ~
15
+ manage_etc_hosts: True
16
+
17
+ # Update and upgrade system on first boot
18
+ apt_preserve_sources_list: True
19
+ package_update: True
20
+ package_upgrade: True
21
+ package_reboot_if_required: True
22
+
23
+ # work only with OpenNebula, use network based datasource,
24
+ # so that we can successfully resolve IPv4 based hostname
25
+ disable_ec2_metadata: True
26
+ datasource_list: ['OpenNebula']
27
+ datasource:
28
+ OpenNebula:
29
+ dsmode: net
30
+
31
+ # The modules that run in the 'init' stage
32
+ cloud_init_modules:
33
+ - migrator
34
+ - seed_random
35
+ - bootcmd
36
+ - write-files
37
+ - growpart
38
+ - resizefs
39
+ - set_hostname
40
+ - update_hostname
41
+ - update_etc_hosts
42
+ - ca-certs
43
+ - rsyslog
44
+ - users-groups
45
+ - ssh
46
+
47
+ # The modules that run in the 'config' stage
48
+ cloud_config_modules:
49
+ # Emit the cloud config ready event
50
+ # this can be used by upstart jobs for 'start on cloud-config'.
51
+ - emit_upstart
52
+ - disk_setup
53
+ - mounts
54
+ - ssh-import-id
55
+ - locale
56
+ - set-passwords
57
+ - grub-dpkg
58
+ - apt-pipelining
59
+ - apt-configure
60
+ - package-update-upgrade-install
61
+ - landscape
62
+ - timezone
63
+ - puppet
64
+ - chef
65
+ - salt-minion
66
+ - mcollective
67
+ - disable-ec2-metadata
68
+ - runcmd
69
+ - byobu
70
+
71
+ # The modules that run in the 'final' stage
72
+ cloud_final_modules:
73
+ - rightscale_userdata
74
+ - scripts-per-once
75
+ - scripts-per-boot
76
+ - scripts-per-instance
77
+ - scripts-user
78
+ - ssh-authkey-fingerprints
79
+ - keys-to-console
80
+ - phone-home
81
+ - final-message
82
+ - power-state-change
83
+
84
+ # System and/or distro specific settings
85
+ # (not accessible to handlers/transforms)
86
+ system_info:
87
+ # This will affect which distro class gets used
88
+ distro: debian
89
+ # Other config here will be given to the distro class and/or path classes
90
+ paths:
91
+ cloud_dir: /var/lib/cloud/
92
+ templates_dir: /etc/cloud/templates/
93
+ upstart_dir: /etc/init/
94
+ package_mirrors:
95
+ - arches: [default]
96
+ failsafe:
97
+ primary: http://ftp.debian.org/debian
98
+ mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']
99
+ manage_etc_hosts: true
100
+
101
+ # vim:syntax=yaml