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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16cab0f7bac2b4541f524b7bc291ebaeab17f716
4
- data.tar.gz: 5830849d9fe535a9b3e4ca73c0cf41a1195965bc
3
+ metadata.gz: ba3a4cf0d797ab20a94b1a4a64802527c1f53c40
4
+ data.tar.gz: 83dbd3ee11fae8d35af90f17cb69c51e6e5a547d
5
5
  SHA512:
6
- metadata.gz: 398a965f8acaf2d6ae1acd5ed83e8dfeae4d5f0ca6b4f8c6206ea8f39ab995811e44bf687b78e0ebd3f5dbb4581aadfd8fa2eb8967547e9c33086e889a00b1bd
7
- data.tar.gz: f8095de17806127930c141aaef5fe0f404410151e08acae0c1de71e3bcc2b8244032d31f7cae391171e235c6210688b2ae22df08f3d158c8721ff4e14107d669
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 had been banging my head trying to work with Chef and Puppet in the
6
- past, so this is my attempt to make the provision stuff easier to be
7
- implemented. With this tool, you get your hand dirty in a few minutes and
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 (and
24
- files) to the server and execute there.
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
- As simple as it could: One or few servers definition written in YAML + setup scripts written in
38
- SHELL, RUBY and PYTHON + text files as resource.
39
- It's up to you to use ERB, HAML or any kind of template processors.
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
- ./provisions
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
- ├── defaults.yml
69
+ ├── webapp.yml
70
+ ├── docker.yml
60
71
  └── search-service.yml
61
72
  ```
62
73
 
63
- So: You put definition of each type of server in `servers/type.yml`.
64
- In `files` and `scripts` folder, you place files and scripts that will be
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
- Add this line to your application's Gemfile:
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
- ### Shared Definitions
102
-
103
- You can share definitions across server types with `./servers/defaults.yml`
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 server and
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('servers/defaults.yml'))
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 './servers/#{profile}.yml'"
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
@@ -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
- system("mkdir tmp")
28
- system("mkdir tmp/files")
29
- system("mkdir tmp/scripts")
30
- files.each do |f|
31
- system("cp #{f} tmp/files/")
32
- end
33
- scripts.each do |f|
34
- system("cp #{f} tmp/scripts/")
35
- end
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
- system("cd tmp && tar -czf #{FILENAME} files/ scripts/")
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!("tmp/#{FILENAME}", ".")
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
- `rm -rf tmp`
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
@@ -1,3 +1,3 @@
1
1
  module SimpleProvision
2
- VERSION = "0.99.8"
2
+ VERSION = "0.99.9"
3
3
  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.8
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-01 00:00:00.000000000 Z
12
+ date: 2014-09-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler