orats 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Gemfile +1 -1
  4. data/{LICENSE.txt → LICENSE} +21 -21
  5. data/README.md +51 -346
  6. data/Rakefile +1 -1
  7. data/bin/orats +5 -2
  8. data/lib/orats/argv_adjust.rb +61 -0
  9. data/lib/orats/cli.rb +53 -141
  10. data/lib/orats/cli_help/new +27 -0
  11. data/lib/orats/cli_help/nuke +19 -0
  12. data/lib/orats/commands/new/exec.rb +59 -0
  13. data/lib/orats/commands/new/rails.rb +197 -0
  14. data/lib/orats/commands/new/server.rb +67 -0
  15. data/lib/orats/commands/nuke.rb +66 -44
  16. data/lib/orats/common.rb +76 -0
  17. data/lib/orats/postgres.rb +90 -0
  18. data/lib/orats/process.rb +35 -0
  19. data/lib/orats/redis.rb +25 -0
  20. data/lib/orats/shell.rb +12 -0
  21. data/lib/orats/templates/auth.rb +96 -82
  22. data/lib/orats/templates/base.rb +115 -110
  23. data/lib/orats/templates/includes/new/rails/.env +28 -28
  24. data/lib/orats/templates/includes/new/rails/Gemfile +4 -4
  25. data/lib/orats/templates/includes/new/rails/config/{whenever.rb → schedule.rb} +0 -0
  26. data/lib/orats/ui.rb +33 -0
  27. data/lib/orats/version.rb +3 -2
  28. data/lib/orats.rb +2 -1
  29. data/orats.gemspec +7 -5
  30. data/test/integration/cli_test.rb +28 -177
  31. data/test/test_helper.rb +24 -9
  32. metadata +17 -29
  33. data/lib/orats/commands/common.rb +0 -146
  34. data/lib/orats/commands/diff/compare.rb +0 -106
  35. data/lib/orats/commands/diff/exec.rb +0 -60
  36. data/lib/orats/commands/diff/parse.rb +0 -66
  37. data/lib/orats/commands/inventory.rb +0 -100
  38. data/lib/orats/commands/playbook.rb +0 -60
  39. data/lib/orats/commands/project/exec.rb +0 -74
  40. data/lib/orats/commands/project/rails.rb +0 -162
  41. data/lib/orats/commands/project/server.rb +0 -57
  42. data/lib/orats/commands/role.rb +0 -70
  43. data/lib/orats/commands/ui.rb +0 -47
  44. data/lib/orats/templates/includes/inventory/group_vars/all.yml +0 -202
  45. data/lib/orats/templates/includes/inventory/hosts +0 -8
  46. data/lib/orats/templates/includes/playbook/Galaxyfile +0 -15
  47. data/lib/orats/templates/includes/playbook/common.yml +0 -23
  48. data/lib/orats/templates/includes/playbook/site.yml +0 -36
  49. data/lib/orats/templates/includes/role/.travis.yml +0 -19
  50. data/lib/orats/templates/includes/role/README.md +0 -62
  51. data/lib/orats/templates/includes/role/meta/main.yml +0 -123
  52. data/lib/orats/templates/includes/role/tests/inventory +0 -1
  53. data/lib/orats/templates/includes/role/tests/main.yml +0 -7
  54. data/lib/orats/templates/playbook.rb +0 -119
  55. data/lib/orats/templates/role.rb +0 -144
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93556f428c47b927511dad2d9bc4581f08512abe
4
- data.tar.gz: f20bb7f697ce51209756d7ab10274f5df982847d
3
+ metadata.gz: 5764fae3d75aa46b816aa3267b9f04da946ed458
4
+ data.tar.gz: ed8c551ef377131ddf6ee19b28fe231813a5bc6e
5
5
  SHA512:
