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
@@ -1,47 +0,0 @@
1
- module Orats
2
- module Commands
3
- module UI
4
- include Thor::Shell
5
-
6
- def log_task(message)
7
- puts
8
- say_status 'task', "#{message}:", :yellow
9
- puts '-'*80, ''; sleep 0.25
10
- end
11
-
12
- def log_status_top(type, message, color)
13
- puts
14
- say_status type, set_color(message, :bold), color
15
- end
16
-
17
- def log_status_bottom(type, message, color, strip_newline = false)
18
- say_status type, message, color
19
- puts unless strip_newline
20
- end
21
-
22
- def log_results(results, message)
23
- log_status_top 'results', "#{results}:", :magenta
24
- log_status_bottom 'message', message, :white
25
- end
26
-
27
- def log_error(top_label, top_message, bottom_label, bottom_message, strip_newline = false)
28
- log_status_top top_label, "#{top_message}:", :red
29
- log_status_bottom bottom_label, bottom_message, :yellow, strip_newline
30
- yield if block_given?
31
- end
32
-
33
- def log_remote_info(top_label, top_message, bottom_label, bottom_message)
34
- log_status_top top_label, "#{top_message}:", :blue
35
- log_status_bottom bottom_label, bottom_message, :cyan
36
- end
37
-
38
- def run_from(path, command)
39
- run "cd #{path} && #{command} && cd -"
40
- end
41
-
42
- def git_commit(message)
43
- run_from @active_path, "git add -A && git commit -m '#{message}'"
44
- end
45
- end
46
- end
47
- end
@@ -1,202 +0,0 @@
1
- ---
2
- # -----------------------------------------------------------------------------
3
- # secrets
4
- # load all passwords from a local location outside of version control
5
- # -----------------------------------------------------------------------------
6
-
7
- # do not add a trailing slash to the path
8
- secrets_load_path: /home/yourname/dev/testproj/secrets
9
-
10
- secrets_postgres_password: "{{ lookup('password', secrets_load_path + '/postgres_password') }}"
11
- secrets_redis_password: "{{ lookup('password', secrets_load_path + '/redis_password') }}"
12
- secrets_mail_password: "{{ lookup('password', secrets_load_path + '/mail_password') }}"
13
- secrets_rails_token: "{{ lookup('password', secrets_load_path + '/rails_token') }}"
14
- secrets_devise_token: "{{ lookup('password', secrets_load_path + '/devise_token') }}"
15
- secrets_devise_pepper_token: "{{ lookup('password', secrets_load_path + '/devise_pepper_token') }}"
16
-
17
- # -----------------------------------------------------------------------------
18
- # ansible
19
- # -----------------------------------------------------------------------------
20
- # default values you can overwrite with documentation:
21
- # http://docs.ansible.com/intro_inventory.html#list-of-behavioral-inventory-parameters
22
- # -----------------------------------------------------------------------------
23
-
24
- ansible_ssh_user: deploy
25
-
26
- # -----------------------------------------------------------------------------
27
- # locale
28
- # -----------------------------------------------------------------------------
29
- # default values you can overwrite with documentation:
30
- # https://github.com/nickjj/ansible-locale/#role-variables
31
- # -----------------------------------------------------------------------------
32
-
33
- # -----------------------------------------------------------------------------
34
- # sshd
35
- # -----------------------------------------------------------------------------
36
- # default values you can overwrite with documentation:
37
- # https://github.com/nickjj/ansible-sshd/#role-variables
38
- # -----------------------------------------------------------------------------
39
-
40
- # -----------------------------------------------------------------------------
41
- # ferm
42
- # -----------------------------------------------------------------------------
43
- # default values you can overwrite with documentation:
44
- # https://github.com/nickjj/ansible-ferm/#role-variables
45
- # -----------------------------------------------------------------------------
46
-
47
- # -----------------------------------------------------------------------------
48
- # fail2ban
49
- # -----------------------------------------------------------------------------
50
- # default values you can overwrite with documentation:
51
- # https://github.com/nickjj/ansible-fail2ban/#role-variables
52
- # -----------------------------------------------------------------------------
53
-
54
- # -----------------------------------------------------------------------------
55
- # user
56
- # -----------------------------------------------------------------------------
57
- # default values you can overwrite with documentation:
58
- # https://github.com/nickjj/ansible-user/#role-variables
59
- # -----------------------------------------------------------------------------
60
-
61
- user_name: "{{ ansible_ssh_user }}"
62
-
63
- # -----------------------------------------------------------------------------
64
- # postgres
65
- # -----------------------------------------------------------------------------
66
- # default values you can overwrite with documentation:
67
- # https://github.com/nickjj/ansible-postgres/#role-variables
68
- # -----------------------------------------------------------------------------
69
-
70
- postgres_user: "{{ user_name }}"
71
- postgres_password: "{{ secrets_postgres_password }}"
72
-
73
- # -----------------------------------------------------------------------------
74
- # redis
75
- # -----------------------------------------------------------------------------
76
- # default values you can overwrite with documentation:
77
- # https://github.com/DavidWittman/ansible-redis/blob/master/defaults/main.yml
78
- # -----------------------------------------------------------------------------
79
-
80
- redis_bind: 0.0.0.0
81
- redis_port: 6379
82
- redis_install_dir: /usr/local
83
- redis_dir: /usr/local/redis
84
- redis_password: "{{ secrets_redis_password }}"
85
-
86
- # -----------------------------------------------------------------------------
87
- # rails
88
- # -----------------------------------------------------------------------------
89
- # default values you can overwrite with documentation:
90
- # https://github.com/nickjj/ansible-rails/#role-variables
91
- # -----------------------------------------------------------------------------
92
-
93
- rails_deploy_app_name: testproj
94
- rails_deploy_user: "{{ user_name }}"
95
-
96
- rails_deploy_ssh_keypair_local_path: "{{ secrets_load_path }}"
97
-
98
- rails_deploy_git_url: "git@bitbucket.org:yourname/testproj.git"
99
-
100
- rails_deploy_migrate_master_host: "{{ groups['app'][0] }}"
101
-
102
- rails_deploy_env:
103
- RAILS_ENV: production
104
- SOURCE_ENV_PATH: "/etc/default/{{ rails_deploy_app_name }}"
105
-
106
- PROJECT_PATH: "{{ rails_deploy_path }}"
107
- TIME_ZONE: Eastern Time (US & Canada)
108
- DEFAULT_LOCALE: en
109
-
110
- GOOGLE_ANALYTICS_UA: ""
111
- DISQUS_SHORT_NAME: ""
112
- S3_ACCESS_KEY_ID: ""
113
- S3_SECRET_ACCESS_KEY: ""
114
- S3_REGION: ""
115
-
116
- DATABASE_HOST: localhost
117
- DATABASE_NAME: "{{ rails_deploy_app_name }}"
118
- DATABASE_USERNAME: "{{ postgres_user }}"
119
- DATABASE_PASSWORD: "{{ postgres_password }}"
120
- DATABASE_POOL: 25
121
- DATABASE_TIMEOUT: 5000
122
-
123
- CACHE_HOST: "{{ redis_bind }}"
124
- CACHE_PORT: "{{ redis_port }}"
125
- CACHE_DATABASE: 0
126
- CACHE_PASSWORD: "{{ secrets_redis_password }}"
127
-
128
- TOKEN_RAILS_SECRET: "{{ secrets_rails_token }}"
129
- TOKEN_DEVISE_SECRET: "{{ secrets_devise_token }}"
130
- TOKEN_DEVISE_PEPPER: "{{ secrets_devise_pepper_token }}"
131
-
132
- SMTP_ADDRESS: smtp.gmail.com
133
- SMTP_PORT: 587 # 465 if you use ssl
134
- SMTP_DOMAIN: gmail.com
135
- SMTP_USERNAME: info@testproj.com
136
- SMTP_PASSWORD: "{{ secrets_mail_password }}"
137
- SMTP_AUTH: plain
138
- SMTP_ENCRYPTION: starttls
139
-
140
- ACTION_MAILER_HOST: www.testproj.com
141
- ACTION_MAILER_DEFAULT_FROM: info@testproj.com
142
- ACTION_MAILER_DEFAULT_TO: me@testproj.com
143
- ACTION_MAILER_DEVISE_DEFAULT_FROM: info@testproj.com
144
-
145
- PUMA_THREADS_MIN: 0
146
- PUMA_THREADS_MAX: 16
147
-
148
- PUMA_WORKERS: "{{ ansible_processor_cores if ansible_processor_cores > 1 else 2 }}"
149
-
150
- SIDEKIQ_CONCURRENCY: 25
151
-
152
- # -----------------------------------------------------------------------------
153
- # whenever
154
- # -----------------------------------------------------------------------------
155
- # default values you can overwrite with documentation:
156
- # https://github.com/nickjj/ansible-whenever/#role-variables
157
- # -----------------------------------------------------------------------------
158
-
159
- whenever_update: rails_deploy_app_name
160
-
161
- # -----------------------------------------------------------------------------
162
- # pumacorn
163
- # -----------------------------------------------------------------------------
164
- # default values you can overwrite with documentation:
165
- # https://github.com/nickjj/ansible-pumacorn/#role-variables
166
- # -----------------------------------------------------------------------------
167
-
168
- # -----------------------------------------------------------------------------
169
- # sidekiq
170
- # -----------------------------------------------------------------------------
171
- # default values you can overwrite with documentation:
172
- # https://github.com/nickjj/ansible-sidekiq/#role-variables
173
- # -----------------------------------------------------------------------------
174
-
175
- # -----------------------------------------------------------------------------
176
- # nginx
177
- # -----------------------------------------------------------------------------
178
- # default values you can overwrite with documentation:
179
- # https://github.com/nickjj/ansible-nginx/#role-variables
180
- # -----------------------------------------------------------------------------
181
-
182
- nginx_base_domain: localhost # change this to yourdomain.com
183
- nginx_upstream_name: "{{ rails_deploy_app_name }}"
184
- nginx_upstream_server: unix://{{ rails_deploy_path }}/tmp/puma.sock
185
- nginx_root_path: "{{ rails_deploy_path }}/public"
186
- nginx_ssl_local_path: "{{ secrets_load_path }}"
187
-
188
- # -----------------------------------------------------------------------------
189
- # monit
190
- # -----------------------------------------------------------------------------
191
- # default values you can overwrite with documentation:
192
- # https://github.com/nickjj/ansible-monit/#role-variables
193
- # -----------------------------------------------------------------------------
194
-
195
- monit_process_list: |
196
- check process {{ rails_deploy_app_name }} with pidfile {{ rails_deploy_path }}/tmp/{{ pumacorn_server }}.pid
197
- start program = "/etc/init.d/{{ rails_deploy_app_name }} start"
198
- stop program = "/etc/init.d/{{ rails_deploy_app_name }} stop"
199
-
200
- check process sidekiq with pidfile {{ rails_deploy_path }}/tmp/sidekiq.pid
201
- start program = "/etc/init.d/sidekiq start"
202
- stop program = "/etc/init.d/sidekiq stop"
@@ -1,8 +0,0 @@
1
- [app]
2
- 192.168.1.2
3
-
4
- [cache]
5
- 192.168.1.2
6
-
7
- [database]
8
- 192.168.1.2
@@ -1,15 +0,0 @@
1
- nickjj.locale,v0.1.1
2
- nickjj.sshd,v0.1.2
3
- nickjj.ferm,v0.1.1
4
- nickjj.fail2ban,v0.1.2
5
- nickjj.user,v0.1.0
6
- nickjj.postgres,v0.1.3
7
- nickjj.ruby,v0.1.9
8
- nickjj.nodejs,v0.1.1
9
- nickjj.nginx,v0.1.4
10
- nickjj.rails,v0.2.2
11
- nickjj.whenever,v0.1.2
12
- nickjj.pumacorn,v0.1.2
13
- nickjj.sidekiq,v0.1.2
14
- nickjj.monit,v0.1.3
15
- DavidWittman.redis
@@ -1,23 +0,0 @@
1
- ---
2
- - name: ensure all servers are commonly configured without sudo
3
- hosts: all:!localhost
4
- sudo: false
5
-
6
- tasks:
7
- - name: ensure IP address of the ansible controller is set
8
- set_fact:
9
- ansible_controller: '{{ ansible_env.SSH_CLIENT.split(" ") | first }}/32'
10
- when: (ansible_controller is undefined and ansible_connection != "local")
11
- tags: [common, ferm]
12
-
13
-
14
- - name: ensure all servers are commonly configured with sudo
15
- hosts: all
16
- sudo: true
17
-
18
- roles:
19
- - { role: nickjj.locale, tags: [common, locale] }
20
- - { role: nickjj.sshd, tags: [common, sshd] }
21
- - { role: nickjj.ferm, tags: [common, ferm] }
22
- - { role: nickjj.fail2ban, tags: [common, fail2ban] }
23
- - { role: nickjj.user, tags: [common, user] }
@@ -1,36 +0,0 @@
1
- ---
2
- - include: common.yml
3
-
4
- - name: ensure database servers are configured
5
- hosts: database
6
- sudo: true
7
-
8
- roles:
9
- - { role: nickjj.postgres, tags: [database, postgres] }
10
-
11
- - name: ensure cache servers are configured
12
- hosts: cache
13
- sudo: true
14
-
15
- roles:
16
- - { role: DavidWittman.redis, tags: [cache, redis] }
17
-
18
- - name: ensure app servers are configured
19
- hosts: app
20
- sudo: true
21
-
22
- roles:
23
- - role: nickjj.ferm
24
- tags: [app, ferm]
25
- ferm_input_list:
26
- - type: "dport_accept"
27
- dport: ["http", "https"]
28
-
29
- - { role: nickjj.ruby, tags: [app, ruby] }
30
- - { role: nickjj.nodejs, tags: [app, nodejs] }
31
- - { role: nickjj.nginx, tags: [app, nginx] }
32
- - { role: nickjj.rails, tags: [app, rails] }
33
- - { role: nickjj.whenever, tags: [app, rails] }
34
- - { role: nickjj.pumacorn, tags: [app, rails] }
35
- - { role: nickjj.sidekiq, tags: [app, rails] }
36
- - { role: nickjj.monit, tags: [app, monit] }
@@ -1,19 +0,0 @@
1
- ---
2
- language: "python"
3
- python: "2.7"
4
-
5
- env:
6
- - SITE_AND_INVENTORY="tests/main.yml -i tests/inventory"
7
-
8
- install:
9
- - "pip install ansible==1.6.2"
10
- - "printf '[defaults]\nroles_path = ../' > ansible.cfg"
11
-
12
- script:
13
- - "ansible-playbook $SITE_AND_INVENTORY --syntax-check"
14
- - "ansible-playbook $SITE_AND_INVENTORY --connection=local -vvvv"
15
- - >
16
- ansible-playbook $SITE_AND_INVENTORY --connection=local
17
- | grep -q 'changed=0.*failed=0'
18
- && (echo 'Idempotence test: pass' && exit 0)
19
- || (echo 'Idempotence test: fail' && exit 1)
@@ -1,62 +0,0 @@
1
- ## What is repo_name? [![Build Status](https://secure.travis-ci.org/github_user/repo_name.png)](http://travis-ci.org/github_user/repo_name)
2
-
3
- It is an [ansible](http://www.ansible.com/home) role to <enter what the role is about>.
4
-
5
- ### What problem does it solve and why is it useful?
6
-
7
- Thanks for generating a role with orats. Here's your todo list:
8
-
9
- - Change `meta/main.yml` to your liking
10
- - Create your awesome role
11
- - Fill out this readme properly
12
- - Sign up for [travis-ci.org](http://travis-ci.org) (it is free for public repos)
13
- - Review `.travis.yml` and write reasonable tests
14
- - Push your role to github and tag it with a version number
15
- - Publish your role on the [ansible galaxy](https://galaxy.ansible.com) if it's not private
16
- - Replace the `role_id` with your id in the `Ansible galaxy` section of this readme
17
-
18
- ## Role variables
19
-
20
- Below is a list of default values along with a description of what they do.
21
-
22
- ```
23
- # Add your default role variables here.
24
- ```
25
-
26
- ## Example playbook
27
-
28
- For the sake of this example let's assume you have a group called **foo** and you have a typical `site.yml` file.
29
-
30
- To use this role edit your `site.yml` file to look something like this:
31
-
32
- ```
33
- ---
34
- - name: ensure foo servers are configured
35
- - hosts: foo
36
-
37
- roles:
38
- - { role: github_user.role_name, tags: role_name }
39
- ```
40
-
41
- Let's say you want to edit a few values, you can do this by opening or creating `group_vars/foo.yml` which is located relative to your `inventory` directory and then making it look something like this:
42
-
43
- ```
44
- ---
45
- # Overwrite the defaults here.
46
- ```
47
-
48
- ## Installation
49
-
50
- `$ ansible-galaxy install github_user.role_name`
51
-
52
- ## Requirements
53
-
54
- Tested on <enter your OS of choice>.
55
-
56
- ## Ansible galaxy
57
-
58
- You can find it on the official [ansible galaxy](https://galaxy.ansible.com/list#/roles/role_id) if you want to rate it.
59
-
60
- ## License
61
-
62
- MIT
@@ -1,123 +0,0 @@
1
- ---
2
- galaxy_info:
3
- author: author_name
4
- description: Enter a short description about this role.
5
- company: Your company (optional).
6
- # Some suggested licenses:
7
- # - BSD (default)
8
- # - MIT
9
- # - GPLv2
10
- # - GPLv3
11
- # - Apache
12
- # - CC-BY
13
- license: license MIT
14
- min_ansible_version: 1.6
15
- #
16
- # Below are all platforms currently available. Just uncomment
17
- # the ones that apply to your role. If you don't see your
18
- # platform on this list, let us know and we'll get it added!
19
- #
20
- #platforms:
21
- #- name: EL
22
- # versions:
23
- # - all
24
- # - 5
25
- # - 6
26
- # - 7
27
- #- name: GenericUNIX
28
- # versions:
29
- # - all
30
- # - any
31
- #- name: Fedora
32
- # versions:
33
- # - all
34
- # - 16
35
- # - 17
36
- # - 18
37
- # - 19
38
- # - 20
39
- #- name: opensuse
40
- # versions:
41
- # - all
42
- # - 12.1
43
- # - 12.2
44
- # - 12.3
45
- # - 13.1
46
- # - 13.2
47
- #- name: Amazon
48
- # versions:
49
- # - all
50
- # - 2013.03
51
- # - 2013.09
52
- #- name: GenericBSD
53
- # versions:
54
- # - all
55
- # - any
56
- #- name: FreeBSD
57
- # versions:
58
- # - all
59
- # - 8.0
60
- # - 8.1
61
- # - 8.2
62
- # - 8.3
63
- # - 8.4
64
- # - 9.0
65
- # - 9.1
66
- # - 9.1
67
- # - 9.2
68
- #- name: Ubuntu
69
- # versions:
70
- # - all
71
- # - lucid
72
- # - maverick
73
- # - natty
74
- # - oneiric
75
- # - precise
76
- # - quantal
77
- # - raring
78
- # - saucy
79
- # - trusty
80
- #- name: SLES
81
- # versions:
82
- # - all
83
- # - 10SP3
84
- # - 10SP4
85
- # - 11
86
- # - 11SP1
87
- # - 11SP2
88
- # - 11SP3
89
- #- name: GenericLinux
90
- # versions:
91
- # - all
92
- # - any
93
- #- name: Debian
94
- # versions:
95
- # - all
96
- # - etch
97
- # - lenny
98
- # - squeeze
99
- # - wheezy
100
- #
101
- # Below are all categories currently available. Just as with
102
- # the platforms above, uncomment those that apply to your role.
103
- #
104
- #categories:
105
- #- cloud
106
- #- cloud:ec2
107
- #- cloud:gce
108
- #- cloud:rax
109
- #- clustering
110
- #- database
111
- #- database:nosql
112
- #- database:sql
113
- #- development
114
- #- monitoring
115
- #- networking
116
- #- packaging
117
- #- system
118
- #- web
119
- dependencies: []
120
- # List your role dependencies here, one per line. Only
121
- # dependencies available via galaxy should be listed here.
122
- # Be sure to remove the '[]' above if you add dependencies
123
- # to this list.
@@ -1 +0,0 @@
1
- localhost
@@ -1,7 +0,0 @@
1
- ---
2
- - hosts: localhost
3
- remote_user: travis
4
- sudo: true
5
-
6
- roles:
7
- - repo_name
@@ -1,119 +0,0 @@
1
- # =============================================================================
2
- # template for generating an orats ansible playbook for ansible 1.6.x
3
- # =============================================================================
4
- # view the task list at the bottom of the file
5
- # -----------------------------------------------------------------------------
6
-
7
- # -----------------------------------------------------------------------------
8
- # private functions
9
- # -----------------------------------------------------------------------------
10
- def method_to_sentence(method)
11
- method.tr!('_', ' ')
12
- method[0] = method[0].upcase
13
- method
14
- end
15
-
16
- def log_task(message)
17
- puts
18
- say_status 'task', "#{method_to_sentence(message.to_s)}:", :yellow
19
- puts '-'*80, ''; sleep 0.25
20
- end
21
-
22
- def git_commit(message)
23
- git add: '-A'
24
- git commit: "-m '#{message}'"
25
- end
26
-
27
- def git_config(field)
28
- command = "git config --global user.#{field}"
29
- git_field_value = run(command, capture: true).gsub("\n", '')
30
- default_value = "YOUR_#{field.upcase}"
31
-
32
- git_field_value.to_s.empty? ? default_value : git_field_value
33
- end
34
-
35
- def copy_from_local_gem(source, dest = '')
36
- dest = source if dest.empty?
37
-
38
- base_path = "#{File.expand_path File.dirname(__FILE__)}/includes/playbook"
39
-
40
- run "mkdir -p #{File.dirname(dest)}" unless Dir.exist?(File.dirname(dest))
41
- run "cp -f #{base_path}/#{source} #{dest}"
42
- end
43
-
44
- # ---
45
-
46
- def delete_generated_rails_code
47
- log_task __method__
48
-
49
- run 'rm -rf * .git .gitignore'
50
- end
51
-
52
- def add_playbook_directory
53
- log_task __method__
54
-
55
- run "mkdir -p #{app_name}"
56
- run "mv #{app_name}/* ."
57
- run "rm -rf #{app_name}"
58
- git :init
59
- git_commit 'Initial commit'
60
- end
61
-
62
- def add_gitignore
63
- log_task __method__
64
-
65
- copy_from_local_gem '../common/.gitignore', '.gitignore'
66
- git_commit 'Add .gitignore'
67
- end
68
-
69
- def add_license
70
- log_task __method__
71
-
72
- author_name = git_config 'name'
73
- author_email = git_config 'email'
74
-
75
- copy_from_local_gem '../common/LICENSE', 'LICENSE'
76
- gsub_file 'LICENSE', 'Time.now.year', Time.now.year.to_s
77
- gsub_file 'LICENSE', 'author_name', author_name
78
- gsub_file 'LICENSE', 'author_email', author_email
79
- git_commit 'Add MIT license'
80
- end
81
-
82
- def add_common_plays
83
- log_task __method__
84
-
85
- copy_from_local_gem 'common.yml'
86
- git_commit 'Add common playsk'
87
- end
88
-
89
- def add_site_plays
90
- log_task __method__
91
-
92
- copy_from_local_gem 'site.yml'
93
- git_commit 'Add the site plays'
94
- end
95
-
96
- def add_galaxyfile
97
- log_task __method__
98
-
99
- copy_from_local_gem 'Galaxyfile'
100
- git_commit 'Add the Galaxyfile'
101
- end
102
-
103
- def remove_unused_files_from_git
104
- log_task __method__
105
-
106
- git add: '-u'
107
- git_commit 'Remove unused files'
108
- end
109
-
110
- # ---
111
-
112
- delete_generated_rails_code
113
- add_playbook_directory
114
- add_gitignore
115
- add_license
116
- add_common_plays
117
- add_site_plays
118
- add_galaxyfile
119
- remove_unused_files_from_git