orats 0.6.5 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +231 -58
- data/lib/orats/cli.rb +63 -25
- data/lib/orats/commands/common.rb +47 -22
- data/lib/orats/commands/{outdated → diff}/compare.rb +5 -4
- data/lib/orats/commands/diff/exec.rb +86 -0
- data/lib/orats/commands/{outdated → diff}/parse.rb +5 -1
- data/lib/orats/commands/inventory.rb +121 -0
- data/lib/orats/commands/{play.rb → playbook.rb} +5 -5
- data/lib/orats/commands/project/exec.rb +74 -0
- data/lib/orats/commands/{new → project}/rails.rb +57 -81
- data/lib/orats/commands/{new → project}/server.rb +6 -4
- data/lib/orats/templates/auth.rb +26 -481
- data/lib/orats/templates/base.rb +74 -716
- data/lib/orats/templates/includes/common/LICENSE +22 -0
- data/lib/orats/templates/includes/new/rails/.env +43 -0
- data/lib/orats/templates/includes/{Gemfile → new/rails/Gemfile} +1 -1
- data/lib/orats/templates/includes/new/rails/Procfile +3 -0
- data/lib/orats/templates/includes/new/rails/README.md +3 -0
- data/lib/orats/templates/includes/{app → new/rails/app}/assets/favicon/favicon_base.png +0 -0
- data/lib/orats/templates/includes/new/rails/app/helpers/application_helper.rb +53 -0
- data/lib/orats/templates/includes/new/rails/app/models/account.rb +40 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/confirmations/new.html.erb +26 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/reset_password_instructions.html.erb +10 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/unlock_instructions.html.erb +8 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/passwords/edit.html.erb +28 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/passwords/new.html.erb +26 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/registrations/edit.html.erb +51 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/registrations/new.html.erb +31 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/sessions/new.html.erb +39 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/shared/_links.html.erb +38 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/unlocks/new.html.erb +26 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_disqus_comments_snippet.html.erb +19 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_disqus_count_snippet.html.erb +12 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_flash.html.erb +10 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_footer.html.erb +2 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_google_analytics_snippet.html.erb +13 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_google_analytics_tracker.html.erb +4 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_navigation.html.erb +18 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_navigation_auth.html.erb +15 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_navigation_links.html.erb +3 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/application.html.erb +48 -0
- data/lib/orats/templates/includes/new/rails/app/views/pages/home.html.erb +81 -0
- data/lib/orats/templates/includes/new/rails/config/database.yml +19 -0
- data/lib/orats/templates/includes/new/rails/config/environments/staging.rb +5 -0
- data/lib/orats/templates/includes/new/rails/config/initializers/devise_async.rb +1 -0
- data/lib/orats/templates/includes/new/rails/config/initializers/mini_profiler.rb +4 -0
- data/lib/orats/templates/includes/new/rails/config/initializers/sidekiq.rb +16 -0
- data/lib/orats/templates/includes/new/rails/config/puma.rb +25 -0
- data/lib/orats/templates/includes/new/rails/config/secrets.yml +12 -0
- data/lib/orats/templates/includes/new/rails/config/sidekiq.yml +5 -0
- data/lib/orats/templates/includes/new/rails/config/sitemap.rb +20 -0
- data/lib/orats/templates/includes/new/rails/config/whenever.rb +7 -0
- data/lib/orats/templates/includes/new/rails/lib/backup/config.rb +116 -0
- data/lib/orats/templates/includes/new/rails/lib/backup/models/backup.rb +55 -0
- data/lib/orats/templates/includes/new/rails/lib/tasks/orats/backup.rake +18 -0
- data/lib/orats/templates/includes/new/rails/lib/tasks/orats/favicon.rake +48 -0
- data/lib/orats/templates/includes/new/rails/public/404.html +13 -0
- data/lib/orats/templates/includes/new/rails/public/422.html +13 -0
- data/lib/orats/templates/includes/new/rails/public/500.html +13 -0
- data/lib/orats/templates/includes/new/rails/public/502.html +13 -0
- data/lib/orats/templates/includes/new/rails/test/fixtures/accounts.yml +27 -0
- data/lib/orats/templates/includes/new/rails/test/models/account_test.rb +46 -0
- data/lib/orats/templates/includes/{Galaxyfile → playbook/Galaxyfile} +0 -0
- data/lib/orats/templates/includes/playbook/site.yml +53 -0
- data/lib/orats/templates/playbook.rb +115 -0
- data/lib/orats/version.rb +1 -1
- data/test/integration/cli_test.rb +122 -75
- data/test/test_helper.rb +16 -8
- metadata +63 -14
- data/lib/orats/commands/new/ansible.rb +0 -98
- data/lib/orats/commands/new/exec.rb +0 -60
- data/lib/orats/commands/outdated/exec.rb +0 -46
- data/lib/orats/templates/play.rb +0 -185
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4074c37de6ccbdfd2b84f5ef94d306e0ae09a38c
|
4
|
+
data.tar.gz: 84e6cf532395d751261e71b6145b2808b3643e85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9210ea048f5c610c5c5b291715f3b6204eeea37e25f066d6334282ce7a9170d521272a6bb8ba0f361f9b60f22e8cd54da13fb02d1b0c90c2397258ce399e2506
|
7
|
+
data.tar.gz: 85c99459d792ddf47ca77046c28c45bf95cbfce3459afc205017622b4793c3f409c514159c124b1f33105d053b6f9d6206e6fe3d3495f7c9a020778f4964cc3d
|
data/README.md
CHANGED
@@ -1,5 +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
|
+
|
3
6
|
## What is orats and what problem does it solve?
|
4
7
|
|
5
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 and provision your servers and deploy your apps effortlessly.
|
@@ -14,7 +17,19 @@ Gems will also be updated once they are proven to work on the target rails/ruby
|
|
14
17
|
- [System dependencies](#system-dependencies)
|
15
18
|
- [Installation](#installation)
|
16
19
|
- [Commands](#commands)
|
17
|
-
- [
|
20
|
+
- [Project](#project)
|
21
|
+
- [Inventory](#inventory)
|
22
|
+
- [Try it](#try-the-inventory-command)
|
23
|
+
- [FAQ](#inventory-faq)
|
24
|
+
- [What's with the sudo password](#whats-with-the-sudo-password)
|
25
|
+
- [Playbook](#playbook)
|
26
|
+
- [Try it](#try-the-playbook-command)
|
27
|
+
- [Ansible roles](#ansible-roles-used)
|
28
|
+
- [Diff](#diff)
|
29
|
+
- [Try it](#try-the-diff-command)
|
30
|
+
- [Templates](#templates)
|
31
|
+
- [Try it](#try-the-templates-command)
|
32
|
+
- [Available templates](#available-templates)
|
18
33
|
- [Base](#base)
|
19
34
|
- [Try it](#try-the-base-template)
|
20
35
|
- [FAQ](#base-faq)
|
@@ -26,9 +41,10 @@ Gems will also be updated once they are proven to work on the target rails/ruby
|
|
26
41
|
- [FAQ](#auth-faq)
|
27
42
|
- [Development configuration?](#auth-what-do-i-need-to-configure-for-development)
|
28
43
|
- [Production configuration?](#auth-what-do-i-need-to-configure-for-production)
|
29
|
-
- [
|
30
|
-
- [Try it](#try-the-
|
31
|
-
- [
|
44
|
+
- [Custom](#custom)
|
45
|
+
- [Try it](#try-the-custom-template)
|
46
|
+
- [FAQ](#custom-faq)
|
47
|
+
- [Any guides on how to make custom templates?](#any-guides-on-how-to-make-custom-templates)
|
32
48
|
- [Wiki](https://github.com/nickjj/orats/wiki)
|
33
49
|
- [What to look at after making a new project](https://github.com/nickjj/orats/wiki/What-to-look-at-after-making-a-new-project)
|
34
50
|
- [Get your application on a server](https://github.com/nickjj/orats/wiki/Get-your-application-on-a-server)
|
@@ -68,37 +84,207 @@ Or if you already have orats then run `gem update orats` to upgrade to the lates
|
|
68
84
|
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.
|
69
85
|
|
70
86
|
- **Create a new orats project**:
|
71
|
-
- `orats
|
87
|
+
- `orats project <TARGET_PATH> --pg-password foo`
|
72
88
|
- Configuration:
|
73
89
|
- Optionally takes: `--pg-location [localhost]`
|
74
90
|
- Optionally takes: `--pg-username [postgres]`
|
75
91
|
- Optionally takes: `--redis-location [localhost]`
|
76
92
|
- Optionally takes: `--redis-password []`
|
77
93
|
- Template:
|
78
|
-
- Optionally takes: `--auth [false]`
|
79
94
|
- Optionally takes: `--template []`
|
95
|
+
- Optionally takes: `--custom []`
|
80
96
|
- Project:
|
81
|
-
- Optionally takes: `--skip-
|
97
|
+
- Optionally takes: `--skip-ansible [false]`
|
82
98
|
- Optionally takes: `--skip-server-start [false]`
|
83
99
|
- Ansible:
|
84
100
|
- Optionally takes: `--sudo-password []`
|
85
101
|
- Optionally takes: `--skip-galaxy [false]`
|
86
102
|
|
103
|
+
- **Create an ansible inventory**:
|
104
|
+
- `orats inventory <TARGET_PATH>`
|
105
|
+
- Configuration:
|
106
|
+
- Optionally takes: `--sudo-password []`
|
107
|
+
- Optionally takes: `--skip-galaxy [false]`
|
108
|
+
|
87
109
|
- **Create an ansible playbook**:
|
88
|
-
- `orats
|
110
|
+
- `orats playbook <TARGET_PATH>`
|
89
111
|
- Template:
|
90
|
-
- Optionally takes: `--
|
112
|
+
- Optionally takes: `--custom []`
|
91
113
|
|
92
114
|
- **Delete a directory and optionally all data associated to it**:
|
93
115
|
- `orats nuke <TARGET_PATH>`
|
94
116
|
- Optionally takes: `--skip-data [false]`
|
95
117
|
|
96
|
-
- **
|
97
|
-
- `orats
|
98
|
-
- Optionally takes: `--
|
118
|
+
- **Compare differences between orats versions**:
|
119
|
+
- `orats diff [options]`
|
120
|
+
- Optionally takes: `--hosts []`
|
99
121
|
- Optionally takes: `--inventory []`
|
122
|
+
- Optionally takes: `--playbook []`
|
123
|
+
|
124
|
+
- **Get a list of available orats templates**:
|
125
|
+
- `orats templates`
|
126
|
+
|
127
|
+
### Project
|
128
|
+
|
129
|
+
The project command kicks off a new orats project. It will always use the
|
130
|
+
base template and optionally allows you to provide the `--template foo` flag
|
131
|
+
where `foo` would be an available template provided by orats.
|
132
|
+
|
133
|
+
You can also supply your own custom template which is explained in the
|
134
|
+
[custom template](#custom) section.
|
135
|
+
|
136
|
+
Get started by checking out what the [base template](#base) provides.
|
137
|
+
|
138
|
+
### Inventory
|
139
|
+
|
140
|
+
The project command automatically creates an inventory for you but it also
|
141
|
+
has an optional flag to skip doing it by providing `--skip-ansible`.
|
142
|
+
|
143
|
+
In case you decided to `--skip-ansible` or decided to delete your inventory
|
144
|
+
from a really old project to let orats generate a new one for you then you can
|
145
|
+
generate a new inventory on its own.
|
146
|
+
|
147
|
+
You may also consider using this command if you happen to use ansible but are
|
148
|
+
not interested in the orats project because here is what it does:
|
149
|
+
|
150
|
+
#### Features
|
151
|
+
|
152
|
+
- Create an `inventory` folder
|
153
|
+
- Create a `hosts` files
|
154
|
+
- Populate it with a few groups used by an orats project
|
155
|
+
- Create a `group_vars/all.yml` file
|
156
|
+
- Populate it with a bunch of configuration for an orats project
|
157
|
+
- Create a `secrets` folder
|
158
|
+
- Generate strong passwords for:
|
159
|
+
- Your postgres user
|
160
|
+
- Your redis server
|
161
|
+
- Your mail account
|
162
|
+
- Generate tokens for:
|
163
|
+
- Rails
|
164
|
+
- Devise
|
165
|
+
- Devise pepper
|
166
|
+
- Create a single private/public ssh keypair
|
167
|
+
- This could be used to send to your servers
|
168
|
+
- Create self signed ssl certificates to test/support ssl
|
169
|
+
- Create a monit pem file for its optional http interface over ssl
|
170
|
+
- Galaxy install the roles required by an orats project
|
171
|
+
- Optionally turned off with `--skip-galaxy`
|
172
|
+
|
173
|
+
#### Try the inventory command
|
174
|
+
|
175
|
+
`orats inventory myinventory`
|
176
|
+
|
177
|
+
#### Inventory FAQ
|
178
|
+
|
179
|
+
##### What's with the sudo password flag?
|
180
|
+
|
181
|
+
Ansible can be installed in a number of ways. A common way is to build a package or use a package manager. When you install ansible this way it
|
182
|
+
gets installed to `/etc/ansible`.
|
183
|
+
|
184
|
+
By default ansible will download roles from the galaxy to
|
185
|
+
`/etc/ansible/roles` which will require sudo to write to.
|
186
|
+
|
187
|
+
If you installed ansible to your home directory then orats is smart enough
|
188
|
+
not to use sudo. It will only try to use sudo when it detects a permission
|
189
|
+
error.
|
190
|
+
|
191
|
+
You can also choose not to provide the `--sudo-password` flag but then you
|
192
|
+
will be prompted for a sudo password about 90% of the way through the
|
193
|
+
duration of the inventory command.
|
194
|
+
|
195
|
+
### Playbook
|
196
|
+
|
197
|
+
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.
|
198
|
+
|
199
|
+
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.
|
200
|
+
|
201
|
+
#### Server breakdown
|
202
|
+
|
203
|
+
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.
|
204
|
+
|
205
|
+
- **Security**:
|
206
|
+
- Logging into the server is only possible with an ssh key
|
207
|
+
- Root login is disable
|
208
|
+
- fail2ban is setup
|
209
|
+
- ufw (firewall) is setup to block any ports not exposed by you
|
210
|
+
- All stack specific processes are running with less privileges than root
|
211
|
+
- **User**:
|
212
|
+
- A single deploy user is created
|
213
|
+
- **Services and runtimes**:
|
214
|
+
- Postgres
|
215
|
+
- Redis
|
216
|
+
- NodeJS
|
217
|
+
- Ruby
|
218
|
+
- **Process management**:
|
219
|
+
- Your rails app and sidekiq have `init.d` scripts
|
220
|
+
- Your rails app and sidekiq are monitored using `monit`
|
221
|
+
|
222
|
+
#### Try the playbook command
|
223
|
+
|
224
|
+
`orats playbook myplaybook`
|
225
|
+
|
226
|
+
#### Ansible roles used
|
227
|
+
|
228
|
+
- `nickjj.user` https://github.com/nickjj/ansible-user
|
229
|
+
- `nickjj.security` https://github.com/nickjj/ansible-security
|
230
|
+
- `nickjj.postgres` https://github.com/nickjj/ansible-postgres
|
231
|
+
- `nickjj.ruby` https://github.com/nickjj/ansible-ruby
|
232
|
+
- `nickjj.rails` https://github.com/nickjj/ansible-rails
|
233
|
+
- `nickjj.whenever` https://github.com/nickjj/ansible-whenever
|
234
|
+
- `nickjj.pumacorn` https://github.com/nickjj/ansible-pumacorn
|
235
|
+
- `nickjj.sidekiq` https://github.com/nickjj/ansible-sidekiq
|
236
|
+
- `nickjj.monit` https://github.com/nickjj/ansible-monit
|
237
|
+
- `nickjj.nodejs` https://github.com/nickjj/ansible-nodejs
|
238
|
+
- `nickjj.nginx` https://github.com/nickjj/ansible-nginx
|
239
|
+
- `DavidWittman.redis` https://github.com/DavidWittman/ansible-redis
|
240
|
+
|
241
|
+
All of the above roles will get installed and updated whenever you generate a new orats project.
|
242
|
+
|
243
|
+
### Diff
|
244
|
+
|
245
|
+
The goal of the diff command is to provide you a way to compare your current
|
246
|
+
orats gem to the latest orats gem. It can also compare the difference between
|
247
|
+
the orats generated version of an inventory/playbook to an
|
248
|
+
inventory/playbook that you generated and have customized.
|
249
|
+
|
250
|
+
This comes in handy when you want to upgrade orats and your project.
|
251
|
+
You will be able to see if your inventory/playbook are missing any variables
|
252
|
+
or roles and it will also detect custom variables/roles that you have added.
|
253
|
+
|
254
|
+
It allows you to make 2 different types of comparisons:
|
255
|
+
|
256
|
+
#### Latest stable version of orats vs your version
|
257
|
+
|
258
|
+
When doing this type of comparison it only compares the actual files contained in the orats source code, not your generated inventory/playbook.
|
259
|
+
|
260
|
+
This is the type of comparison that is made when you run the `diff` command
|
261
|
+
without any arguments. It is useful to run this from time to time to
|
262
|
+
see if you are missing out on any new features in the latest version.
|
100
263
|
|
101
|
-
|
264
|
+
#### Your orats version vs your custom project files
|
265
|
+
|
266
|
+
If you pass in the `--hosts`, `--inventory` and/or `--playbook` flags along
|
267
|
+
with a path to each of their files then it will compare the files contained
|
268
|
+
in the orats source code to your custom generated inventory/playbook.
|
269
|
+
|
270
|
+
If you stick with the orats naming convention and directory structure there
|
271
|
+
are a few quality of life enhancements. If you supply the path to the
|
272
|
+
inventory folder it will do a comparison on both the inventory and hosts file for you. If you supply the path to a
|
273
|
+
playbook folder it will automatically choose the `site.yml` playbook.
|
274
|
+
|
275
|
+
#### Try the diff command
|
276
|
+
|
277
|
+
`orats diff`
|
278
|
+
|
279
|
+
### Templates
|
280
|
+
|
281
|
+
Return a list of available templates to choose from.
|
282
|
+
|
283
|
+
#### Try the templates command
|
284
|
+
|
285
|
+
`orats templates`
|
286
|
+
|
287
|
+
## Available templates
|
102
288
|
|
103
289
|
### Base
|
104
290
|
|
@@ -129,9 +315,11 @@ All of the changes have git commits to go with them. After generating a project
|
|
129
315
|
- Use the `dotenv` gem to manage environment variables
|
130
316
|
- Use `foreman` to manage the app's processes
|
131
317
|
- Use `bullet`, `rack mini profiler` and `meta_request` for profiling/analysis
|
318
|
+
- Set `scss`/`coffee` as the default generator engines
|
132
319
|
- **Production mode only**:
|
133
320
|
- Setup log rotation
|
134
321
|
- Add popular file types to the assets precompile list
|
322
|
+
- Compress `css`/`js` when running `rake assets:precompile`
|
135
323
|
- Change validation errors to output inline on each element instead of a big list
|
136
324
|
- **Helpers**:
|
137
325
|
- `title`, `meta_description`, `heading` to easily set those values per view
|
@@ -155,7 +343,7 @@ All of the changes have git commits to go with them. After generating a project
|
|
155
343
|
|
156
344
|
#### Try the base template
|
157
345
|
|
158
|
-
`orats
|
346
|
+
`orats project myapp --pg-password foo --skip-galaxy`
|
159
347
|
|
160
348
|
#### Base FAQ
|
161
349
|
|
@@ -163,21 +351,21 @@ All of the changes have git commits to go with them. After generating a project
|
|
163
351
|
|
164
352
|
Orats will automatically start your server (you can turn this off with a flag) and also run database migrations or generators depending on what you're doing.
|
165
353
|
|
166
|
-
In order to do this it must know your postgres location, username and password. By default it will use localhost for the *location* and *postgres* as the username but if you need to supply those values because yours are different you can use `--pg-location
|
354
|
+
In order to do this it must know your postgres location, username and password. By default it will use localhost for the *location* and *postgres* as the username but if you need to supply those values because yours are different you can use `--pg-location foo` and `--pg-username bar`.
|
167
355
|
|
168
356
|
##### What is `--skip-galaxy`?
|
169
357
|
|
170
|
-
By default the
|
358
|
+
By default the project command will generate ansible related files for you so that you can manage this app's "inventory". It also automatically downloads the ansible roles from the [ansible galaxy](https://galaxy.ansible.com/).
|
171
359
|
|
172
360
|
This was done to ensure each app you create has the correct ansible role version to go with it. However, if you installed ansible through apt or somewhere outside of your home directory then you will get permissions errors when it tries to download the roles.
|
173
361
|
|
174
|
-
You can fix this by supplying `--sudo-password
|
362
|
+
You can fix this by supplying `--sudo-password foo` to the above command if you know ansible is installed outside of your home directory or you can just wait while the command runs and it will prompt you for your sudo password when it gets to that point because orats will attempt to use sudo only after it fails trying to install the roles without sudo.
|
175
363
|
|
176
|
-
If you don't care about the ansible at all you could add `--skip-
|
364
|
+
If you don't care about the ansible at all you could add `--skip-ansible` to not generate any ansible files.
|
177
365
|
|
178
366
|
##### Does your redis server use a password?
|
179
367
|
|
180
|
-
If your redis server is configured to use a password then you must also pass in `--redis-password
|
368
|
+
If your redis server is configured to use a password then you must also pass in `--redis-password foo`.
|
181
369
|
|
182
370
|
##### What's with the directory structure?
|
183
371
|
|
@@ -195,7 +383,7 @@ The **secrets** path contains the passwords for various things as well as ssh ke
|
|
195
383
|
|
196
384
|
The **services** path contains your rails application. I like to call it services because you might have multiple services in 1 project.
|
197
385
|
|
198
|
-
If you run the command with `--skip-
|
386
|
+
If you run the command with `--skip-ansible` you will not get the inventory and services.
|
199
387
|
|
200
388
|
<a name="base-what-do-i-need-to-configure-for-development"></a>
|
201
389
|
##### What do I need to configure for development?
|
@@ -273,7 +461,7 @@ All of the changes have git commits to go with them. After generating a project
|
|
273
461
|
|
274
462
|
#### Try the auth template
|
275
463
|
|
276
|
-
`orats
|
464
|
+
`orats project myauthapp --auth --pg-password foo --skip-galaxy`
|
277
465
|
|
278
466
|
#### Auth FAQ
|
279
467
|
|
@@ -291,50 +479,35 @@ You may want to change `ACTION_MAILER_DEVISE_DEFAULT_FROM` in `.env`.
|
|
291
479
|
|
292
480
|
You will want to change `ACTION_MAILER_DEVISE_DEFAULT_FROM` in `inventory/group_vars/all.yml`.
|
293
481
|
|
294
|
-
###
|
482
|
+
### Custom
|
295
483
|
|
296
|
-
|
484
|
+
You can pass custom templates into both the `project` and `playbook` commands
|
485
|
+
. It works exactly like passing a custom application template to `rails new`.
|
297
486
|
|
298
|
-
|
487
|
+
Pass in a custom template by providing the `--custom` flag along with either a local path or a URL.
|
299
488
|
|
300
|
-
|
489
|
+
Here is a simple example of a custom template:
|
301
490
|
|
302
|
-
|
491
|
+
```
|
492
|
+
# /tmp/foo.rb
|
303
493
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
- All stack specific processes are running with less privileges than root
|
310
|
-
- **User**:
|
311
|
-
- A single deploy user is created
|
312
|
-
- **Services and runtimes**:
|
313
|
-
- Postgres
|
314
|
-
- Redis
|
315
|
-
- NodeJS
|
316
|
-
- Ruby
|
317
|
-
- **Process management**:
|
318
|
-
- Your rails app and sidekiq have `init.d` scripts
|
319
|
-
- Your rails app and sidekiq are monitored using `monit`
|
494
|
+
file 'app/components/foo.rb', <<-S
|
495
|
+
class Foo
|
496
|
+
end
|
497
|
+
S
|
498
|
+
```
|
320
499
|
|
321
|
-
#### Try the
|
500
|
+
#### Try the custom template
|
322
501
|
|
323
|
-
`orats
|
502
|
+
`orats project /tmp/customexample -p foo --custom /tmp/foo.rb`
|
324
503
|
|
325
|
-
####
|
504
|
+
#### Custom FAQ
|
326
505
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
- `nickjj.whenever` https://github.com/nickjj/ansible-whenever
|
333
|
-
- `nickjj.pumacorn` https://github.com/nickjj/ansible-pumacorn
|
334
|
-
- `nickjj.sidekiq` https://github.com/nickjj/ansible-sidekiq
|
335
|
-
- `nickjj.monit` https://github.com/nickjj/ansible-monit
|
336
|
-
- `nickjj.nodejs` https://github.com/nickjj/ansible-nodejs
|
337
|
-
- `nickjj.nginx` https://github.com/nickjj/ansible-nginx
|
338
|
-
- `DavidWittman.redis` https://github.com/DavidWittman/ansible-redis
|
506
|
+
<a name="any-guides-on-how-to-make-custom-templates"></a>
|
507
|
+
##### Any guides on how to make custom templates?
|
508
|
+
|
509
|
+
There's the official [rails guide on custom application templates]
|
510
|
+
(http://guides.rubyonrails.org/rails_application_templates.html).
|
339
511
|
|
340
|
-
|
512
|
+
You can also view the [orats project templates](https://github.com/nickjj/orats/tree/master/lib/orats/templates) to use as inspiration. All of
|
513
|
+
the template files are self contained.
|
data/lib/orats/cli.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'thor'
|
2
|
-
require 'orats/commands/
|
3
|
-
require 'orats/commands/
|
4
|
-
require 'orats/commands/
|
2
|
+
require 'orats/commands/project/exec'
|
3
|
+
require 'orats/commands/inventory'
|
4
|
+
require 'orats/commands/playbook'
|
5
5
|
require 'orats/commands/nuke'
|
6
|
+
require 'orats/commands/diff/exec'
|
6
7
|
|
7
8
|
module Orats
|
8
9
|
class CLI < Thor
|
@@ -11,15 +12,15 @@ module Orats
|
|
11
12
|
option :pg_password, required: true, aliases: '-p'
|
12
13
|
option :redis_location, default: 'localhost', aliases: '-n'
|
13
14
|
option :redis_password, default: '', aliases: '-d'
|
14
|
-
option :auth, type: :boolean, default: false, aliases: '-a'
|
15
15
|
option :template, default: '', aliases: '-m'
|
16
|
-
option :
|
16
|
+
option :custom, default: '', aliases: '-c'
|
17
|
+
option :skip_ansible, type: :boolean, default: false, aliases: '-A'
|
17
18
|
option :skip_server_start, type: :boolean, default: false, aliases: '-F'
|
18
19
|
option :sudo_password, default: '', aliases: '-s'
|
19
20
|
option :skip_galaxy, type: :boolean, default: false, aliases: '-G'
|
20
|
-
desc '
|
21
|
+
desc 'project TARGET_PATH [options]', ''
|
21
22
|
long_desc <<-D
|
22
|
-
`orats
|
23
|
+
`orats project target_path --pg-password supersecret` will create a new rails project and it will also create an ansible inventory to go with it by default.
|
23
24
|
|
24
25
|
You must supply at least this flag:
|
25
26
|
|
@@ -37,13 +38,13 @@ module Orats
|
|
37
38
|
|
38
39
|
Template features:
|
39
40
|
|
40
|
-
`--
|
41
|
+
`--template` accepts a template name which will get added in addition to the base template []
|
41
42
|
|
42
|
-
`--
|
43
|
+
`--custom` will let you supply a custom template, a url or file is ok but urls must start with http or https []
|
43
44
|
|
44
45
|
Project features:
|
45
46
|
|
46
|
-
`--skip-
|
47
|
+
`--skip-ansible` skip creating the ansible related directories [false]
|
47
48
|
|
48
49
|
`--skip-server-start` skip automatically running puma and sidekiq [false]
|
49
50
|
|
@@ -54,22 +55,39 @@ module Orats
|
|
54
55
|
`--skip-galaxy` skip automatically installing roles from the galaxy [false]
|
55
56
|
D
|
56
57
|
|
57
|
-
def
|
58
|
-
Commands::
|
58
|
+
def project(target_path)
|
59
|
+
Commands::Project::Exec.new(target_path, options).init
|
59
60
|
end
|
60
61
|
|
61
|
-
option :
|
62
|
-
|
62
|
+
option :sudo_password, default: '', aliases: '-s'
|
63
|
+
option :skip_galaxy, type: :boolean, default: false, aliases: '-G'
|
64
|
+
desc 'inventory TARGET_PATH [options]', ''
|
63
65
|
long_desc <<-D
|
64
|
-
`orats
|
66
|
+
`orats inventory target_path` will create an ansible inventory.
|
67
|
+
|
68
|
+
Configuration:
|
69
|
+
|
70
|
+
`--sudo-password` to install ansible roles from the galaxy to a path outside of your user privileges []
|
71
|
+
|
72
|
+
`--skip-galaxy` skip automatically installing roles from the galaxy [false]
|
73
|
+
D
|
74
|
+
|
75
|
+
def inventory(target_path)
|
76
|
+
Commands::Inventory.new(target_path, options).init
|
77
|
+
end
|
78
|
+
|
79
|
+
option :custom, default: '', aliases: '-c'
|
80
|
+
desc 'playbook TARGET_PATH [options]', ''
|
81
|
+
long_desc <<-D
|
82
|
+
`orats playbook target_path` will create an ansible playbook.
|
65
83
|
|
66
84
|
Template features:
|
67
85
|
|
68
|
-
`--
|
86
|
+
`--custom` will let you supply a custom template, a url or file is ok but urls must start with http or https []
|
69
87
|
D
|
70
88
|
|
71
|
-
def
|
72
|
-
Commands::
|
89
|
+
def playbook(target_path)
|
90
|
+
Commands::Playbook.new(target_path, options).init
|
73
91
|
end
|
74
92
|
|
75
93
|
option :skip_data, type: :boolean, default: false, aliases: '-D'
|
@@ -89,11 +107,12 @@ module Orats
|
|
89
107
|
Commands::Nuke.new(target_path, options).init
|
90
108
|
end
|
91
109
|
|
92
|
-
option :
|
110
|
+
option :hosts, default: '', aliases: '-h'
|
93
111
|
option :inventory, default: '', aliases: '-i'
|
94
|
-
|
112
|
+
option :playbook, default: '', aliases: '-b'
|
113
|
+
desc 'diff [options]', ''
|
95
114
|
long_desc <<-D
|
96
|
-
`orats
|
115
|
+
`orats diff` will run various comparisons on orats and your ansible files.
|
97
116
|
|
98
117
|
Help:
|
99
118
|
|
@@ -103,13 +122,32 @@ module Orats
|
|
103
122
|
|
104
123
|
Options:
|
105
124
|
|
106
|
-
`--
|
125
|
+
`--hosts` to supply a hosts file for comparison []
|
126
|
+
|
127
|
+
`--inventory` to supply an inventory directory/file for comparison []
|
128
|
+
|
129
|
+
`--playbook` to supply a playbook directory/file for comparison []
|
130
|
+
|
131
|
+
Quality of life features:
|
132
|
+
|
133
|
+
`--inventory` also accepts a path to your project's inventory folder,
|
134
|
+
if you kept the default file names it will automatically compare both your
|
135
|
+
hosts and group_vars/all.yml files.
|
107
136
|
|
108
|
-
`--
|
137
|
+
`--playbook` also accepts a path to a playbook folder, if you kept the playbook name as `site.yml` it will automatically choose it.
|
138
|
+
D
|
139
|
+
|
140
|
+
def diff
|
141
|
+
Commands::Diff::Exec.new(nil, options).init
|
142
|
+
end
|
143
|
+
|
144
|
+
desc 'templates', ''
|
145
|
+
long_desc <<-D
|
146
|
+
`orats templates` will return a list of available orats templates.
|
109
147
|
D
|
110
148
|
|
111
|
-
def
|
112
|
-
Commands::
|
149
|
+
def templates
|
150
|
+
Commands::Project::Exec.new.list_templates
|
113
151
|
end
|
114
152
|
|
115
153
|
desc 'version', ''
|