simple_provision 0.99.8 → 0.99.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -50
- data/lib/simple_provision/configuration.rb +3 -3
- data/lib/simple_provision/scp.rb +29 -13
- data/lib/simple_provision/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba3a4cf0d797ab20a94b1a4a64802527c1f53c40
|
4
|
+
data.tar.gz: 83dbd3ee11fae8d35af90f17cb69c51e6e5a547d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52f1c14e75716dfcee3052212b0bab8722ac96610219def78d3d8a023b5ead46711a8b6e48397b34d6f96b2258e314e262ec5d1f72aec2a0e0adf005c2e04f88
|
7
|
+
data.tar.gz: a8526e1aad13fcde6ca0d567e30084f9d63325ad428ac63153fcf2566375d02f3e0c2759ce13d13d89ae85ba77e4fff022deff86512eddbe047034f0f8eb020d
|
data/README.md
CHANGED
@@ -2,15 +2,9 @@
|
|
2
2
|
This is based on the work that brandonhilkert initally carried to automate
|
3
3
|
EC2 instance provision with YAML and SHELL script. It tries to bring the good spirit: SIMPLE, and JUST WORK to the world of every remote machine.
|
4
4
|
|
5
|
-
I
|
6
|
-
|
7
|
-
|
8
|
-
we have the working provision profile in just half an hour. From that
|
9
|
-
moment, provision another instance is just the matter of kicking off
|
10
|
-
a command from the terminal.
|
11
|
-
|
12
|
-
I use simple_provision with mina in my Rails projects and the combination
|
13
|
-
has been working really well for me.
|
5
|
+
I used to use this to do all the provision of Redis, Postgres, Nginx,
|
6
|
+
Unicorn, Cron, etc before. These days I just use this to provision
|
7
|
+
docker on the server and then use crane to orchestrate the rest.
|
14
8
|
|
15
9
|
Let's rock.
|
16
10
|
|
@@ -20,8 +14,8 @@ Don't forget to also checkout the recipes collection
|
|
20
14
|
https://github.com/phuongnd08/simple_provision_recipes
|
21
15
|
|
22
16
|
# How it works
|
23
|
-
This gem carries the provision by uploading a set of scripts
|
24
|
-
files
|
17
|
+
This gem carries the provision by uploading a set of scripts and
|
18
|
+
files to the server and execute there.
|
25
19
|
|
26
20
|
It's up to you to choose the language you want. I often use a mix of
|
27
21
|
SHELL and RUBY scripts to accomplish the task. SHELL for some simple stuff
|
@@ -33,13 +27,29 @@ and then you can start use ruby/python. The install of ruby and python can be
|
|
33
27
|
as simple as create a bash contains "yum install ruby(python) -y" and include
|
34
28
|
it in the top of the `scripts` section in your server definition file.
|
35
29
|
|
30
|
+
## Installation
|
31
|
+
|
32
|
+
Add this line to your application's Gemfile:
|
33
|
+
|
34
|
+
gem 'simple_provision'
|
35
|
+
|
36
|
+
And then execute:
|
37
|
+
|
38
|
+
$ bundle
|
39
|
+
|
40
|
+
Or install it yourself as:
|
41
|
+
|
42
|
+
$ gem install simple_provision
|
43
|
+
|
44
|
+
|
36
45
|
# Project Structure
|
37
|
-
|
38
|
-
|
39
|
-
|
46
|
+
The provision profile need to be defined inside /provision directory.
|
47
|
+
Since it's just scripting, feel free to use ERB, HAML, or any kind of
|
48
|
+
templates that you want, assume you install the necessary library before
|
49
|
+
you do that.
|
40
50
|
|
41
51
|
```
|
42
|
-
./
|
52
|
+
./provision
|
43
53
|
├── files
|
44
54
|
│ ├── keys
|
45
55
|
│ │ └── deploy_key
|
@@ -56,34 +66,16 @@ It's up to you to use ERB, HAML or any kind of template processors.
|
|
56
66
|
│ ├── search_service_code.sh
|
57
67
|
│ └── search_service_env.sh
|
58
68
|
└── servers
|
59
|
-
├──
|
69
|
+
├── webapp.yml
|
70
|
+
├── docker.yml
|
60
71
|
└── search-service.yml
|
61
72
|
```
|
62
73
|
|
63
|
-
|
64
|
-
|
65
|
-
uploaded to the server machine and executed there.
|
66
|
-
|
67
|
-
## Installation
|
74
|
+
In /provision/servers/{webapp, docker, search-service}.yml, you define
|
75
|
+
your server defintion (read below).
|
68
76
|
|
69
|
-
|
70
|
-
|
71
|
-
gem 'simple_provision'
|
72
|
-
|
73
|
-
And then execute:
|
74
|
-
|
75
|
-
$ bundle
|
76
|
-
|
77
|
-
Or install it yourself as:
|
78
|
-
|
79
|
-
$ gem install simple_provision
|
80
|
-
|
81
|
-
## Servers Configuration
|
82
|
-
|
83
|
-
### Server Definition
|
84
|
-
To define a server type, create a yaml file in the `./servers` directory with the following format:
|
85
|
-
|
86
|
-
`./servers/my-awesome-server.yml`
|
77
|
+
## Server Definition
|
78
|
+
To define a server type, create a yaml file in the `./provision/servers` directory with the following format:
|
87
79
|
|
88
80
|
```yaml
|
89
81
|
files:
|
@@ -98,22 +90,17 @@ env:
|
|
98
90
|
WEBROOT: /var/www/app
|
99
91
|
```
|
100
92
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
```yaml
|
106
|
-
private_key_path: /Users/bhilkert/.ssh/pd-app-server
|
107
|
-
```
|
108
|
-
|
93
|
+
File declared in files and scripts can point to anywhere in the machine
|
94
|
+
from which you make the provision. The file path is calculated relative
|
95
|
+
to `./provision` directory. These files/scripts will then be uploaded to
|
96
|
+
provisioned server at ~/files and ~/scripts
|
109
97
|
|
110
98
|
### Passing variables to scripts
|
111
99
|
Variables defined in `env` will be exposed to scripts during execution.
|
112
|
-
That way you can use the same scripts for different type of
|
113
|
-
still be able to produce different outcomes.
|
100
|
+
That way you can re-use the same scripts for different type of servers.
|
114
101
|
|
115
102
|
## Provision your server
|
116
|
-
`simpro my-awesome-server root@my-host`
|
103
|
+
`bundle exec simpro my-awesome-server root@my-host`
|
117
104
|
|
118
105
|
## Contributing
|
119
106
|
|
@@ -18,7 +18,7 @@ module SimpleProvision
|
|
18
18
|
|
19
19
|
def default_options
|
20
20
|
begin
|
21
|
-
YAML.load(File.read(
|
21
|
+
YAML.load(File.read(server_file))
|
22
22
|
rescue Errno::ENOENT
|
23
23
|
{}
|
24
24
|
end
|
@@ -28,12 +28,12 @@ module SimpleProvision
|
|
28
28
|
begin
|
29
29
|
YAML.load(File.read(server_file))
|
30
30
|
rescue Errno::ENOENT
|
31
|
-
raise MissingServerConfiguration, "Please create a configuration file '
|
31
|
+
raise MissingServerConfiguration, "Please create a configuration file './#{server_file}'"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
def server_file
|
36
|
-
"servers/#{profile}.yml"
|
36
|
+
"provision/servers/#{profile}.yml"
|
37
37
|
end
|
38
38
|
|
39
39
|
def read_and_parse_server_options
|
data/lib/simple_provision/scp.rb
CHANGED
@@ -21,32 +21,48 @@ module SimpleProvision
|
|
21
21
|
includes = files + scripts
|
22
22
|
|
23
23
|
if includes.empty?
|
24
|
-
raise "Both files and scripts are empty. You should provide some"
|
24
|
+
raise "Both files and scripts are empty. You should provide some."
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
cmds = [
|
28
|
+
"cd provision",
|
29
|
+
"rm -rf tmp",
|
30
|
+
"mkdir tmp",
|
31
|
+
"mkdir tmp/files",
|
32
|
+
"mkdir tmp/scripts"
|
33
|
+
]
|
34
|
+
|
35
|
+
files.each { |f| cmds << "cp #{f} tmp/files/"}
|
36
|
+
|
37
|
+
scripts.each { |f| cmds << "cp #{f} tmp/scripts/" }
|
36
38
|
|
37
|
-
|
39
|
+
cmds << "cd tmp && tar -czf #{FILENAME} files/ scripts/"
|
40
|
+
|
41
|
+
if ENV["VERBOSE"]
|
42
|
+
puts "==============Execute Locally============"
|
43
|
+
puts cmds.join("\n")
|
44
|
+
puts "========================================="
|
45
|
+
end
|
46
|
+
system cmds.join("\n")
|
38
47
|
end
|
39
48
|
|
40
49
|
def scp_files_to_server
|
50
|
+
path = "provision/tmp/#{FILENAME}"
|
51
|
+
|
41
52
|
Net::SCP.start(@host, @username) do |scp|
|
42
|
-
scp.upload!(
|
53
|
+
scp.upload!(path, ".")
|
43
54
|
end
|
44
55
|
rescue Net::SSH::HostKeyMismatch
|
45
56
|
puts "Please run ssh #{@username}@#{@host} to verify the fingerprint first"
|
46
57
|
end
|
47
58
|
|
48
59
|
def remove_local_archive
|
49
|
-
|
60
|
+
cmds = [
|
61
|
+
"cd provision",
|
62
|
+
"rm -rf tmp"
|
63
|
+
]
|
64
|
+
|
65
|
+
system cmds.join("\n")
|
50
66
|
end
|
51
67
|
end
|
52
68
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_provision
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.99.
|
4
|
+
version: 0.99.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phuong Gia Su
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-09-
|
12
|
+
date: 2014-09-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|