6
- metadata.gz: 7c17135f4b66475105a0226cca3c8431155e6e776ed517655d3dccb4f71bd9b7f27099624d51352009eaf23e6aa24b032b28c1a620f34c9e9db59ce892a69aa7
7
- data.tar.gz: 79546ec90a891606628f65699c0d5cb6d82f638252a095fcd801bb5c7578f267fcaee1830ab0743dc879a0d9c292bcb1699287870fb34bf57b1ff2498624882f
6
+ metadata.gz: 72b68d0ca30428c544d59d150057cf9fa987cec678c22a80dee8c90b7a0e3afc730d8e06c84e4b51b888e018110d36502e178ab170965a2d2f83c04b78796d9e
7
+ data.tar.gz: 2dd3ab36868fd5334f9ba9059b99d250ec063ee8fc64aa027289f640bfacf00d80027918a93194fafbad2410caf2f9a01860455030e136df14754679f13aa17c
data/.gitignore CHANGED
@@ -5,4 +5,5 @@
5
5
  *~
6
6
  .idea/
7
7
  *.gem
8
- Gemfile.lock
8
+ Gemfile.lock
9
+ .rubocop.yml
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gemspec
3
+ gemspec
@@ -1,22 +1,22 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2014 Nick Janetakis <nick.janetakis@gmail.com>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- 'Software'), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Nick Janetakis <nick.janetakis@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
22
  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,11 +1,8 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/orats.png)](http://badge.fury.io/rb/orats)
2
2
 
3
- ##### Note
4
- This readme file is based off the master version of orats. If you want accurate documentation then make sure to select the branch for the latest *gem version* of orats.
5
-
6
3
  ## What is orats and what problem does it solve?
7
4
 
8
- It stands for opinionated rails application templates. The templates include solving tedious tasks that you would do for most projects. It handles creating a rails application with a bunch of opinions and optionally an ansible inventory/playbook so you can provision your servers and deploy your apps effortlessly.
5
+ It stands for opinionated rails application templates. The templates include solving tedious tasks that you would do for most projects. It handles creating a rails application with a bunch of opinions and best practices.
9
6
 
10
7
  ## What version of Rails and Ruby are you targeting?
11
8
 
@@ -17,39 +14,24 @@ Gems will also be updated once they are proven to work on the target rails/ruby
17
14
  - [System dependencies](#system-dependencies)
18
15
  - [Installation](#installation)
19
16
  - [Commands](#commands)
20
- - [Project](#project)
21
- - [Inventory](#inventory)
22
- - [Try it](#try-the-inventory-command)
23
- - [Playbook](#playbook)
24
- - [Try it](#try-the-playbook-command)
25
- - [Ansible roles](#ansible-roles-used)
26
- - [FAQ](#playbook-faq)
27
- - [What is the Galaxyfile?](#what-is-the-galaxyfile)
28
- - [Role](#role)
29
- - [Try it](#try-the-role-command)
30
- - [Diff](#diff)
31
- - [Try it](#try-the-diff-command)
17
+ - [New](#new)
18
+ - [Try it](#try-the-new-command)
19
+ - [Nuke](#nuke)
20
+ - [Try it](#try-the-nuke-command)
32
21
  - [Templates](#templates)
33
22
  - [Try it](#try-the-templates-command)
34
23
  - [Available templates](#available-templates)
35
24
  - [Base](#base)
36
25
  - [Try it](#try-the-base-template)
37
- - [FAQ](#base-faq)
38
- - [What's with the directory structure?](#whats-with-the-directory-structure)
39
- - [Development configuration?](#base-what-do-i-need-to-configure-for-development)
40
- - [Production configuration?](#base-what-do-i-need-to-configure-for-production)
41
26
  - [Auth](#auth)
42
27
  - [Try it](#try-the-auth-template)
43
- - [FAQ](#auth-faq)
44
- - [Development configuration?](#auth-what-do-i-need-to-configure-for-development)
45
- - [Production configuration?](#auth-what-do-i-need-to-configure-for-production)
46
28
  - [Custom](#custom)
47
29
  - [Try it](#try-the-custom-template)
48
30
  - [FAQ](#custom-faq)
49
31
  - [Any guides on how to make custom templates?](#any-guides-on-how-to-make-custom-templates)
32
+ - [The .oratsrc file](#the-oratsrc-file)
50
33
  - [Wiki](https://github.com/nickjj/orats/wiki)
51
34
  - [What to look at after making a new project](https://github.com/nickjj/orats/wiki/What-to-look-at-after-making-a-new-project)
52
- - [Get your application on a server](https://github.com/nickjj/orats/wiki/Get-your-application-on-a-server)
53
35
 
54
36
  ## System dependencies
55
37
 
@@ -61,15 +43,13 @@ Before running orats...
61
43
  - [Postgres](https://wiki.postgresql.org/wiki/Detailed_installation_guides)
62
44
  - [Redis](http://redis.io/topics/quickstart)
63
45
  - Ruby 2.1.x - [chruby](https://github.com/postmodern/chruby) | [rbenv](https://github.com/sstephenson/rbenv) | [rvm](https://rvm.io/)
64
- - Rails 4.1.x - `gem install rails -v '~> 4.1.2'`
46
+ - Rails 4.1.x - `gem install rails -v '~> 4.1.4'`
65
47
 
66
48
  #### You should install
67
49
 
68
- - [Ansible](http://docs.ansible.com/intro_installation.html)
69
- - If you plan to use the ansible features (optional)
70
50
  - [Imagemagick](https://www.google.com/search?q=install+imagemagick)
71
51
  - If you want favicons to be automatically created (optional)
72
-
52
+
73
53
  #### You need these processes to be running
74
54
 
75
55
  - Postgres
@@ -83,262 +63,25 @@ Or if you already have orats then run `gem update orats` to upgrade to the lates
83
63
 
84
64
  ## Commands
85
65
 
86
- Here is an overview of the available commands. You can find out more information about each command and flag by running `orats help <command name>` from your terminal. You can also type `orats` on its own to see a list of all commands.
87
-
88
- - **Create a new orats project**:
89
- - `orats project <TARGET_PATH> --pg-password foo`
90
- - Configuration:
91
- - Optionally takes: `--pg-location [localhost]`
92
- - Optionally takes: `--pg-username [postgres]`
93
- - Optionally takes: `--redis-location [localhost]`
94
- - Optionally takes: `--redis-password []`
95
- - Template:
96
- - Optionally takes: `--template []`
97
- - Optionally takes: `--custom []`
98
- - Project:
99
- - Optionally takes: `--skip-ansible [false]`
100
- - Optionally takes: `--skip-server-start [false]`
101
-
102
- - **Create an ansible inventory**:
103
- - `orats inventory <TARGET_PATH>`
104
-
105
- - **Create an ansible playbook**:
106
- - `orats playbook <TARGET_PATH>`
107
- - Template:
108
- - Optionally takes: `--custom []`
109
-
110
- - **Create a new ansible role**:
111
- - `orats role <TARGET_PATH>`
112
- - Configuration:
113
- - Optionally takes: `--repo-name []`
114
- - Template:
115
- - Optionally takes: `--custom []`
116
-
117
- - **Delete a directory and optionally all data associated to it**:
118
- - `orats nuke <TARGET_PATH>`
119
- - Optionally takes: `--skip-data [false]`
120
-
121
- - **Compare differences between your orats files and the latest version's
122
- files**:
123
- - `orats diff [options]`
124
- - Optionally takes: `--galaxyfile []`
125
- - Optionally takes: `--playbook []`
126
- - Optionally takes: `--hosts []`
127
- - Optionally takes: `--inventory []`
128
-
129
- - **Get a list of available orats templates**:
130
- - `orats templates`
131
-
132
- ### Project
133
-
134
- The project command kicks off a new orats project. It will always use the
135
- base template and optionally allows you to provide the `--template foo` flag
136
- where `foo` would be an available template provided by orats.
137
-
138
- You can also supply your own custom template which is explained in the
139
- [custom template](#custom) section.
140
-
141
- Get started by checking out what the [base template](#base) provides.
142
-
143
- ### Inventory
144
-
145
- The project command automatically creates an inventory for you but it also
146
- has an optional flag to skip doing it by providing `--skip-ansible`.
147
-
148
- In case you decided to `--skip-ansible` or decided to delete your inventory
149
- from a really old project to let orats generate a new one for you then you can
150
- generate a new inventory on its own.
151
-
152
- You may also consider using this command if you happen to use ansible but are
153
- not interested in the orats project because here is what it does:
154
-
155
- #### Features
156
-
157
- - Create an `inventory` folder
158
- - Create a `hosts` files
159
- - Populate it with a few groups used by an orats project
160
- - Create a `group_vars/all.yml` file
161
- - Populate it with a bunch of configuration for an orats project
162
- - Create a `secrets` folder
163
- - Generate strong passwords for:
164
- - Your postgres user
165
- - Your redis server
166
- - Your mail account
167
- - Generate tokens for:
168
- - Rails
169
- - Devise
170
- - Devise pepper
171
- - Create a single private/public ssh keypair
172
- - This could be used to send to your servers
173
- - Create self signed ssl certificates to test/support ssl
174
- - Create a monit pem file for its optional http interface over ssl
175
-
176
- #### Try the inventory command
177
-
178
- `orats inventory myinventory`
179
-
180
- ### Playbook
181
-
182
- Building your application is only one piece of the puzzle. If you want to ship your application you have to host it somewhere. You have a few options when it comes to managed hosts like Heroku but they tend to be very expensive if you fall out of their free tier.
183
-
184
- The playbook template creates an ansible playbook that will provision a **ubuntu 12.04 LTS server**. It can be hosted anywhere as there are no hard requirements on any specific host.
185
-
186
- #### Server breakdown
187
-
188
- Everything is broken up into ansible roles so you can quickly scale out horizontally or by splitting up your server groups such that your database is on a separate server than your application.
189
-
190
- - **Security**:
191
- - Logging into the server is only possible with an ssh key
192
- - Root login is disable
193
- - fail2ban is setup and configurable
194
- - ferm (firewall) is setup to block any ports not exposed by you
195
- - All stack specific processes are running with less privileges than root
196
- - **User**:
197
- - A single deploy user is created
198
- - **Services and runtimes**:
199
- - Postgres
200
- - Redis
201
- - NodeJS
202
- - Ruby
203
- - **Process management**:
204
- - Your rails app and sidekiq have `init.d` scripts
205
- - Your rails app and sidekiq are monitored using `monit`
206
-
207
- #### Try the playbook command
208
-
209
- `orats playbook myplaybook`
210
-
211
- #### Ansible roles used
212
-
213
- - `nickjj.locale` https://github.com/nickjj/ansible-locale [![Build Status](https://secure.travis-ci.org/nickjj/ansible-locale.png)](http://travis-ci.org/nickjj/ansible-locale)
214
- - `nickjj.sshd` https://github.com/nickjj/ansible-sshd [![Build Status](https://secure.travis-ci.org/nickjj/ansible-sshd.png)](http://travis-ci.org/nickjj/ansible-sshd)
215
- - `nickjj.ferm` https://github.com/nickjj/ansible-ferm [![Build Status](https://secure.travis-ci.org/nickjj/ansible-ferm.png)](http://travis-ci.org/nickjj/ansible-ferm)
216
- - `nickjj.fail2ban` https://github.com/nickjj/ansible-fail2ban [![Build Status](https://secure.travis-ci.org/nickjj/ansible-fail2ban.png)](http://travis-ci.org/nickjj/ansible-fail2ban)
217
- - `nickjj.user` https://github.com/nickjj/ansible-user [![Build Status](https://secure.travis-ci.org/nickjj/ansible-user.png)](http://travis-ci.org/nickjj/ansible-user)
218
- - `nickjj.postgres` https://github.com/nickjj/ansible-postgres [![Build Status](https://secure.travis-ci.org/nickjj/ansible-postgres.png)](http://travis-ci.org/nickjj/ansible-postgres)
219
- - `nickjj.ruby` https://github.com/nickjj/ansible-ruby [![Build Status](https://secure.travis-ci.org/nickjj/ansible-ruby.png)](http://travis-ci.org/nickjj/ansible-ruby)
220
- - `nickjj.rails` https://github.com/nickjj/ansible-rails [![Build Status](https://secure.travis-ci.org/nickjj/ansible-rails.png)](http://travis-ci.org/nickjj/ansible-rails)
221
- - `nickjj.whenever` https://github.com/nickjj/ansible-whenever [![Build Status](https://secure.travis-ci.org/nickjj/ansible-whenever.png)](http://travis-ci.org/nickjj/ansible-whenever)
222
- - `nickjj.pumacorn` https://github.com/nickjj/ansible-pumacorn [![Build Status](https://secure.travis-ci.org/nickjj/ansible-pumacorn.png)](http://travis-ci.org/nickjj/ansible-pumacorn)
223
- - `nickjj.sidekiq` https://github.com/nickjj/ansible-sidekiq [![Build Status](https://secure.travis-ci.org/nickjj/ansible-sidekiq.png)](http://travis-ci.org/nickjj/ansible-sidekiq)
224
- - `nickjj.monit` https://github.com/nickjj/ansible-monit [![Build Status](https://secure.travis-ci.org/nickjj/ansible-monit.png)](http://travis-ci.org/nickjj/ansible-monit)
225
- - `nickjj.nodejs` https://github.com/nickjj/ansible-nodejs [![Build Status](https://secure.travis-ci.org/nickjj/ansible-nodejs.png)](http://travis-ci.org/nickjj/ansible-nodejs)
226
- - `nickjj.nginx` https://github.com/nickjj/ansible-nginx [![Build Status](https://secure.travis-ci.org/nickjj/ansible-nginx.png)](http://travis-ci.org/nickjj/ansible-nginx)
227
- - `DavidWittman.redis` https://github.com/DavidWittman/ansible-redis [![Build Status](https://secure.travis-ci.org/DavidWittman/ansible-redis.png)](http://travis-ci.org/DavidWittman/ansible-redis)
228
-
229
- #### Playbook FAQ
230
-
231
- ##### What is the Galaxyfile?
232
-
233
- It is similar to what a Gemfile is for ruby.
66
+ To get the details of each command then please run `orats help` from the terminal. Below is a high level overview of what the main commands do.
234
67
 
235
- When you generate a playbook it will create a `roles` folder inside of the
236
- target path you specified. The roles folder will contain all of the above
237
- roles.
68
+ ### New
238
69
 
239
- When you run the playbook it will use these files when it provisions
240
- your server(s).
241
-
242
- This allows you to easily update the versions of each ansible role without
243
- having to download a new version of orats.
244
-
245
- ##### How do I update the roles for an existing playbook?
246
-
247
- Just run `orats playbook myplaybook` and it will overwrite
248
- the roles in `myplaybook/roles` using the versions supplied in your
249
- `Galaxyfile`. This is useful to run when a role requires a bug fix or new features were added.
250
-
251
- Since the roles are self contained in the playbook this allows you to have
252
- multiple playbooks with certain role versions in case you have older orats
253
- projects which require older role versions.
254
-
255
- ### Role
256
-
257
- The role command generates an ansible role with a few opinions. The
258
- `ansible-galaxy` command that ships with ansible already comes with an `init`
259
- function but the formatting of the files wasn't to my liking.
260
-
261
- I also wanted it to add in tests using travis-ci and setup a basic
262
- idempotence test for all new roles.
263
-
264
- #### Changes vs ansible-galaxy init
265
-
266
- All of the changes have git commits to go with them. After generating a role you
267
- can type `git reflog` to get a list of changes.
70
+ The new command kicks off a new orats app. It will always use the base template and optionally allows you to provide the `--template foo` flag where `foo` would be an available template provided by orats.
268
71
 
269
- - **Core changes**:
270
- - Add travis-ci tests
271
- - Remove the `vars` folder
272
- - Add `LICENSE` (MIT)
273
- - Add `.gitignore`
274
- - **meta/main.yml**:
275
- - Automatically fill in the author name based on your git name
276
- - **README.md**:
277
- - Add a travis badge
278
- - Add a section to link back to your role on the official ansible galaxy
279
- - Automatically fill in your repo name, role name and name where necessary
280
- - Add instructions for using the role in an example playbook
281
- - Add a todo list for you to make the role your own
282
-
283
- #### Try the role command
284
-
285
- ##### Basic
286
-
287
- `orats role your_github_user_name.myrole`
288
-
289
- ##### Custom repo name
290
-
291
- `orats role your_github_user_name.mynewrole --repo-name ansible-mynewrole`
292
-
293
- The custom repo name is probably what you'll want to use all the time if you
294
- plan to make your roles open source. For example my roles are named things like `nickjj.postgres` and `nickjj.rails`. However my repos are named `ansible-postgres` and `ansible-rails`.
295
-
296
- When you submit your role to the galaxy you would use `rails` as the
297
- optional name for your role.
298
-
299
- ### Diff
300
-
301
- The goal of the diff command is to compare your orats generated files with
302
- the latest version to see what differences there are between the 2.
303
-
304
- You can compare nothing in which case it just gives you back your version of
305
- the orats gem vs the latest gem version or you can add paths to 1 or all of the
306
- files below.
72
+ You can also supply your own custom template which is explained in the [custom template](#custom) section.
307
73
 
308
- ##### Galaxyfile
309
-
310
- When you supply the `--galaxyfile` flag along with a path to your `Galaxyfile`
311
- it will show you a list of missing, outdated and extra roles with the versions.
312
-
313
- ##### Playbook
314
-
315
- When you supply the `--playbook` flag along with a path to your
316
- `site.yml` file it will show you a list of missing or extra roles.
317
-
318
- ##### Hosts
319
-
320
- When you supply the `--hosts` flag along with a path to your `hosts` file it
321
- will show you a list of missing or extra groups.
322
-
323
- ##### Inventory
324
-
325
- When you supply the `--inventory` flag along with a path to your
326
- `group_vars/all.yml` file it will show you a list of missing or extra variables.
327
-
328
- #### Wait, there is an easier way to compare everything
329
-
330
- If you kept the default file names for the files orats generated then you can pass in the path to your inventory directory and playbook directory and it will compare everything for you.
74
+ Get started by checking out what the [base template](#base) provides.
331
75
 
332
- #### Try the diff command
76
+ ### Nuke
333
77
 
334
- ##### Individual files
78
+ You can delete an app using the nuke command. It is much better than just using `rm -rf` because it will clean up the postgres and redis namespace as long as you don't disable that functionality with the `--skip-data` flag.
335
79
 
336
- `orats diff -g /path/to/playbook/Galaxyfile -p /path/to/playbook/site.yml -h
337
- /path/to/project/inventory/hosts -i /path/to/project/inventory/group_vars/all.yml`
80
+ #### Try the nuke command
338
81
 
339
- ##### Shortcut
82
+ You will need to have generated an app before trying this. Check out the [try the base template](#try-the-base-template) section to learn how to generate an app.
340
83
 
341
- `orats diff -i /path/to/my/project/inventory -p /path/to/playbook`
84
+ `orats nuke /tmp/someapp --pg-password foo`
342
85
 
343
86
  ### Templates
344
87
 
@@ -407,7 +150,7 @@ All of the changes have git commits to go with them. After generating a project
407
150
 
408
151
  #### Try the base template
409
152
 
410
- `orats project myapp --pg-password foo`
153
+ `orats new myapp --pg-password foo`
411
154
 
412
155
  #### Base FAQ
413
156
 
@@ -421,54 +164,6 @@ In order to do this it must know your postgres location, username and password.
421
164
 
422
165
  If your redis server is configured to use a password then you must also pass in `--redis-password foo`.
423
166
 
424
- ##### What's with the directory structure?
425
-
426
- Let's say you were to generate a new project at *~/tmp/myapp*, then you would get the following paths:
427
-
428
- ```
429
- ~/tmp/myapp/inventory
430
- ~/tmp/myapp/secrets
431
- ~/tmp/myapp/services
432
- ```
433
-
434
- The **inventory** path contains the ansible inventory files for this project. This would be where your host addresses go along with configuration settings for this project.
435
-
436
- The **secrets** path contains the passwords for various things as well as ssh keypairs and ssl certificates. This path should be kept out of version control. You could also go 1 extra step and encrypt this directory locally.
437
-
438
- The **services** path contains your rails application. I like to call it services because you might have multiple services in 1 project.
439
-
440
- If you run the command with `--skip-ansible` you will not get the inventory and services.
441
-
442
- <a name="base-what-do-i-need-to-configure-for-development"></a>
443
- ##### What do I need to configure for development?
444
-
445
- Pretty much everything is contained within environment variables. They are stored in the `.env` file located in the root directory of the rails application. It should be self explanatory. This file is also added to `.gitignore`.
446
-
447
- <a name="base-what-do-i-need-to-configure-for-production"></a>
448
- ##### What do I need to configure for production?
449
-
450
- If you are using ansible then you should open `inventory/group_vars/all.yml` and take a peek. Everything there has comments. Assuming you have everything hosted on 1 server then at minimum you will only need to change `rails_deploy_git_url` to get going.
451
-
452
- The above variable is the repo where your code is contained. Ansible will clone that repo in an idempotent way.
453
-
454
- You will also need to put the correct server IP(s) in `inventory/hosts`. At this point that's all you need to change to successfully provision a server.
455
-
456
- There are many other variables that you would likely change too such as adding your google analytics UA, S3 keys and all of the mail settings.
457
-
458
- You may also want to tinker with the following values for performance reasons based on your server(s).
459
-
460
- ```
461
- DATABASE_POOL: 25
462
-
463
- PUMA_THREADS_MIN: 0
464
- PUMA_THREADS_MAX: 16
465
-
466
- # ensure there are always at least 2 workers so puma can properly do phased restarts
467
- PUMA_WORKERS: "{{ ansible_processor_cores if ansible_processor_cores > 1 else 2 }}"
468
-
469
- SIDEKIQ_CONCURRENCY: 25
470
- ```
471
-
472
167
  ### Auth
473
168
 
474
169
  This is the auth template which gets merged into the base template. It contains a basic authentication setup using devise and pundit.
@@ -515,28 +210,11 @@ All of the changes have git commits to go with them. After generating a project
515
210
 
516
211
  #### Try the auth template
517
212
 
518
- `orats project myauthapp --template auth --pg-password foo`
519
-
520
- #### Auth FAQ
521
-
522
- ##### What do those flags do?
523
-
524
- You should read the [try the base template](#try-the-base-template) section to get an idea of what they do.
525
-
526
- <a name="auth-what-do-i-need-to-configure-for-development"></a>
527
- ##### What do I need to configure for development?
528
-
529
- You may want to change `ACTION_MAILER_DEVISE_DEFAULT_FROM` in `.env`.
530
-
531
- <a name="auth-what-do-i-need-to-configure-for-production"></a>
532
- ##### What do I need to configure for production?
533
-
534
- You will want to change `ACTION_MAILER_DEVISE_DEFAULT_FROM` in `inventory/group_vars/all.yml`.
213
+ `orats new myauthapp --template auth --pg-password foo`
535
214
 
536
215
  ### Custom
537
216
 
538
- You can pass custom templates into both the `project` and `playbook` commands
539
- . It works exactly like passing a custom application template to `rails new`.
217
+ You can pass custom templates into the `new` command. It works exactly like passing a custom application template to `rails new`.
540
218
 
541
219
  Pass in a custom template by providing the `--custom` flag along with either a local path or a URL.
542
220
 
@@ -553,7 +231,7 @@ S
553
231
 
554
232
  #### Try the custom template
555
233
 
556
- `orats project /tmp/customexample -p foo --custom /tmp/foo.rb`
234
+ `orats new /tmp/customexample -p foo --custom /tmp/foo.rb`
557
235
 
558
236
  #### Custom FAQ
559
237
 
@@ -563,5 +241,32 @@ S
563
241
  There's the official [rails guide on custom application templates]
564
242
  (http://guides.rubyonrails.org/rails_application_templates.html).
565
243
 
566
- You can also view the [orats project templates](https://github.com/nickjj/orats/tree/master/lib/orats/templates) to use as inspiration. All of
567
- the template files are self contained.
244
+ You can also view the [orats templates](https://github.com/nickjj/orats/tree/master/lib/orats/templates) to use as inspiration. All of the template files are self contained.
245
+
246
+ ## The .oratsrc file
247
+
248
+ Both the `new` and `nuke` commands are dependent on having your postgres and redis login information because they need to connection to those databases to perform various tasks.
249
+
250
+ There are 5 flags to configure for this:
251
+
252
+ - `--pg-location` (defaults to localhost)
253
+ - `--pg-username` (defaults to postgres)
254
+ - `--pg-password` (defaults to an empty string)
255
+ - `--redis-location` (defaults to localhost)
256
+ - `--redis-password` (defaults to an empty string)
257
+
258
+ For most people you will only need to supply the postgres password but still it's annoying to have to type those flags in every time you create a new app or nuke an app. It's really annoying if you develop inside of linux containers like myself which means the location is not localhost.
259
+
260
+ This is where the `.oratsrc` file comes into play. By default it will look for one in your home directory but you can pass in a location directly with the `--rc` flag.
261
+
262
+ This file can contain the above flags. You might have one created at `~/.oratsrc`
263
+ and it could look like this:
264
+
265
+ ```
266
+ --pg-location 192.168.144.101
267
+ --pg-username nick
268
+ --pg-password pleasedonthackme
269
+ --redis-location 192.168.144.101
270
+ ```
271
+
272
+ You can supply as many or little flags as you want.
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require 'bundler/gem_tasks'
1
+ require 'bundler/gem_tasks'
data/bin/orats CHANGED
@@ -10,8 +10,11 @@
10
10
  git_path = File.expand_path('../../.git', __FILE__)
11
11
 
12
12
  if File.exist?(git_path)
13
- $:.unshift(File.expand_path('../../lib', __FILE__))
13
+ $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
14
14
  end
15
15
 
16
16
  require 'orats/cli'
17
- Orats::CLI.start(ARGV)
17
+ require 'orats/argv_adjust'
18
+
19
+ argv = Orats::ARGVAdjust.new.init
20
+ Orats::CLI.start(argv)
@@ -0,0 +1,61 @@
1
+ require 'orats/ui'
2
+
3
+ module Orats
4
+ # adjust ARGV by adding args from the .oratsrc file if necessary
5
+ class ARGVAdjust
6
+ include Orats::UI
7
+
8
+ def initialize(argv = ARGV)
9
+ @argv = argv
10
+
11
+ @default_rc_file = File.expand_path('~/.oratsrc')
12
+ @rc_path = ''
13
+ end
14
+
15
+ def init
16
+ rc_path @argv.first
17
+ return @argv if @rc_path.empty?
18
+
19
+ argv
20
+ end
21
+
22
+ private
23
+
24
+ def rc_path(command)
25
+ return unless command == 'new' || command == 'nuke'
26
+
27
+ rc_flag = @argv.index { |item| item.include?('--rc') }
28
+
29
+ if rc_flag
30
+ cli_rc_file(rc_flag)
31
+ elsif File.exist?(@default_rc_file)
32
+ @rc_path = @default_rc_file
33
+ end
34
+ end
35
+
36
+ def argv
37
+ if File.exist?(@rc_path)
38
+ extra_args = File.readlines(@rc_path).flat_map(&:split)
39
+ results 'Using values from an .oratsrc file',
40
+ 'args', extra_args.join(' ')
41
+ puts
42
+
43
+ (@argv += extra_args).flatten
44
+ else
45
+ error 'The .oratsrc file cannot be found', @rc_path
46
+ end
47
+ end
48
+
49
+ def cli_rc_file(index)
50
+ rc_value = @argv[index]
51
+
52
+ if rc_value.include?('=')
53
+ @rc_path = rc_value.gsub('--rc=', '')
54
+ @argv.slice! index
55
+ elsif rc_value == '--rc'
56
+ @rc_path = @argv[index + 1]
57
+ @argv.slice! index + 1
58
+ end
59
+ end
60
+ end
61
+ end