vscripts 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/.yardopts +4 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE +0 -1
- data/README.md +17 -14
- data/VERSION +1 -1
- data/lib/vscripts.rb +1 -1
- data/lib/vscripts/aws.rb +1 -1
- data/lib/vscripts/aws/ec2.rb +20 -11
- data/lib/vscripts/aws/metadata.rb +9 -8
- data/lib/vscripts/command_line.rb +8 -9
- data/lib/vscripts/commands.rb +2 -3
- data/lib/vscripts/commands/identify.rb +26 -17
- data/lib/vscripts/commands/tags2facts.rb +8 -6
- data/lib/vscripts/util.rb +1 -1
- data/lib/vscripts/util/local_system.rb +14 -8
- data/lib/vscripts/version.rb +3 -1
- data/spec/spec_helper.rb +5 -1
- data/tasks/deploy.rake +1 -0
- data/vscripts.gemspec +27 -22
- metadata +50 -99
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjM5YzJkNTdlYjQ5MmRmYTkzNGNkYTk4YzM0MTgwMTM2YmVjOWNiZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDYzNzVkMjVmZWE0Njc4MzIxMmE4Nzk4OTY1MWQ4OWY5YzI4YWNjNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzkzNDZmZTFmYjljZDg0NmRmODE3YTNkYTQ5Y2JkYWM2NmRlY2NkYzM1YjU2
|
10
|
+
M2RiYzExMjg3YWQ3MjIzMWY0ZGY4ZjdlNDZmMThmZDNjZDdmYmYwNmEzNzc2
|
11
|
+
YTU5OGFmZWFlZTE4NDI3YTMwMzk2NjAzZTA2NDhhNjRmOTVkM2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGM0MTNhMmQxOTYwZTc1ZTgxNWJkYzZjNGI0NmExN2RkNzc0OGIyMGY2OTU0
|
14
|
+
YzI0MTRmNmVlN2ZiYTJlM2U1NjhmYzhhZTJjZTliZmMxY2I0ZjIyNjQ4NmJk
|
15
|
+
MGViMThkOGUyZTgyMTlhNjEwNDJmNmYxMjFjZDI2MGYxMWZjMWY=
|
data/.yardopts
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
Version 0.1.3
|
2
|
+
---
|
3
|
+
* Upgrade documentation ([Vlad - fd6fb30](https://github.com/vghn/vscripts/commit/fd6fb30af09d4f4050f0b35d41cc3bfb7e534e4a))
|
4
|
+
* Update gem specification ([Vlad - 8c98c07](https://github.com/vghn/vscripts/commit/8c98c070bba9c2cd9c64c7de5568161fa3f3e004))
|
5
|
+
|
1
6
|
Version 0.1.2
|
2
7
|
---
|
3
8
|
* Revert "Lock gem versions" ([Vlad - 5881199](https://github.com/vghn/vscripts/commit/5881199dd0dd846667c27a4619c01934c66f2c7b))
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -3,14 +3,13 @@
|
|
3
3
|
[](https://codeclimate.com/github/vghn/vscripts)
|
4
4
|
[](http://badge.fury.io/rb/vscripts)
|
5
5
|
[](https://coveralls.io/r/vghn/vscripts)
|
6
|
+
[](https://gemnasium.com/vghn/vscripts)
|
6
7
|
|
7
8
|
Automation daemon.
|
8
9
|
|
9
10
|
## Dependencies
|
10
11
|
- Ruby >= 1.9.3
|
11
|
-
- An AWS account (you'll need to create)
|
12
|
-
- A SNS Queue (optional, will attempt to create if can't be found)
|
13
|
-
- A Route53 zone.
|
12
|
+
- An AWS account (you'll need to create)
|
14
13
|
|
15
14
|
## Installing
|
16
15
|
|
@@ -27,8 +26,8 @@ vscripts GLOBAL-OPTIONS COMMAND OPTIONS
|
|
27
26
|
|
28
27
|
### Global Options
|
29
28
|
```
|
30
|
-
|
31
|
-
|
29
|
+
-h|--help: Displays VScripts help.
|
30
|
+
-v|--version: Displays the version number.
|
32
31
|
```
|
33
32
|
|
34
33
|
|
@@ -43,15 +42,17 @@ The `Name` and `Domain` tags are excluded by default because this command is
|
|
43
42
|
intended to add Facter facts and these 2 already exist in Facter. This behaviour
|
44
43
|
can be overridden by adding `[-a|--all]` command line option.
|
45
44
|
|
46
|
-
|
45
|
+
**Options**:
|
46
|
+
|
47
47
|
```
|
48
|
-
--file, -f <s>: The file that will store the tags (default:
|
49
|
-
|
50
|
-
--all, -a: Collect all tags
|
51
|
-
--help, -h: Shows help
|
48
|
+
--file, -f <s>: The file that will store the tags (default:
|
49
|
+
/etc/facter/facts.d/ec2_tags.json)
|
50
|
+
--all, -a: Collect all tags
|
51
|
+
--help, -h: Shows help
|
52
52
|
```
|
53
53
|
|
54
|
-
|
54
|
+
**Examples**:
|
55
|
+
|
55
56
|
```
|
56
57
|
$ vscripts tags2facts
|
57
58
|
$ vscripts tags2facts --file /tmp/my_tags.json --all
|
@@ -77,15 +78,17 @@ associated with the current instance.
|
|
77
78
|
If a ***--domain*** argument is provided it will override the default
|
78
79
|
domain.
|
79
80
|
|
80
|
-
|
81
|
-
|
81
|
+
**Options**:
|
82
|
+
|
83
|
+
```
|
82
84
|
--ec2-tag-theme, -e <s>: Theme (default: Group-Role-#)
|
83
85
|
--host, -n <s>: Host name
|
84
86
|
--domain, -d <s>: Domain
|
85
87
|
--help, -h: Shows help
|
86
88
|
```
|
87
89
|
|
88
|
-
|
90
|
+
**Examples**:
|
91
|
+
|
89
92
|
```
|
90
93
|
$ vscripts identify
|
91
94
|
MyGroup-MyRole-1.Example.tld
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/vscripts.rb
CHANGED
@@ -3,7 +3,7 @@ require 'vscripts/command_line'
|
|
3
3
|
|
4
4
|
# Main VScripts module
|
5
5
|
module VScripts
|
6
|
-
#
|
6
|
+
# Reads the arguments and runs the given command
|
7
7
|
def self.run(argv)
|
8
8
|
cli = CommandLine.new(argv)
|
9
9
|
command = VScripts::Commands.const_get(cli.command).new(cli.arguments)
|
data/lib/vscripts/aws.rb
CHANGED
data/lib/vscripts/aws/ec2.rb
CHANGED
@@ -4,35 +4,43 @@ module VScripts
|
|
4
4
|
# @ec2 smells of :reek:UncommunicativeVariableName
|
5
5
|
# ec2 smells of :reek:UncommunicativeMethodName
|
6
6
|
|
7
|
-
#
|
7
|
+
# A collection of methods used for interaction with Amazon Web Service
|
8
|
+
# Elastic Compute Cloud.
|
8
9
|
module EC2
|
9
|
-
#
|
10
|
+
# Loads AWS SDK for EC2
|
10
11
|
def ec2
|
11
12
|
::AWS::EC2.new(region: region)
|
12
13
|
end
|
13
14
|
|
14
|
-
#
|
15
|
+
# @return [AWS::EC2::Instance] the current instance
|
15
16
|
def instance
|
16
17
|
check_instance
|
17
18
|
ec2.instances[instance_id]
|
18
19
|
end
|
19
20
|
|
20
|
-
# @return [AWS::EC2::ResourceTagCollection]
|
21
|
+
# @return [AWS::EC2::ResourceTagCollection] all tags
|
21
22
|
def all_tags
|
22
23
|
instance.tags
|
23
24
|
end
|
24
25
|
|
25
|
-
# @
|
26
|
+
# @param key [String] the key
|
27
|
+
# @return [AWS::EC2::Tag] the value of the tag
|
26
28
|
def tag(key)
|
27
29
|
instance.tags[key]
|
28
30
|
end
|
29
31
|
|
30
|
-
#
|
32
|
+
# Creates an EC2 Tag
|
33
|
+
# @param resource [String] the id of the resource
|
34
|
+
# @param key [String] the key of the tag
|
35
|
+
# @param value [String] the value of the tag
|
36
|
+
# @return [AWS::EC2::Tag] the new tag
|
31
37
|
def create_tag(resource, key, value)
|
32
38
|
ec2.tags.create(resource, key, value)
|
33
39
|
end
|
34
40
|
|
35
|
-
#
|
41
|
+
# Exclude tags
|
42
|
+
# @param list [Array] the list of tag keys to be excluded
|
43
|
+
# @return [Hash] the filtered tags
|
36
44
|
def tags_without(list = [])
|
37
45
|
all_tags.each_with_object({}) do |tag, hash|
|
38
46
|
key, value = tag[0], tag[1]
|
@@ -42,17 +50,17 @@ module VScripts
|
|
42
50
|
end
|
43
51
|
|
44
52
|
# Looks for the value of the 'Name' tag for the given instance
|
53
|
+
# @return [String] the name value
|
45
54
|
def name
|
46
55
|
all_tags_hash['Name']
|
47
56
|
end
|
48
57
|
|
49
|
-
# @return[AWS::EC2::InstanceCollection]
|
50
|
-
# 'Name' tag
|
58
|
+
# @return [AWS::EC2::InstanceCollection] the value of the name tag
|
51
59
|
def named_instances
|
52
60
|
ec2.instances.tagged('Name')
|
53
61
|
end
|
54
62
|
|
55
|
-
# @return[
|
63
|
+
# @return [AWS::EC2::InstanceCollection] instances that are not terminated
|
56
64
|
def functional_instances
|
57
65
|
named_instances.map do |named_instance|
|
58
66
|
named_instance if [:running, :shutting_down, :stopping, :stopped]
|
@@ -60,7 +68,8 @@ module VScripts
|
|
60
68
|
end
|
61
69
|
end
|
62
70
|
|
63
|
-
# @return[
|
71
|
+
# @return [AWS::EC2::InstanceCollection] running instances that have
|
72
|
+
# a Name tag
|
64
73
|
def similar_instances
|
65
74
|
check_instance
|
66
75
|
functional_instances.map do |functional_instance|
|
@@ -4,42 +4,43 @@ require 'net/http'
|
|
4
4
|
module VScripts
|
5
5
|
module AWS
|
6
6
|
# This module contacts the AWS Metadata service to collect information
|
7
|
-
# about the EC2 instance.
|
7
|
+
# about the current EC2 instance.
|
8
8
|
module Metadata
|
9
|
-
# @return [String] Metadata URL
|
9
|
+
# @return [String] the Metadata URL
|
10
10
|
def metadata_url
|
11
11
|
'http://instance-data/latest/meta-data'
|
12
12
|
end
|
13
13
|
|
14
|
-
# @return [String]
|
14
|
+
# @return [String] the availability zone
|
15
15
|
def zone
|
16
16
|
open("#{metadata_url}/placement/availability-zone")
|
17
17
|
.read
|
18
18
|
end
|
19
19
|
|
20
|
-
# @return [String]
|
20
|
+
# @return [String] the region
|
21
21
|
def region
|
22
22
|
zone[/^(.*[\d])[a-z]$/, 1]
|
23
23
|
end
|
24
24
|
|
25
|
-
# @return [String]
|
25
|
+
# @return [String] the instance ID
|
26
26
|
def instance_id
|
27
27
|
open("#{metadata_url}/instance-id").read
|
28
28
|
end
|
29
29
|
|
30
|
-
# @return [String]
|
30
|
+
# @return [String] the instance public hostname
|
31
31
|
def public_hostname
|
32
32
|
open("#{metadata_url}/public-hostname").read
|
33
33
|
end
|
34
34
|
|
35
|
-
#
|
35
|
+
# Checks connection to metadata service
|
36
|
+
# @return [Boolean]
|
36
37
|
def ec2_instance?
|
37
38
|
Net::HTTP.get_response(URI.parse(metadata_url)) && true
|
38
39
|
rescue
|
39
40
|
false
|
40
41
|
end
|
41
42
|
|
42
|
-
#
|
43
|
+
# Fails if the current instance is not an EC2 instance
|
43
44
|
def check_instance
|
44
45
|
return if ec2_instance?
|
45
46
|
abort 'FATAL: NOT an EC2 instance or could not connect to Metadata'
|
@@ -1,18 +1,17 @@
|
|
1
1
|
require 'trollop'
|
2
|
-
require 'vscripts/version'
|
3
2
|
require 'vscripts/commands'
|
4
3
|
|
5
4
|
module VScripts
|
6
|
-
#
|
5
|
+
# Parses the command line arguments
|
7
6
|
class CommandLine
|
8
|
-
# @return [Array]
|
7
|
+
# @return [Array] all command line arguments
|
9
8
|
attr_accessor :arguments
|
10
|
-
# @return [Hash]
|
9
|
+
# @return [Hash] the global command line arguments.
|
11
10
|
attr_reader :global
|
12
|
-
# @return [String]
|
11
|
+
# @return [String] the command name
|
13
12
|
attr_reader :command
|
14
13
|
|
15
|
-
#
|
14
|
+
# Builds command line arguments
|
16
15
|
def initialize(argv = [])
|
17
16
|
@arguments ||= argv
|
18
17
|
@global ||= parse_cli_options
|
@@ -44,7 +43,7 @@ EOS
|
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
47
|
-
#
|
46
|
+
# @return [Hash] the command line arguments
|
48
47
|
def parse_cli_options
|
49
48
|
Trollop.with_standard_exception_handling parser do
|
50
49
|
fail Trollop::HelpNeeded if arguments.empty?
|
@@ -52,8 +51,8 @@ EOS
|
|
52
51
|
end
|
53
52
|
end
|
54
53
|
|
55
|
-
#
|
56
|
-
# @return [String]
|
54
|
+
# Ensures command is available
|
55
|
+
# @return [String] the command name
|
57
56
|
def verify_command
|
58
57
|
command_cli = arguments.shift
|
59
58
|
command_cls = command_cli.capitalize.to_sym
|
data/lib/vscripts/commands.rb
CHANGED
@@ -2,10 +2,9 @@ require 'vscripts/commands/tags2facts'
|
|
2
2
|
require 'vscripts/commands/identify'
|
3
3
|
|
4
4
|
module VScripts
|
5
|
-
#
|
5
|
+
# Commands module
|
6
6
|
module Commands
|
7
|
-
#
|
8
|
-
# @return [Array]
|
7
|
+
# @return [Array] the available commands
|
9
8
|
def self.list
|
10
9
|
VScripts::Commands.constants.select do |cls|
|
11
10
|
VScripts::Commands.const_get(cls).is_a? Class
|
@@ -9,7 +9,7 @@ module VScripts
|
|
9
9
|
include VScripts::AWS
|
10
10
|
include VScripts::Util
|
11
11
|
|
12
|
-
#
|
12
|
+
# Shows help
|
13
13
|
USAGE = <<-EOS
|
14
14
|
This command creates a themed host name and fully qualified domain name for
|
15
15
|
the server, using AWS EC2 tags. The default theme is `Group-Role-#` which means
|
@@ -40,15 +40,17 @@ associated with the current instance.
|
|
40
40
|
Options:
|
41
41
|
EOS
|
42
42
|
|
43
|
-
# @return [String]
|
43
|
+
# @return [String] the theme
|
44
44
|
attr_reader :theme
|
45
|
-
# @return [String]
|
45
|
+
# @return [String] the host name
|
46
46
|
attr_reader :host
|
47
|
-
# @return [String]
|
47
|
+
# @return [String] the domain name
|
48
48
|
attr_reader :domain
|
49
|
-
# @return [Array]
|
49
|
+
# @return [Array] the command specific arguments
|
50
50
|
attr_reader :arguments
|
51
51
|
|
52
|
+
# Loads the Identify command
|
53
|
+
# @param argv [Array] the command specific arguments
|
52
54
|
def initialize(argv = [])
|
53
55
|
@arguments ||= argv
|
54
56
|
@theme ||= cli.ec2_tag_theme
|
@@ -69,31 +71,35 @@ associated with the current instance.
|
|
69
71
|
end
|
70
72
|
end
|
71
73
|
|
72
|
-
#
|
74
|
+
# @return [Hash] the command line arguments
|
73
75
|
def cli
|
74
76
|
@cli ||= Trollop.with_standard_exception_handling parser do
|
75
77
|
parser.parse arguments
|
76
78
|
end
|
77
79
|
end
|
78
80
|
|
79
|
-
#
|
81
|
+
# Splits theme into elements
|
82
|
+
# @return [Array] the theme elements
|
80
83
|
def theme_elements
|
81
84
|
theme.split('-')
|
82
85
|
end
|
83
86
|
|
84
|
-
#
|
87
|
+
# Lists values corresponding to each tag specified in the theme
|
88
|
+
# @return [Array] the values list
|
85
89
|
def map2tags
|
86
90
|
theme_elements.map do |element|
|
87
91
|
element == '#' ? element : tag(element)
|
88
92
|
end
|
89
93
|
end
|
90
94
|
|
91
|
-
#
|
95
|
+
# Composes the host name based on found tags
|
96
|
+
# @return [String] the new host name
|
92
97
|
def themed_host_name
|
93
98
|
map2tags.compact.join('-')
|
94
99
|
end
|
95
100
|
|
96
|
-
#
|
101
|
+
# Increments the new hostname if it finds similar ones
|
102
|
+
# @return [String] the incremented host name
|
97
103
|
def incremented_hostname
|
98
104
|
number = 1
|
99
105
|
while similar_instances.include? "#{themed_host_name}.#{domain}"
|
@@ -103,30 +109,33 @@ associated with the current instance.
|
|
103
109
|
"#{themed_host_name}".sub(/#/, "#{number}")
|
104
110
|
end
|
105
111
|
|
106
|
-
#
|
112
|
+
# The command line `--host` argument, the themed hostname or the existing
|
113
|
+
# local hostname
|
114
|
+
# @return [String] the new hostname
|
107
115
|
def new_hostname
|
108
116
|
host || incremented_hostname || local_host_name
|
109
117
|
end
|
110
118
|
|
111
|
-
#
|
112
|
-
#
|
119
|
+
# The value of the command line `--domain` argument, or the
|
120
|
+
# value of the 'Domain' EC2 tag or the local domain name.
|
121
|
+
# @return [String] the new domain name
|
113
122
|
def new_domain
|
114
123
|
domain || tag('Domain') || local_domain_name
|
115
124
|
end
|
116
125
|
|
117
|
-
# @return [String]
|
126
|
+
# @return [String] the fully qualified domain name
|
118
127
|
def new_fqdn
|
119
128
|
"#{new_hostname}.#{new_domain}"
|
120
129
|
end
|
121
130
|
|
122
|
-
#
|
131
|
+
# Modifies the 'Name' tag
|
123
132
|
def set_name_tag
|
124
133
|
return if tag('Name') == new_fqdn
|
125
134
|
puts "Setting name tag to \"#{new_fqdn}\"..."
|
126
135
|
create_tag(instance, 'Name', value: new_fqdn)
|
127
136
|
end
|
128
137
|
|
129
|
-
#
|
138
|
+
# Modifies the host name
|
130
139
|
def set_hostname
|
131
140
|
return if File.read(hostname_path).strip == new_hostname
|
132
141
|
puts "Setting local hostname (#{new_hostname})..."
|
@@ -134,7 +143,7 @@ associated with the current instance.
|
|
134
143
|
`hostname -F /etc/hostname`
|
135
144
|
end
|
136
145
|
|
137
|
-
#
|
146
|
+
# Modifies the hosts file
|
138
147
|
def update_hosts
|
139
148
|
return if File.readlines(hosts_path)
|
140
149
|
.grep(/#{new_fqdn} #{new_hostname}/)
|
@@ -9,7 +9,7 @@ module VScripts
|
|
9
9
|
include VScripts::AWS
|
10
10
|
include VScripts::Util
|
11
11
|
|
12
|
-
#
|
12
|
+
# Shows help
|
13
13
|
USAGE = <<-EOS
|
14
14
|
|
15
15
|
This command can only be run on an AWS EC2 instance. It looks for all tags
|
@@ -27,9 +27,11 @@ module VScripts
|
|
27
27
|
Options:
|
28
28
|
EOS
|
29
29
|
|
30
|
-
# @return [Array]
|
30
|
+
# @return [Array] the command specific arguments
|
31
31
|
attr_reader :arguments
|
32
32
|
|
33
|
+
# Loads the Tags2Facts class
|
34
|
+
# @param argv [Array] the command specific arguments
|
33
35
|
def initialize(argv = [])
|
34
36
|
@arguments ||= argv
|
35
37
|
end
|
@@ -45,19 +47,19 @@ module VScripts
|
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
48
|
-
#
|
50
|
+
# @return [Hash] the command line arguments
|
49
51
|
def cli
|
50
52
|
@cli ||= Trollop.with_standard_exception_handling parser do
|
51
53
|
parser.parse arguments
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
55
|
-
# @return [Array]
|
57
|
+
# @return [Array] the tags to exclude
|
56
58
|
def exclude_list
|
57
59
|
cli.all ? [] : %w(Name Domain)
|
58
60
|
end
|
59
61
|
|
60
|
-
# @return [JSON]
|
62
|
+
# @return [JSON] the formatted JSON string
|
61
63
|
def tags_json
|
62
64
|
filtered = tags_without(exclude_list)
|
63
65
|
if filtered.empty?
|
@@ -67,7 +69,7 @@ module VScripts
|
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
70
|
-
# Writes the formatted JSON to
|
72
|
+
# Writes the formatted JSON to the file
|
71
73
|
def execute
|
72
74
|
file = cli.file
|
73
75
|
puts "Writing tags to \"#{file}\""
|
data/lib/vscripts/util.rb
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
module VScripts
|
2
2
|
module Util
|
3
|
-
# Local system functions library
|
3
|
+
# Local system functions library.
|
4
4
|
module LocalSystem
|
5
|
-
#
|
5
|
+
# @return [String] the hosts file path
|
6
6
|
def hosts_path
|
7
7
|
'/etc/hosts'
|
8
8
|
end
|
9
9
|
|
10
|
-
# @return[String]
|
10
|
+
# @return [String] the contents of the hosts file
|
11
11
|
def hosts_file
|
12
12
|
File.read(hosts_path)
|
13
13
|
end
|
14
14
|
|
15
|
-
#
|
15
|
+
# @return [String] the hostname file path
|
16
16
|
def hostname_path
|
17
17
|
'/etc/hostname'
|
18
18
|
end
|
19
19
|
|
20
|
-
#
|
20
|
+
# @return [String] the local fully qualified domain
|
21
21
|
def local_fqdn
|
22
22
|
`hostname -f`.strip
|
23
23
|
end
|
24
24
|
|
25
|
-
#
|
25
|
+
# @return [String] the local host name
|
26
26
|
def local_host_name
|
27
27
|
`hostname`.strip
|
28
28
|
end
|
29
29
|
|
30
|
-
#
|
30
|
+
# @return [String] the local domain name
|
31
31
|
def local_domain_name
|
32
32
|
`dnsdomainname`.strip
|
33
33
|
rescue
|
@@ -35,6 +35,7 @@ module VScripts
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# Tries to get the reverse dns
|
38
|
+
# @return [String] the reverse dns
|
38
39
|
def external_dns
|
39
40
|
ext_ip = `wget -q -O - checkip.dyndns.org \
|
40
41
|
| sed -e 's/[^[:digit:]|.]//g'`
|
@@ -44,12 +45,15 @@ module VScripts
|
|
44
45
|
end
|
45
46
|
|
46
47
|
# Creates the directory for the specified file
|
48
|
+
# @param file [String] the path of the file
|
47
49
|
def ensure_file_dir(file)
|
48
50
|
path = File.dirname(file)
|
49
51
|
`mkdir -p #{path}`
|
50
52
|
end
|
51
53
|
|
52
|
-
# Writes to file
|
54
|
+
# Writes to a file
|
55
|
+
# @param file [String] the path of the file
|
56
|
+
# @param body [String] the body of the file
|
53
57
|
def write_file(file, body)
|
54
58
|
ensure_file_dir(file)
|
55
59
|
File.open(file, 'w') do |newfile|
|
@@ -60,6 +64,8 @@ module VScripts
|
|
60
64
|
end
|
61
65
|
|
62
66
|
# Ensures the specified file has the specified content
|
67
|
+
# @param file [String] the path of the file
|
68
|
+
# @param body [String] the body of the file
|
63
69
|
def ensure_file_content(file, body)
|
64
70
|
write = write_file(file, body)
|
65
71
|
read = IO.read(file)
|
data/lib/vscripts/version.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
# Version number
|
2
1
|
module VScripts
|
2
|
+
# @return [String] the version number
|
3
3
|
VERSION = File.read(File.expand_path('../../../VERSION', __FILE__)).strip
|
4
|
+
# @return [String] the semantic version number
|
4
5
|
VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH = VERSION.split('.')
|
6
|
+
# @return [String] the copyrighted version number
|
5
7
|
VERSION_C = "VScripts #{VERSION} (c) #{Time.new.year} Vlad Ghinea"
|
6
8
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -23,5 +23,9 @@ RSpec.configure {|config|
|
|
23
23
|
config.formatter = :documentation # :progress, :html, :textmate
|
24
24
|
|
25
25
|
# Clean up
|
26
|
-
config.after(:suite) {
|
26
|
+
config.after(:suite) {
|
27
|
+
unless ENV['TRAVIS']
|
28
|
+
`ls /tmp/vscripts-test-* &> /dev/null && rm -r /tmp/vscripts-test-*`
|
29
|
+
end
|
30
|
+
}
|
27
31
|
}
|
data/tasks/deploy.rake
CHANGED
@@ -106,6 +106,7 @@ def merge_changes
|
|
106
106
|
switch_to_branch('master')
|
107
107
|
puts "Merging \"#{DEV_BRANCH}\" branch"
|
108
108
|
abort 'ERROR: Conflicts found; Stopping!' if merge =~ /conflict/i
|
109
|
+
switch_to_branch(branch) # Switch back to whatever branch was before
|
109
110
|
end
|
110
111
|
|
111
112
|
def push_release
|
data/vscripts.gemspec
CHANGED
@@ -4,34 +4,39 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'vscripts/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
11
|
-
spec.
|
12
|
-
spec.
|
13
|
-
|
14
|
-
|
7
|
+
spec.name = 'vscripts'
|
8
|
+
spec.version = VScripts::VERSION
|
9
|
+
spec.authors = ['Vlad Ghinea']
|
10
|
+
spec.email = ['vlad@ghn.me']
|
11
|
+
spec.summary = %q{VladGh.com's automation scripts}
|
12
|
+
spec.description = <<-EOF
|
13
|
+
VScripts is a command line utility that performs a series of tasks used on
|
14
|
+
VladGh.com's deployment.
|
15
|
+
EOF
|
16
|
+
spec.homepage = 'https://github.com/vghn/vscripts'
|
17
|
+
spec.license = 'Apache 2.0'
|
18
|
+
|
19
|
+
spec.metadata = {
|
20
|
+
'issue_tracker' => 'https://github.com/vghn/vscripts/issues'
|
21
|
+
}
|
15
22
|
|
16
23
|
spec.files = `git ls-files -z`.split("\x0")
|
17
24
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
25
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
26
|
spec.require_paths = ['lib']
|
20
27
|
|
21
|
-
spec.
|
22
|
-
|
23
|
-
spec.add_runtime_dependency '
|
24
|
-
spec.add_runtime_dependency 'trollop'
|
25
|
-
spec.add_runtime_dependency 'rake'
|
28
|
+
spec.required_ruby_version = '>= 1.9.3'
|
29
|
+
|
30
|
+
spec.add_runtime_dependency 'aws-sdk', '~> 1.0'
|
31
|
+
spec.add_runtime_dependency 'trollop', '~> 2.0'
|
26
32
|
|
27
|
-
spec.add_development_dependency '
|
28
|
-
spec.add_development_dependency '
|
29
|
-
spec.add_development_dependency 'rack-test'
|
33
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
34
|
+
spec.add_development_dependency 'bundler', '~> 1.0'
|
30
35
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
|
-
spec.add_development_dependency 'yard'
|
32
|
-
spec.add_development_dependency 'reek'
|
33
|
-
spec.add_development_dependency 'rubocop'
|
34
|
-
spec.add_development_dependency 'coveralls'
|
35
|
-
spec.add_development_dependency 'fpm'
|
36
|
-
spec.add_development_dependency 'travis', '~> 1.
|
36
|
+
spec.add_development_dependency 'yard', '~> 0.0'
|
37
|
+
spec.add_development_dependency 'reek', '~> 1.0'
|
38
|
+
spec.add_development_dependency 'rubocop', '~> 0.0'
|
39
|
+
spec.add_development_dependency 'coveralls', '~> 0.0'
|
40
|
+
spec.add_development_dependency 'fpm', '~> 1.0'
|
41
|
+
spec.add_development_dependency 'travis', '~> 1.0'
|
37
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vscripts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vlad Ghinea
|
@@ -14,114 +14,58 @@ dependencies:
|
|
14
14
|
name: aws-sdk
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ! '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: unicorn
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ! '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ! '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: sinatra
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ! '>='
|
17
|
+
- - ~>
|
46
18
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
19
|
+
version: '1.0'
|
48
20
|
type: :runtime
|
49
21
|
prerelease: false
|
50
22
|
version_requirements: !ruby/object:Gem::Requirement
|
51
23
|
requirements:
|
52
|
-
- -
|
24
|
+
- - ~>
|
53
25
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
26
|
+
version: '1.0'
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
28
|
name: trollop
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
58
30
|
requirements:
|
59
|
-
- -
|
31
|
+
- - ~>
|
60
32
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
33
|
+
version: '2.0'
|
62
34
|
type: :runtime
|
63
35
|
prerelease: false
|
64
36
|
version_requirements: !ruby/object:Gem::Requirement
|
65
37
|
requirements:
|
66
|
-
- -
|
38
|
+
- - ~>
|
67
39
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
40
|
+
version: '2.0'
|
69
41
|
- !ruby/object:Gem::Dependency
|
70
42
|
name: rake
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
72
44
|
requirements:
|
73
|
-
- -
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ! '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: bundler
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ! '>='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ! '>='
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rack
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ! '>='
|
45
|
+
- - ~>
|
102
46
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
47
|
+
version: '10.0'
|
104
48
|
type: :development
|
105
49
|
prerelease: false
|
106
50
|
version_requirements: !ruby/object:Gem::Requirement
|
107
51
|
requirements:
|
108
|
-
- -
|
52
|
+
- - ~>
|
109
53
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
54
|
+
version: '10.0'
|
111
55
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
56
|
+
name: bundler
|
113
57
|
requirement: !ruby/object:Gem::Requirement
|
114
58
|
requirements:
|
115
|
-
- -
|
59
|
+
- - ~>
|
116
60
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
61
|
+
version: '1.0'
|
118
62
|
type: :development
|
119
63
|
prerelease: false
|
120
64
|
version_requirements: !ruby/object:Gem::Requirement
|
121
65
|
requirements:
|
122
|
-
- -
|
66
|
+
- - ~>
|
123
67
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
68
|
+
version: '1.0'
|
125
69
|
- !ruby/object:Gem::Dependency
|
126
70
|
name: rspec
|
127
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,87 +84,92 @@ dependencies:
|
|
140
84
|
name: yard
|
141
85
|
requirement: !ruby/object:Gem::Requirement
|
142
86
|
requirements:
|
143
|
-
- -
|
87
|
+
- - ~>
|
144
88
|
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
89
|
+
version: '0.0'
|
146
90
|
type: :development
|
147
91
|
prerelease: false
|
148
92
|
version_requirements: !ruby/object:Gem::Requirement
|
149
93
|
requirements:
|
150
|
-
- -
|
94
|
+
- - ~>
|
151
95
|
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
96
|
+
version: '0.0'
|
153
97
|
- !ruby/object:Gem::Dependency
|
154
98
|
name: reek
|
155
99
|
requirement: !ruby/object:Gem::Requirement
|
156
100
|
requirements:
|
157
|
-
- -
|
101
|
+
- - ~>
|
158
102
|
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
103
|
+
version: '1.0'
|
160
104
|
type: :development
|
161
105
|
prerelease: false
|
162
106
|
version_requirements: !ruby/object:Gem::Requirement
|
163
107
|
requirements:
|
164
|
-
- -
|
108
|
+
- - ~>
|
165
109
|
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
110
|
+
version: '1.0'
|
167
111
|
- !ruby/object:Gem::Dependency
|
168
112
|
name: rubocop
|
169
113
|
requirement: !ruby/object:Gem::Requirement
|
170
114
|
requirements:
|
171
|
-
- -
|
115
|
+
- - ~>
|
172
116
|
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
117
|
+
version: '0.0'
|
174
118
|
type: :development
|
175
119
|
prerelease: false
|
176
120
|
version_requirements: !ruby/object:Gem::Requirement
|
177
121
|
requirements:
|
178
|
-
- -
|
122
|
+
- - ~>
|
179
123
|
- !ruby/object:Gem::Version
|
180
|
-
version: '0'
|
124
|
+
version: '0.0'
|
181
125
|
- !ruby/object:Gem::Dependency
|
182
126
|
name: coveralls
|
183
127
|
requirement: !ruby/object:Gem::Requirement
|
184
128
|
requirements:
|
185
|
-
- -
|
129
|
+
- - ~>
|
186
130
|
- !ruby/object:Gem::Version
|
187
|
-
version: '0'
|
131
|
+
version: '0.0'
|
188
132
|
type: :development
|
189
133
|
prerelease: false
|
190
134
|
version_requirements: !ruby/object:Gem::Requirement
|
191
135
|
requirements:
|
192
|
-
- -
|
136
|
+
- - ~>
|
193
137
|
- !ruby/object:Gem::Version
|
194
|
-
version: '0'
|
138
|
+
version: '0.0'
|
195
139
|
- !ruby/object:Gem::Dependency
|
196
140
|
name: fpm
|
197
141
|
requirement: !ruby/object:Gem::Requirement
|
198
142
|
requirements:
|
199
|
-
- -
|
143
|
+
- - ~>
|
200
144
|
- !ruby/object:Gem::Version
|
201
|
-
version: '0'
|
145
|
+
version: '1.0'
|
202
146
|
type: :development
|
203
147
|
prerelease: false
|
204
148
|
version_requirements: !ruby/object:Gem::Requirement
|
205
149
|
requirements:
|
206
|
-
- -
|
150
|
+
- - ~>
|
207
151
|
- !ruby/object:Gem::Version
|
208
|
-
version: '0'
|
152
|
+
version: '1.0'
|
209
153
|
- !ruby/object:Gem::Dependency
|
210
154
|
name: travis
|
211
155
|
requirement: !ruby/object:Gem::Requirement
|
212
156
|
requirements:
|
213
157
|
- - ~>
|
214
158
|
- !ruby/object:Gem::Version
|
215
|
-
version: 1.
|
159
|
+
version: '1.0'
|
216
160
|
type: :development
|
217
161
|
prerelease: false
|
218
162
|
version_requirements: !ruby/object:Gem::Requirement
|
219
163
|
requirements:
|
220
164
|
- - ~>
|
221
165
|
- !ruby/object:Gem::Version
|
222
|
-
version: 1.
|
223
|
-
description:
|
166
|
+
version: '1.0'
|
167
|
+
description: ! 'VScripts is a command line utility that performs a series of tasks
|
168
|
+
used on
|
169
|
+
|
170
|
+
VladGh.com''s deployment.
|
171
|
+
|
172
|
+
'
|
224
173
|
email:
|
225
174
|
- vlad@ghn.me
|
226
175
|
executables:
|
@@ -230,6 +179,7 @@ extra_rdoc_files: []
|
|
230
179
|
files:
|
231
180
|
- .gitignore
|
232
181
|
- .travis.yml
|
182
|
+
- .yardopts
|
233
183
|
- CHANGELOG.md
|
234
184
|
- Gemfile
|
235
185
|
- LICENSE
|
@@ -266,7 +216,8 @@ files:
|
|
266
216
|
homepage: https://github.com/vghn/vscripts
|
267
217
|
licenses:
|
268
218
|
- Apache 2.0
|
269
|
-
metadata:
|
219
|
+
metadata:
|
220
|
+
issue_tracker: https://github.com/vghn/vscripts/issues
|
270
221
|
post_install_message:
|
271
222
|
rdoc_options: []
|
272
223
|
require_paths:
|
@@ -275,7 +226,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
275
226
|
requirements:
|
276
227
|
- - ! '>='
|
277
228
|
- !ruby/object:Gem::Version
|
278
|
-
version:
|
229
|
+
version: 1.9.3
|
279
230
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
280
231
|
requirements:
|
281
232
|
- - ! '>='
|