salted-rails 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/README.md +7 -0
  2. data/lib/salted-rails/config.rb +71 -55
  3. data/lib/salted-rails/helper_base.rb +15 -0
  4. data/lib/salted-rails/vagrant_helper.rb +15 -9
  5. data/lib/salted-rails/version.rb +1 -1
  6. data/pillar/capistrano/top.sls +1 -1
  7. data/pillar/common.sls +1 -8
  8. data/pillar/vagrant/top.sls +1 -1
  9. data/salt/apt/load_packages.sls +5 -0
  10. data/salt/apt/update_packages.sls +5 -0
  11. data/salt/bin/change_mirror.sh +10 -6
  12. data/salt/bin/misc_fixes.sh +26 -0
  13. data/salt/bin/provision +40 -3
  14. data/salt/ci/cruisecontrolrb.sls +17 -11
  15. data/salt/ci/teamcity/etc/init.d/teamcity +4 -4
  16. data/salt/ci/teamcity/init.sls +18 -18
  17. data/salt/crons/init.sls +2 -2
  18. data/salt/databases/init.sls +45 -14
  19. data/salt/databases/mysql/client.sls +1 -1
  20. data/salt/databases/mysql/common.sls +3 -3
  21. data/salt/databases/mysql/server.sls +1 -1
  22. data/salt/databases/packages.sls +47 -0
  23. data/salt/databases/phpmyadmin/etc/nginx/admin.d/phpmyadmin.conf +10 -7
  24. data/salt/databases/postgresql/client.sls +5 -0
  25. data/salt/databases/postgresql/init.sls +10 -0
  26. data/salt/databases/sqlite3.sls +6 -0
  27. data/salt/databases/sqlitebrowser.sls +4 -0
  28. data/salt/editors/gvim.sls +5 -1
  29. data/salt/editors/rubymine.sls +16 -16
  30. data/salt/editors/vim/init.sls +71 -2
  31. data/salt/editors/vim/vimrc +8 -1
  32. data/salt/gui/desktop.sls +9 -0
  33. data/salt/gui/x2go.sls +5 -0
  34. data/salt/lang/jenv.sls +64 -0
  35. data/salt/lang/php/etc/php5/fpm/pool.d/www.conf +2 -2
  36. data/salt/lang/phpenv.sls +82 -0
  37. data/salt/lang/rbenv.sls +115 -0
  38. data/salt/lang/ruby.sls +24 -37
  39. data/salt/munin/nginx.sls +3 -1
  40. data/salt/munin/node.sls +2 -1
  41. data/salt/munin/php5-fpm.sls +3 -1
  42. data/salt/net/hosts.sls +9 -0
  43. data/salt/net/ntp.sls +6 -0
  44. data/salt/net/ufw.sls +8 -0
  45. data/salt/railsapp/gems.sls +5 -3
  46. data/salt/railsapp/init.sls +6 -2
  47. data/salt/scm/bazaar.sls +10 -0
  48. data/salt/scm/git/gitconfig +42 -0
  49. data/salt/scm/git/init.sls +21 -0
  50. data/salt/scm/init.sls +5 -0
  51. data/salt/scm/mercurial.sls +10 -0
  52. data/salt/scm/subversion.sls +6 -0
  53. data/salt/{vagrant/top.sls → top.sls} +24 -9
  54. data/salt/utils/file.sls +19 -0
  55. data/salt/utils/html.sls +5 -0
  56. data/salt/utils/init.sls +6 -0
  57. data/salt/{sysutils → utils}/net.sls +4 -0
  58. data/salt/{sysutils → utils}/status.sls +0 -0
  59. data/salt/utils/tmux/home/tmux-dev +7 -0
  60. data/salt/utils/tmux/home/tmux.conf +89 -0
  61. data/salt/utils/tmux/init.sls +32 -0
  62. data/salt/vagrant/minion.sls +1 -1
  63. data/salt/www/chromium.sls +5 -0
  64. data/salt/www/nginx/etc/nginx/admin.d/doc.conf +7 -0
  65. data/salt/www/nginx/etc/nginx/admin.d/nginx_status.conf +7 -0
  66. data/salt/www/nginx/etc/nginx/sites-available/.gitignore +3 -0
  67. data/salt/www/nginx/etc/nginx/sites-available/admin.conf +47 -0
  68. data/salt/www/nginx/init.sls +102 -16
  69. data/salt/www/nginx/srv/www/admin/favicon.ico +0 -0
  70. data/salt/www/nginx/srv/www/admin/favicon.png +0 -0
  71. data/salt/www/nginx/srv/www/admin/index.php +67 -0
  72. data/salt/www/nginx/srv/www/admin/phpinfo.php +3 -0
  73. data/salt/www/nginx/srv/www/admin/robots.txt +2 -0
  74. data/salt/www/users.sls +0 -9
  75. metadata +41 -20
  76. data/salt/bin/fix_hostname.sh +0 -6
  77. data/salt/capistrano/deploy_requirements.sls +0 -5
  78. data/salt/capistrano/top.sls +0 -4
  79. data/salt/databases/client.sls +0 -18
  80. data/salt/databases/server.sls +0 -19
  81. data/salt/gui/init.sls +0 -3
  82. data/salt/lang/ruby.sls.bak +0 -106
  83. data/salt/lang/system_ruby.sls +0 -43
  84. data/salt/sysutils/file.sls +0 -8
  85. data/salt/sysutils/init.sls +0 -5
  86. data/salt/sysutils/tmux.sls +0 -3
  87. data/salt/www/admin/etc/nginx/nginx.conf +0 -53
  88. data/salt/www/admin/etc/nginx/sites-available/.gitignore +0 -3
  89. data/salt/www/admin/etc/nginx/sites-available/phpmyadmin.conf +0 -7
  90. data/salt/www/admin/init.sls +0 -31
