rails-ahoy 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ahoy.gemspec +1 -0
- data/lib/ahoy.rb +4 -1
- data/lib/ahoy/version.rb +1 -1
- data/lib/generators/ahoy/base.rb +8 -3
- data/lib/generators/ahoy/deployment_generator.rb +122 -0
- data/lib/generators/ahoy/init_generator.rb +10 -15
- data/lib/generators/ahoy/lib/question_helper.rb +50 -0
- data/lib/generators/ahoy/lib/variable_store.rb +19 -0
- data/lib/generators/ahoy/templates/_Vagrantfile +3 -3
- data/lib/generators/ahoy/templates/_database.yml +2 -2
- data/lib/generators/ahoy/templates/_deploy.rb +14 -13
- data/lib/generators/ahoy/templates/_puma.rb +3 -4
- data/lib/generators/ahoy/templates/_puma.sh +1 -1
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/complete/tasks/main.yml +14 -0
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/complete/templates/database.yml +9 -0
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/complete/templates/secrets.yml +2 -0
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/essentials/tasks/main.yml +6 -6
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/essentials/templates/vimrc +0 -2
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/nginx/templates/platform.conf +6 -6
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/postgresql/tasks/main.yml +8 -8
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/ruby/tasks/gems.yml +2 -2
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/ruby/tasks/rbenv.yml +8 -8
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/ruby/tasks/ruby.yml +4 -4
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/security/tasks/fail2ban.yml +4 -0
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/security/tasks/firewall.yml +2 -0
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/security/tasks/main.yml +1 -6
- data/lib/generators/ahoy/templates/{ansible_templates/playbooks/roles/security/tasks/_ssh_settings.yml → ansible/playbooks/roles/security/tasks/ssh_settings.yml} +4 -4
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/user/tasks/main.yml +4 -4
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/variables/tasks/application.yml +21 -0
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/variables/tasks/main.yml +3 -0
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/variables/tasks/system.yml +25 -0
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/variables/templates/profile +22 -0
- data/lib/generators/ahoy/templates/ansible/playbooks/tasks/vagrant_settings.yml +1 -1
- data/lib/generators/ahoy/templates/ansible/production.sh +1 -0
- data/lib/generators/ahoy/templates/ansible_templates/_production +5 -0
- data/lib/generators/ahoy/templates/{ansible/playbooks/playbook.yml → ansible_templates/playbooks/_production.yml} +6 -7
- data/lib/generators/ahoy/templates/ansible_templates/playbooks/_vagrant.yml +17 -0
- data/lib/generators/ahoy/templates/ansible_templates/playbooks/group_vars/_all.yml +2 -4
- data/lib/generators/ahoy/templates/ansible_templates/playbooks/group_vars/_production.yml +11 -0
- data/lib/generators/ahoy/templates/env_templates/_development_env.yml +1 -0
- data/lib/generators/ahoy/templates/env_templates/_production_env.yml +12 -0
- data/lib/generators/ahoy/templates/env_templates/_test_env.yml +1 -0
- data/lib/generators/ahoy/vagrant_generator.rb +31 -31
- metadata +22 -15
- data/lib/generators/ahoy/ansible_generator.rb +0 -36
- data/lib/generators/ahoy/deploy_generator.rb +0 -47
- data/lib/generators/ahoy/templates/_env_vars.yml +0 -7
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/deploy_env/tasks/main.yml +0 -10
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/deploy_env/templates/database.yml +0 -9
- data/lib/generators/ahoy/templates/ansible/playbooks/roles/deploy_env/templates/secrets.yml +0 -2
- data/lib/generators/ahoy/templates/ansible_templates/_hosts +0 -5
- data/lib/generators/ahoy/templates/ansible_templates/_provision.sh +0 -1
- data/lib/generators/ahoy/templates/ansible_templates/playbooks/host_vars/_default.yml +0 -8
- data/lib/generators/ahoy/templates/ansible_templates/playbooks/host_vars/_production_deploy.yml +0 -7
- data/lib/generators/ahoy/templates/ansible_templates/playbooks/host_vars/_production_root.yml +0 -2
@@ -25,12 +25,10 @@ NeoBundle 'reedes/vim-colors-pencil'
|
|
25
25
|
NeoBundle 'gcmt/taboo.vim'
|
26
26
|
|
27
27
|
" Syntax highlighting
|
28
|
-
" NeoBundle 'scrooloose/syntastic'
|
29
28
|
NeoBundle 'jtratner/vim-flavored-markdown.git'
|
30
29
|
NeoBundle 'elzr/vim-json'
|
31
30
|
NeoBundle 'kchmck/vim-coffee-script'
|
32
31
|
NeoBundle 'pangloss/vim-javascript'
|
33
|
-
" NeoBundle 'chase/vim-ansible-yaml'
|
34
32
|
|
35
33
|
" Snippets & autocomplete
|
36
34
|
NeoBundle 'sirver/ultisnips'
|
@@ -1,16 +1,16 @@
|
|
1
|
-
upstream {{
|
2
|
-
server {{
|
3
|
-
server unix:///var/www/{{
|
1
|
+
upstream {{app_name}} {
|
2
|
+
server {{server_domain}}:3000;
|
3
|
+
server unix:///var/www/{{app_name}}/shared/tmp/sockets/puma.sock;
|
4
4
|
}
|
5
5
|
server {
|
6
6
|
listen 80;
|
7
|
-
server_name {{
|
8
|
-
root /var/www/{{
|
7
|
+
server_name {{server_domain}};
|
8
|
+
root /var/www/{{app_name}}/current/public;
|
9
9
|
|
10
10
|
location / {
|
11
11
|
proxy_set_header Host $host;
|
12
12
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
13
|
-
proxy_pass http://{{
|
13
|
+
proxy_pass http://{{app_name}};
|
14
14
|
}
|
15
15
|
|
16
16
|
location ~* ^/assets/ {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
- name: install dependencies
|
3
|
-
action: apt pkg={{
|
3
|
+
action: apt pkg={{item}} state=latest
|
4
4
|
with_items:
|
5
5
|
- python-apt
|
6
6
|
- python-psycopg2
|
@@ -10,30 +10,30 @@
|
|
10
10
|
apt_key: url=http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc
|
11
11
|
|
12
12
|
- name: add apt-get repository for latest postgres
|
13
|
-
apt_repository: repo="deb http://apt.postgresql.org/pub/repos/apt/ {{
|
13
|
+
apt_repository: repo="deb http://apt.postgresql.org/pub/repos/apt/ {{ansible_lsb.codename}}-pgdg main"
|
14
14
|
|
15
15
|
- name: install postgres
|
16
|
-
apt: name=postgresql-{{
|
16
|
+
apt: name=postgresql-{{postgresql_version}} state=latest update_cache=true
|
17
17
|
|
18
18
|
- name: copy pg_hba.conf
|
19
19
|
sudo: true
|
20
|
-
template: src=pg_hba.conf dest=/etc/postgresql/{{
|
20
|
+
template: src=pg_hba.conf dest=/etc/postgresql/{{postgresql_version}}/main/pg_hba.conf
|
21
21
|
|
22
22
|
- name: set pg_hba.conf permissions
|
23
23
|
sudo: true
|
24
|
-
file: path=/etc/postgresql/{{
|
24
|
+
file: path=/etc/postgresql/{{postgresql_version}}/main/pg_hba.conf owner=postgres group=postgres mode=0640
|
25
25
|
|
26
26
|
- name: start postgresql
|
27
27
|
service: name=postgresql state=started
|
28
28
|
|
29
29
|
- name: create db user
|
30
|
-
postgresql_user: name={{
|
30
|
+
postgresql_user: name={{database_user}} password={{database_password}} role_attr_flags=CREATEDB
|
31
31
|
sudo_user: postgres
|
32
32
|
|
33
33
|
- name: create database
|
34
|
-
postgresql_db: name={{
|
34
|
+
postgresql_db: name={{database_name}} owner={{database_user}} encoding=unicode lc_collate=en_US.utf8 lc_ctype=en_US.utf8 template=template0
|
35
35
|
sudo_user: postgres
|
36
|
-
when: inventory_hostname == '
|
36
|
+
when: inventory_hostname == 'deploy'
|
37
37
|
|
38
38
|
- name: ensure postgres starts on a fresh reboot
|
39
39
|
service: name=postgresql state=started enabled=yes
|
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
- name: set gemrc
|
3
|
-
copy: src=gemrc dest=/home/{{
|
3
|
+
copy: src=gemrc dest=/home/{{server_user}}/.gemrc owner={{server_user}} group={{server_user}} mode=0644
|
4
4
|
|
5
5
|
- name: install bundler
|
6
|
-
shell: RBENV_ROOT={{
|
6
|
+
shell: RBENV_ROOT={{rbenv_root}} rbenv exec gem install bundler --no-ri --no-rdoc
|
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
- name: install dependencies
|
3
|
-
apt: pkg={{
|
3
|
+
apt: pkg={{item}} state=present
|
4
4
|
with_items:
|
5
5
|
- libqt4-dev
|
6
6
|
- libssl-dev
|
@@ -8,24 +8,24 @@
|
|
8
8
|
|
9
9
|
- name: install rbenv
|
10
10
|
sudo: true
|
11
|
-
git: repo=git://github.com/sstephenson/rbenv.git dest={{
|
11
|
+
git: repo=git://github.com/sstephenson/rbenv.git dest={{rbenv_root}}
|
12
12
|
|
13
13
|
- name: install ruby-build as rbenv plugin
|
14
14
|
sudo: true
|
15
|
-
git: repo=https://github.com/sstephenson/ruby-build.git dest={{
|
15
|
+
git: repo=https://github.com/sstephenson/ruby-build.git dest={{rbenv_root}}/plugins/ruby-build
|
16
16
|
|
17
17
|
- name: change owner of rbenv directory
|
18
18
|
sudo: true
|
19
|
-
file: path={{
|
19
|
+
file: path={{rbenv_root}} owner={{server_user}} recurse=yes state=directory
|
20
20
|
|
21
21
|
- name: add rbenv symlink
|
22
|
-
file: path=/usr/local/bin/rbenv src={{
|
22
|
+
file: path=/usr/local/bin/rbenv src={{rbenv_root}}/bin/rbenv state=link
|
23
23
|
|
24
24
|
- name: export RBENV_ROOT to profile
|
25
|
-
lineinfile: line='export RBENV_ROOT="{{
|
25
|
+
lineinfile: line='export RBENV_ROOT="{{rbenv_root}}"' dest=/home/{{server_user}}/.profile
|
26
26
|
|
27
27
|
- name: export PATH to rbenv bin to profile
|
28
|
-
lineinfile: line='export PATH="{{
|
28
|
+
lineinfile: line='export PATH="{{rbenv_root}}/bin:$PATH"' dest=/home/{{server_user}}/.profile
|
29
29
|
|
30
30
|
- name: eval rbenv init
|
31
|
-
lineinfile: line="eval \"$(rbenv init -)\"" dest=/home/{{
|
31
|
+
lineinfile: line="eval \"$(rbenv init -)\"" dest=/home/{{server_user}}/.profile
|
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
- name: check if proper ruby version is installed
|
3
|
-
shell: RBENV_ROOT={{
|
3
|
+
shell: RBENV_ROOT={{rbenv_root}} rbenv versions | grep {{ruby_version}}
|
4
4
|
register: ruby_installed
|
5
5
|
ignore_errors: yes
|
6
6
|
|
7
7
|
- name: install proper ruby version
|
8
|
-
shell: RBENV_ROOT={{
|
8
|
+
shell: RBENV_ROOT={{rbenv_root}} rbenv install {{ruby_version}}
|
9
9
|
when: ruby_installed|failed
|
10
10
|
|
11
11
|
- name: set global ruby
|
12
|
-
shell: RBENV_ROOT={{
|
12
|
+
shell: RBENV_ROOT={{rbenv_root}} rbenv global {{ruby_version}}
|
13
13
|
|
14
14
|
- name: rehash rbenv
|
15
|
-
shell: RBENV_ROOT={{
|
15
|
+
shell: RBENV_ROOT={{rbenv_root}} rbenv rehash
|
@@ -1,9 +1,4 @@
|
|
1
1
|
---
|
2
|
-
-
|
3
|
-
apt: name=fail2ban state=present update_cache=true
|
4
|
-
when: inventory_hostname == 'production_root'
|
5
|
-
|
2
|
+
- include: fail2ban.yml
|
6
3
|
- include: firewall.yml
|
7
|
-
when: inventory_hostname == 'production_root'
|
8
|
-
|
9
4
|
- include: ssh_settings.yml
|
@@ -1,13 +1,13 @@
|
|
1
1
|
---
|
2
2
|
- name: add local ssh keys to authorized_keys
|
3
|
-
authorized_key: user={{
|
3
|
+
authorized_key: user={{server_user}} key="{{lookup('file', '~/.ssh/id_rsa.pub')}}"
|
4
4
|
|
5
5
|
- name: change permissions on authorized_keys
|
6
|
-
file: path=/home/{{
|
6
|
+
file: path=/home/{{server_user}}/.ssh/authorized_keys mode=0400
|
7
7
|
|
8
8
|
- name: change ssh port
|
9
9
|
sudo: true
|
10
|
-
action: lineinfile dest=/etc/ssh/sshd_config regexp="^#?Port" line="Port
|
10
|
+
action: lineinfile dest=/etc/ssh/sshd_config regexp="^#?Port" line="Port {{server_ssh_port}}"
|
11
11
|
|
12
12
|
- name: disable root user login via ssh
|
13
13
|
sudo: true
|
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
- name: allow deploy user login via ssh
|
21
21
|
sudo: true
|
22
|
-
action: lineinfile dest=/etc/ssh/sshd_config insertafter=EOF line="AllowUsers {{
|
22
|
+
action: lineinfile dest=/etc/ssh/sshd_config insertafter=EOF line="AllowUsers {{server_user}}"
|
23
23
|
|
24
24
|
- name: restart ssh service
|
25
25
|
action: service name=ssh state=restarted
|
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
|
-
- name: create
|
3
|
-
user: name={{
|
2
|
+
- name: create server user
|
3
|
+
user: name={{server_user}} shell=/bin/bash generate_ssh_key=yes ssh_key_bits=2048
|
4
4
|
|
5
|
-
- name: allow
|
6
|
-
action: lineinfile dest=/etc/sudoers regexp="^root" line="root ALL=(ALL:ALL) ALL\n{{
|
5
|
+
- name: allow server user sudo commands without password
|
6
|
+
action: lineinfile dest=/etc/sudoers regexp="^root" line="root ALL=(ALL:ALL) ALL\n{{server_user}} ALL=(ALL) NOPASSWD:ALL" state=present
|
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
- name: check if .env exists
|
3
|
+
stat: path=/var/www/{{app_root}}/shared/.env/production_env.yml
|
4
|
+
register: env_file
|
5
|
+
|
6
|
+
- name: delete .env if exists
|
7
|
+
shell: rm /var/www/{{app_root}}/shared/.env/production_env.yml
|
8
|
+
when: env_file.stat.exists == true
|
9
|
+
|
10
|
+
- name: add environment variables to .env
|
11
|
+
lineinfile:
|
12
|
+
dest=/var/www/{{app_root}}/shared/.env/production_env.yml
|
13
|
+
line='{{item}}'
|
14
|
+
owner={{server_user}}
|
15
|
+
insertafter=EOF
|
16
|
+
create=true
|
17
|
+
with_items:
|
18
|
+
- 'database_name: {{database_name}}'
|
19
|
+
- 'database_user: {{database_user}}'
|
20
|
+
- 'database_password: {{database_password}}'
|
21
|
+
- 'secret_key_base: {{secret_key_base}}'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
---
|
2
|
+
- name: check if .profile exists
|
3
|
+
stat: path=/home/{{server_user}}/.profile
|
4
|
+
register: profile_file
|
5
|
+
|
6
|
+
- name: delete .profile if exists
|
7
|
+
shell: rm /home/{{server_user}}/.profile
|
8
|
+
when: profile_file.stat.exists == true
|
9
|
+
|
10
|
+
- name: recreate .profile from a clean template
|
11
|
+
template: src=profile dest=/home/{{server_user}}/.profile owner=deploy group=deploy
|
12
|
+
|
13
|
+
- name: add environment variables to .profile
|
14
|
+
lineinfile:
|
15
|
+
dest=/home/{{server_user}}/.profile
|
16
|
+
line='{{item}}'
|
17
|
+
owner={{server_user}}
|
18
|
+
insertafter=EOF
|
19
|
+
create=true
|
20
|
+
with_items:
|
21
|
+
- export APP_NAME={{app_name}}
|
22
|
+
- export APP_ROOT={{app_root}}
|
23
|
+
- export APP_DOMAIN="{{server_domain}}"
|
24
|
+
- export APP_REPO="{{app_repo}}"
|
25
|
+
- export APP_REPO_BRANCH={{app_repo_branch}}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# ~/.profile: executed by the command interpreter for login shells.
|
2
|
+
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
|
3
|
+
# exists.
|
4
|
+
# see /usr/share/doc/bash/examples/startup-files for examples.
|
5
|
+
# the files are located in the bash-doc package.
|
6
|
+
|
7
|
+
# the default umask is set in /etc/profile; for setting the umask
|
8
|
+
# for ssh logins, install and configure the libpam-umask package.
|
9
|
+
#umask 022
|
10
|
+
|
11
|
+
# if running bash
|
12
|
+
if [ -n "$BASH_VERSION" ]; then
|
13
|
+
# include .bashrc if it exists
|
14
|
+
if [ -f "$HOME/.bashrc" ]; then
|
15
|
+
. "$HOME/.bashrc"
|
16
|
+
fi
|
17
|
+
fi
|
18
|
+
|
19
|
+
# set PATH so it includes user's private bin if it exists
|
20
|
+
if [ -d "$HOME/bin" ] ; then
|
21
|
+
PATH="$HOME/bin:$PATH"
|
22
|
+
fi
|
@@ -0,0 +1 @@
|
|
1
|
+
ansible-playbook playbooks/production.yml -i production
|
@@ -0,0 +1,5 @@
|
|
1
|
+
[production]
|
2
|
+
root ansible_ssh_host=<%= Ahoy::VariableStore.variables['server_domain'] == '' ? '127.0.0.1' : Ahoy::VariableStore.variables['server_domain'] %>
|
3
|
+
|
4
|
+
[production]
|
5
|
+
deploy ansible_ssh_host=<%= Ahoy::VariableStore.variables['server_domain'] == '' ? '127.0.0.1' : Ahoy::VariableStore.variables['server_domain'] %> ansible_ssh_port=<%= Ahoy::VariableStore.variables['server_ssh_port'] == '' ? '22' : Ahoy::VariableStore.variables['server_ssh_port'] %>
|
@@ -1,22 +1,21 @@
|
|
1
1
|
---
|
2
|
-
#
|
2
|
+
# production playbook
|
3
3
|
#==========================================================
|
4
|
-
- hosts:
|
4
|
+
- hosts: root
|
5
5
|
sudo: true
|
6
6
|
user: root
|
7
7
|
roles:
|
8
8
|
- role: user
|
9
9
|
- role: security
|
10
10
|
|
11
|
-
- hosts:
|
11
|
+
- hosts: deploy
|
12
12
|
sudo: true
|
13
|
-
user:
|
14
|
-
vars_files:
|
15
|
-
- ../../env_vars.yml
|
13
|
+
user: <%= Ahoy::VariableStore.variables['server_user'] %>
|
16
14
|
roles:
|
17
15
|
- role: essentials
|
18
16
|
- role: nodejs
|
19
17
|
- role: nginx
|
20
18
|
- role: postgresql
|
21
19
|
- role: ruby
|
22
|
-
- role:
|
20
|
+
- role: variables
|
21
|
+
- role: complete
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
# Vagrant playbook
|
3
|
+
#==========================================================
|
4
|
+
- hosts: default
|
5
|
+
sudo: true
|
6
|
+
vars:
|
7
|
+
- server_user: vagrant
|
8
|
+
- database_user: vagrant
|
9
|
+
- database_password: vagrant
|
10
|
+
roles:
|
11
|
+
- role: user
|
12
|
+
- role: essentials
|
13
|
+
- role: nodejs
|
14
|
+
- role: postgresql
|
15
|
+
- role: ruby
|
16
|
+
tasks:
|
17
|
+
- include: tasks/vagrant_settings.yml
|
@@ -1,6 +1,4 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
|
4
|
-
version: <%= @postgresql_version == '' ? '9.3' : @postgresql_version %>
|
5
|
-
ruby_version: <%= @ruby_version == '' ? '2.1.5' : @ruby_version %>
|
2
|
+
postgresql_version: <%= Ahoy::VariableStore.variables['postgresql_version'] %>
|
3
|
+
ruby_version: <%= Ahoy::VariableStore.variables['ruby_version'] %>
|
6
4
|
rbenv_root: /usr/local/rbenv
|
@@ -0,0 +1,11 @@
|
|
1
|
+
---
|
2
|
+
server:
|
3
|
+
user: <%= Ahoy::VariableStore.variables['server_user'] %>
|
4
|
+
ssh_port: <%= Ahoy::VariableStore.variables['server_ssh_port'] %>
|
5
|
+
app:
|
6
|
+
root: <%= Ahoy::VariableStore.variables['app_name'] %>
|
7
|
+
secret_key_base: ea25c34b9d9443935394356303a408d19d5613ccdb77de0bc98c5ac57dcb5d19b53f03f13fd402926778b8f6fe6be81b67d9f206d16f5fe3145b9049a6fee582
|
8
|
+
database:
|
9
|
+
name: <%= Ahoy::VariableStore.variables['database_name'] %>
|
10
|
+
user: <%= Ahoy::VariableStore.variables['database_user'] %>
|
11
|
+
password: <%= Ahoy::VariableStore.variables['database_password'] %>
|
@@ -0,0 +1 @@
|
|
1
|
+
---
|
@@ -0,0 +1,12 @@
|
|
1
|
+
---
|
2
|
+
server_user: <%= Ahoy::VariableStore.variables['server_user'] %>
|
3
|
+
server_domain: <%= Ahoy::VariableStore.variables['server_domain'] %>
|
4
|
+
server_ssh_port: <%= Ahoy::VariableStore.variables['server_ssh_port'] %>
|
5
|
+
app_name: <%= Ahoy::VariableStore.variables['app_name'] %>
|
6
|
+
app_root: <%= Ahoy::VariableStore.variables['app_name'] %>
|
7
|
+
database_name: <%= Ahoy::VariableStore.variables['database_name'] %>
|
8
|
+
database_user: <%= Ahoy::VariableStore.variables['database_user'] %>
|
9
|
+
database_password: <%= Ahoy::VariableStore.variables['database_password'] %>
|
10
|
+
app_repo: <%= Ahoy::VariableStore.variables['app_repo'] %>
|
11
|
+
app_repo_branch: <%= Ahoy::VariableStore.variables['app_repo_branch'] %>
|
12
|
+
secret_key_base:
|
@@ -0,0 +1 @@
|
|
1
|
+
---
|
@@ -1,52 +1,52 @@
|
|
1
1
|
require 'rails/generators'
|
2
2
|
require 'generators/ahoy/base'
|
3
|
+
require 'generators/ahoy/lib/question_helper'
|
4
|
+
require 'generators/ahoy/lib/variable_store'
|
5
|
+
require 'fileutils'
|
3
6
|
|
4
7
|
module Ahoy
|
5
8
|
class VagrantGenerator < Ahoy::Generator::Base
|
6
9
|
|
7
10
|
def use_vagrant
|
8
|
-
|
9
|
-
|
11
|
+
question :boolean do
|
12
|
+
{
|
13
|
+
use_vagrant: 'Would you like to use Vagrant with your project?',
|
14
|
+
default: 'No'
|
15
|
+
}
|
16
|
+
end
|
10
17
|
end
|
11
18
|
|
12
19
|
def prompt_user
|
13
|
-
if
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
+
if Ahoy::VariableStore.variables['use_vagrant'] == true
|
21
|
+
question :string do
|
22
|
+
{
|
23
|
+
vagrant_memory: 'How many Megabytes of memory would you like to allocate to your VM? [enter for default]',
|
24
|
+
default: '2'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
question :string do
|
28
|
+
{
|
29
|
+
vagrant_cpus: 'How many CPUs would you like to allocated? [enter for default]',
|
30
|
+
default: '1'
|
31
|
+
}
|
32
|
+
end
|
20
33
|
else
|
21
34
|
puts 'Skipping Vagrant'
|
35
|
+
exit
|
22
36
|
end
|
23
37
|
end
|
24
38
|
|
25
|
-
|
39
|
+
def copy_files
|
40
|
+
copy_file 'ansible_templates/playbooks/_vagrant.yml', 'config/ansible/playbooks/vagrant.yml'
|
41
|
+
end
|
26
42
|
|
27
|
-
def
|
28
|
-
|
29
|
-
template '_database.yml', 'config/database.yml'
|
30
|
-
template 'ansible_templates/playbooks/host_vars/_default.yml', 'config/ansible/playbooks/host_vars/default.yml'
|
43
|
+
def backup_files
|
44
|
+
FileUtils.mv 'config/database.yml', 'config/database.yml.bak'
|
31
45
|
end
|
32
46
|
|
33
|
-
def
|
34
|
-
|
47
|
+
def copy_templates
|
48
|
+
template '_database.yml', 'config/database.yml'
|
49
|
+
template '_Vagrantfile', 'Vagrantfile'
|
35
50
|
end
|
36
51
|
end
|
37
52
|
end
|
38
|
-
|
39
|
-
VAGRANT_PLAYBOOK = "
|
40
|
-
# Vagrant playbook
|
41
|
-
#==========================================================
|
42
|
-
- hosts: default
|
43
|
-
sudo: true
|
44
|
-
roles:
|
45
|
-
- role: user
|
46
|
-
- role: essentials
|
47
|
-
- role: nodejs
|
48
|
-
- role: postgresql
|
49
|
-
- role: ruby
|
50
|
-
tasks:
|
51
|
-
- include: tasks/vagrant_settings.yml
|
52
|
-
"
|