@@ -0,0 +1,47 @@
1
+ server {
2
+ listen *:880;
3
+
4
+ {%- if pillar['admin_password'] %}
5
+ ssl on;
6
+ ssl_certificate /etc/pki/self_signed/certs/localhost.crt;
7
+ ssl_certificate_key /etc/pki/self_signed/certs/localhost.key;
8
+
9
+ auth_basic "Restricted site";
10
+ auth_basic_user_file /etc/nginx/admin.d/htpasswd;
11
+ {%- endif %}
12
+
13
+ satisfy all;
14
+
15
+ # Allow private IP range.
16
+ allow 10.0.0.0/8;
17
+ allow 172.16.0.0/12;
18
+ allow 192.168.0.0/16;
19
+
20
+ # todo: add list of dynamic ips - of admins
21
+
22
+ deny all;
23
+
24
+ #listen [::1]:880 default ipv6only=on; ## listen for ipv6
25
+ index index.php index.html index.htm;
26
+
27
+ server_name localhost;
28
+ client_max_body_size 20M;
29
+
30
+ root {{ pillar['www_dir'] }}/admin;
31
+
32
+ location ~ \.php$ {
33
+ fastcgi_split_path_info ^(.+\.php)(/.+)$;
34
+ # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
35
+ #
36
+ # # With php5-cgi alone:
37
+ # fastcgi_pass 127.0.0.1:9000;
38
+ # # With php5-fpm:
39
+ fastcgi_pass unix:/var/run/php5-fpm.sock;
40
+ fastcgi_index index.php;
41
+ include fastcgi_params;
42
+ }
43
+
44
+ include /etc/nginx/admin.d/*.conf;
45
+
46
+ }
47
+
@@ -1,33 +1,119 @@
1
1
  nginx:
2
2
  pkg.installed:
3
- - name: nginx-full
3
+ - pkgs:
4
+ - nginx-full
5
+ - apache2-utils # for htpasswd
4
6
  service:
5
7
  - running
6
8
  - enable: True
7
9
  - reload: True
8
- #- watch:
9
- #- file: {{ pillar['etc_dir'] }}nginx/nginx.conf
10
- #- file: {{ pillar['etc_dir'] }}nginx/sites-enabled/*
11
- #- file: {{ pillar['etc_dir'] }}nginx/admin.d/*
10
+ - watch:
11
+ - file: enable-admin-site
12
12
  - require:
13
13
  - file.directory: admin-d
14
14
  - pkg: nginx
15
15
 
16
- admin-d:
16
+ www_dir:
17
17
  file.directory:
18
- - name: {{ pillar['etc_dir'] }}nginx/admin.d
18
+ - name: {{ pillar['www_dir'] }}
19
19
  - user: root
20
20
  - group: root
21
- - mode: 755
21
+ - mode: 775
22
+ - makedirs: True
23
+
24
+ admin-d:
25
+ file.recurse:
26
+ - source: salt://www/nginx/etc/nginx/admin.d
27
+ - name: {{ pillar['etc_dir'] }}/nginx/admin.d
28
+ - user: root
29
+ - group: root
30
+ - file_mode: 644
31
+ - dir_mode: 755
32
+ - exclude_pat: '.*swp'
22
33
  - require:
23
34
  - pkg: nginx
24
35
 
25
- # require:
26
- # - file: {{ pillar['etc_dir'] }}nginx/nginx.conf
36
+ admin-conf:
37
+ module.run:
38
+ - name: tls.create_self_signed_cert
39
+ - tls_dir: 'self_signed'
40
+ - emailAddress: "webmaster@{{ pillar['domain'] }}"
41
+ - require:
42
+ - file: admin-d
43
+ file.managed:
44
+ - source: salt://www/nginx/etc/nginx/sites-available/admin.conf
45
+ - name: {{ pillar['etc_dir'] }}/nginx/sites-available/admin.conf
46
+ - user: root
47
+ - group: root
48
+ - template: jinja
49
+ - mode: 644
50
+ - require:
51
+ - module: admin-conf
52
+
53
+ admin-site-templated:
54
+ file.recurse:
55
+ - source: salt://www/nginx/srv/www/admin
56
+ - name: {{ pillar['www_dir'] }}/admin
57
+ - user: root
58
+ - group: root
59
+ - template: jinja
60
+ - include_pat: '*.php'
61
+ - file_mode: 644
62
+ - dir_mode: 755
63
+
64
+ admin-site-raw:
65
+ file.recurse:
66
+ - source: salt://www/nginx/srv/www/admin
67
+ - name: {{ pillar['www_dir'] }}/admin
68
+ - user: root
69
+ - group: root
70
+ - exclude_pat: '*.php'
71
+ - file_mode: 644
72
+ - dir_mode: 755
73
+
74
+ enable-admin-site:
75
+ file.symlink:
76
+ - target: {{ pillar['etc_dir'] }}nginx/sites-available/admin.conf
77
+ - name: {{ pillar['etc_dir'] }}/nginx/sites-enabled/admin.conf
78
+ - require:
79
+ - file: admin-conf
80
+
81
+ {{ pillar['etc_dir'] }}/nginx/admin.d/htpasswd:
82
+ file.managed:
83
+ - contents: "#users that are allowed to access admin website\n"
84
+ - replace: False
85
+ - require:
86
+ - file: admin-d
87
+
88
+ {{ pillar['etc_dir'] }}/nginx/staging_passwd:
89
+ file.managed:
90
+ - contents: "#users that are allowed to access staging website\n"
91
+ - replace: False
92
+ - require:
93
+ - file: admin-d
94
+
95
+ {%- if pillar['admin_password'] %}
96
+
97
+ admin-user:
98
+ cmd.run:
99
+ - name: htpasswd -b {{ pillar['etc_dir'] }}/nginx/admin.d/htpasswd 'admin' '{{ pillar['admin_password'] }}'
100
+ - require:
101
+ - file: {{ pillar['etc_dir'] }}/nginx/admin.d/htpasswd
102
+
103
+ # module.run:
104
+ # - name: apache.useradd
105
+ # - pwfile: {{ pillar['etc_dir'] }}/nginx/admin.d/htpasswd
106
+ # - user: 'admin'
107
+ # - password: '{{ pillar['admin_password'] }}'
108
+ # - require:
109
+ # - file: {{ pillar['etc_dir'] }}/nginx/admin.d/htpasswd
110
+ #
111
+ # Unfortunately this produces an error even when htpasswd is present:
112
+ # State: - module
113
+ # Name: apache.useradd
114
+ # Function: run
115
+ # Result: False
116
+ # Comment: Module function apache.useradd is not available
117
+ # Changes:
27
118
 
28
- #{{ pillar['etc_dir'] }}nginx/nginx.conf:
29
- # file.managed:
30
- # - source: salt://www/nginx/etc/nginx/nginx.conf
31
- # - user: root
32
- # - group: root
33
- # - mode: 644
119
+ {%- endif %}
@@ -0,0 +1,67 @@
1
+ <html><head>
2
+ <title>Admin</title>
3
+ <link rel="shortcut icon" href="/favicon.ico">
4
+ </head><body>
5
+ <h2>Admin functions</h2>
6
+ <ul>
7
+ <?php
8
+ $d = dir("/etc/nginx/admin.d");
9
+ while (false !== ($entry = $d->read())) {
10
+ #echo "<li>Found: " . $entry;
11
+ if (preg_match("/(.*).conf/", $entry, $matches)) {
12
+ echo '<li><a href="/' . $matches[1] . '/">' . $matches[1] . "</a>\n";
13
+ }
14
+ }
15
+ $d->close();
16
+ ?>
17
+ <li><a href="phpinfo.php">phpinfo</a>
18
+ </ul>
19
+
20
+ <h2>localhost port mapping</h2>
21
+
22
+ <ul>
23
+ {%- for port, host_port in pillar['mapped_ports'].items() %}
24
+ <li>
25
+ {%- if port == 22 %}
26
+ <i>ssh localhost -p {{ host_port }}</i> mapped to ssh port {{ port }}
27
+ {%- else %}
28
+ {%- if (port == 443) or (port == 880 and pillar['admin_password']) %}
29
+ <a href="https://localhost:{{ host_port }}/">https://localhost:{{ host_port }}/</a> -
30
+ {%- else %}
31
+ <a href="http://localhost:{{ host_port }}/">http://localhost:{{ host_port }}/</a> -
32
+ {%- endif %}
33
+ {%- if port == 80 %}
34
+ main site (production via cap deploy)
35
+ {%- elif port == 443 %}
36
+ main secure site (production via cap deploy)
37
+ {%- elif port == 880 %}
38
+ this admin site
39
+ {%- elif port == 3000 %}
40
+ rails app (development mode)
41
+ {%- else %}
42
+ other app
43
+ {%- endif %}
44
+ {%- if (port == 443) or (port == 880 and pillar['admin_password']) %}
45
+ on port <a href="https://localhost:{{ port }}">{{ port }}</a>
46
+ {%- else %}
47
+ on port <a href="http://localhost:{{ port }}">{{ port }}</a>
48
+ {%- endif %}
49
+ {%- endif %}
50
+ {%- endfor %}
51
+ </ul>
52
+
53
+ <h2>Roles</h2>
54
+ <ul>
55
+ {%- for role in pillar['roles'] %}
56
+ <li>{{ role }}
57
+ {%- endfor %}
58
+ </ul>
59
+
60
+ <h2>Versions</h2>
61
+ <ul>
62
+ {%- for app in pillar['versions'] %}
63
+ <li>{{ app }}: {{ pillar['versions'][app] }}
64
+ {%- endfor %}
65
+ </ul>
66
+
67
+ </body></html>
@@ -0,0 +1,3 @@
1
+ <?
2
+ phpinfo();
3
+ ?>
@@ -0,0 +1,2 @@
1
+ User-agent: *
2
+ Disallow: /
@@ -1,12 +1,3 @@
1
- {{ pillar['www_dir'] }}:
2
- file.directory:
3
- - user: www-data
4
- - group: www-data
5
- - mode: 775
6
- - makedirs: True
7
- - require:
8
- - group: www-data
9
- - user: www-data
10
1
 
11
2
  www-data:
12
3
  group.present:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: salted-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-09 00:00:00.000000000 Z
12
+ date: 2013-10-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -69,20 +69,19 @@ files:
69
69
  - pillar/common.sls
70
70
  - pillar/vagrant.sls
71
71
  - pillar/vagrant/top.sls
72
+ - salt/apt/load_packages.sls
72
73
  - salt/apt/partner-sources.sls
73
74
  - salt/apt/unwanted.sls
75
+ - salt/apt/update_packages.sls
74
76
  - salt/bin/change_mirror.sh
75
- - salt/bin/fix_hostname.sh
77
+ - salt/bin/misc_fixes.sh
76
78
  - salt/bin/provision
77
- - salt/capistrano/deploy_requirements.sls
78
79
  - salt/capistrano/minion
79
80
  - salt/capistrano/minion.sls
80
- - salt/capistrano/top.sls
81
81
  - salt/ci/cruisecontrolrb.sls
82
82
  - salt/ci/teamcity/etc/init.d/teamcity
83
83
  - salt/ci/teamcity/init.sls
84
84
  - salt/crons/init.sls
85
- - salt/databases/client.sls
86
85
  - salt/databases/init.sls
87
86
  - salt/databases/mysql/client-encoding-and-collation.cnf
88
87
  - salt/databases/mysql/client.sls
@@ -94,27 +93,32 @@ files:
94
93
  - salt/databases/mysql/init.sls
95
94
  - salt/databases/mysql/server-encoding-and-collation.cnf
96
95
  - salt/databases/mysql/server.sls
96
+ - salt/databases/packages.sls
97
97
  - salt/databases/phpmyadmin/etc/nginx/admin.d/phpmyadmin.conf
98
98
  - salt/databases/phpmyadmin/init.sls
99
- - salt/databases/server.sls
99
+ - salt/databases/postgresql/client.sls
100
+ - salt/databases/postgresql/init.sls
101
+ - salt/databases/sqlite3.sls
102
+ - salt/databases/sqlitebrowser.sls
100
103
  - salt/editors/gvim.sls
101
104
  - salt/editors/rubymine.sls
102
105
  - salt/editors/vim/init.sls
103
106
  - salt/editors/vim/vimrc
104
- - salt/gui/init.sls
107
+ - salt/gui/desktop.sls
105
108
  - salt/gui/lxde.sls
106
109
  - salt/gui/x2go.sls
107
110
  - salt/lang/java/etc/profile.d/java.sh
108
111
  - salt/lang/java/init.sls
112
+ - salt/lang/jenv.sls
109
113
  - salt/lang/php/composer.sls
110
114
  - salt/lang/php/etc/php5/fpm/php.fpm.ini
111
115
  - salt/lang/php/etc/php5/fpm/pool.d/www.conf
112
116
  - salt/lang/php/init.sls
113
117
  - salt/lang/php/nginx.sls
118
+ - salt/lang/phpenv.sls
114
119
  - salt/lang/python/python-libs.sls
120
+ - salt/lang/rbenv.sls
115
121
  - salt/lang/ruby.sls
116
- - salt/lang/ruby.sls.bak
117
- - salt/lang/system_ruby.sls
118
122
  - salt/munin/files/nginx/plugin-conf.d/nginx
119
123
  - salt/munin/files/nginx/plugins/nginx_combined_localhost
120
124
  - salt/munin/files/nginx/plugins/nginx_request
@@ -131,6 +135,9 @@ files:
131
135
  - salt/munin/node.sls
132
136
  - salt/munin/php5-fpm.sls
133
137
  - salt/munin/server.sls
138
+ - salt/net/hosts.sls
139
+ - salt/net/ntp.sls
140
+ - salt/net/ufw.sls
134
141
  - salt/railsapp/gems.sls
135
142
  - salt/railsapp/init.sls
136
143
  - salt/railsapp/mysql_database.sls
@@ -141,24 +148,38 @@ files:
141
148
  - salt/salt/minion/lsb.sls
142
149
  - salt/salt/minion/mysql.conf
143
150
  - salt/salt/minion/mysql.sls
151
+ - salt/scm/bazaar.sls
152
+ - salt/scm/git/gitconfig
153
+ - salt/scm/git/init.sls
154
+ - salt/scm/init.sls
155
+ - salt/scm/mercurial.sls
156
+ - salt/scm/subversion.sls
144
157
  - salt/server/monit.sls
145
158
  - salt/server/sudo/init.sls
146
159
  - salt/server/sudo/sudoers
147
- - salt/sysutils/file.sls
148
- - salt/sysutils/init.sls
149
- - salt/sysutils/net.sls
150
- - salt/sysutils/status.sls
151
- - salt/sysutils/tmux.sls
160
+ - salt/top.sls
161
+ - salt/utils/file.sls
162
+ - salt/utils/html.sls
163
+ - salt/utils/init.sls
164
+ - salt/utils/net.sls
165
+ - salt/utils/status.sls
166
+ - salt/utils/tmux/home/tmux-dev
167
+ - salt/utils/tmux/home/tmux.conf
168
+ - salt/utils/tmux/init.sls
152
169
  - salt/vagrant/minion
153
170
  - salt/vagrant/minion.sls
154
- - salt/vagrant/top.sls
155
- - salt/www/admin/etc/nginx/nginx.conf
156
- - salt/www/admin/etc/nginx/sites-available/.gitignore
157
- - salt/www/admin/etc/nginx/sites-available/phpmyadmin.conf
158
- - salt/www/admin/init.sls
159
171
  - salt/www/chromium.sls
172
+ - salt/www/nginx/etc/nginx/admin.d/doc.conf
173
+ - salt/www/nginx/etc/nginx/admin.d/nginx_status.conf
160
174
  - salt/www/nginx/etc/nginx/nginx.conf
175
+ - salt/www/nginx/etc/nginx/sites-available/.gitignore
176
+ - salt/www/nginx/etc/nginx/sites-available/admin.conf
161
177
  - salt/www/nginx/init.sls
178
+ - salt/www/nginx/srv/www/admin/favicon.ico
179
+ - salt/www/nginx/srv/www/admin/favicon.png
180
+ - salt/www/nginx/srv/www/admin/index.php
181
+ - salt/www/nginx/srv/www/admin/phpinfo.php
182
+ - salt/www/nginx/srv/www/admin/robots.txt
162
183
  - salt/www/users.sls
163
184
  - salted-rails.gemspec
164
185
  homepage: https://github.com/ianheggie/salted-rails
@@ -1,6 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # Removes domain from /etc/hostname
4
-
5
- sed -i "s@\..*\$@@" /etc/hostname
6
- hostname -F /etc/hostname
@@ -1,5 +0,0 @@
1
- deploy:
2
- pkg.installed:
3
- - pkgs:
4
- - git
5
-
@@ -1,4 +0,0 @@
1
- base:
2
- '*':
3
- - TODO.SETUP.CAPISTRANO
4
-
@@ -1,18 +0,0 @@
1
-
2
- include:
3
- # MySQL
4
- {%- if ('mysql' in pillar['gems']) or ('mysql2' in pillar['gems']) %}
5
- - databases.mysql.client
6
- {%- endif %}
7
- # PostgreSQL - TODO main alternative to mysql
8
- # MongoDB - TODO Document database
9
- # CouchDB - TODO json web distributed db
10
- # Redis - TODO key value store
11
- # Riak - TODO Distributed fault tolerant DB
12
- # RabbitMQ - TODO message broker software
13
- # Memcached - TODO Memory cache
14
- # Cassandra - TODO distributed database management system
15
- # Neo4J - TODO Graph database
16
- # ElasticSearch - TODO search and analytics engine
17
- # Kestrel - TODO light-weight persistent message queue
18
- # SQLite3 - Included by default