danarchy_deploy 0.2.6 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.asdf_versions.json +5 -0
  3. data/.tool-versions +1 -0
  4. data/CHANGELOG.md +15 -0
  5. data/Gemfile.lock +9 -8
  6. data/danarchy_deploy.gemspec +4 -4
  7. data/lib/danarchy_deploy/groups.rb +0 -1
  8. data/lib/danarchy_deploy/services/init/openrc.rb +10 -6
  9. data/lib/danarchy_deploy/services/init.rb +28 -18
  10. data/lib/danarchy_deploy/services.rb +0 -1
  11. data/lib/danarchy_deploy/system/centos.rb +7 -0
  12. data/lib/danarchy_deploy/system/debian.rb +6 -0
  13. data/lib/danarchy_deploy/system/gentoo.rb +83 -23
  14. data/lib/danarchy_deploy/system/opensuse.rb +6 -0
  15. data/lib/danarchy_deploy/system.rb +22 -10
  16. data/lib/danarchy_deploy/templater.rb +26 -9
  17. data/lib/danarchy_deploy/users.rb +50 -42
  18. data/lib/danarchy_deploy/version.rb +1 -1
  19. data/lib/danarchy_deploy.rb +61 -19
  20. data/templates/applications/nginx/domain.conf.erb +38 -0
  21. data/templates/applications/php/phpfpm.conf.erb +19 -0
  22. data/templates/applications/php/user.conf.erb +19 -0
  23. data/templates/applications/wordpress/mysql_user_privileges.sql.erb +2 -0
  24. data/templates/applications/wordpress/wp-config.php.erb +82 -0
  25. data/templates/asdf/asdf.sh.erb +52 -0
  26. data/templates/deploy_template.json +76 -50
  27. data/templates/distcc/distccd.erb +14 -0
  28. data/templates/distcc/hosts.erb +2 -0
  29. data/templates/portage/make.conf.erb +30 -0
  30. data/templates/portage/package.use/bindist +3 -0
  31. data/templates/portage/package.use/documentation +3 -0
  32. data/templates/services/memcached/memcached.erb +40 -0
  33. data/templates/services/mysql/my.cnf.erb +143 -0
  34. data/templates/services/mysql/root_my.cnf.erb +11 -0
  35. data/templates/services/mysql/user_db_grants.sql.erb +33 -0
  36. data/templates/services/mysql/user_db_grants.sql.erb_cleanupUsers +52 -0
  37. data/templates/services/nginx/nginx.conf.erb +48 -0
  38. data/templates/services/php/php-fpm.conf.erb +2 -0
  39. data/templates/services/postfix/localmail.initial_setup.sh +19 -0
  40. data/templates/services/postfix/localmail.main.cf.erb +41 -0
  41. data/templates/services/postfix/mailname.erb +1 -0
  42. data/templates/services/postfix/mailrelayhost_main.cf.erb +33 -0
  43. data/templates/services/postfix/main.cf.erb +28 -0
  44. data/templates/services/postfix/master.cf.erb +124 -0
  45. data/templates/services/postfix/mysql-virtual-alias-maps.cf.erb +5 -0
  46. data/templates/services/postfix/mysql-virtual-mailbox-domains.cf.erb +5 -0
  47. data/templates/services/postfix/mysql-virtual-mailbox-maps.cf.erb +5 -0
  48. data/templates/system/authorized_keys.erb +5 -0
  49. data/templates/system/crontab.erb +8 -0
  50. data/templates/system/dmcrypt.erb +17 -0
  51. data/templates/system/exports.erb +4 -0
  52. data/templates/system/fstab.erb +4 -0
  53. data/templates/system/sudoers.erb +5 -0
  54. metadata +44 -11
  55. data/.ruby-gemset +0 -1
  56. data/.ruby-version +0 -1
  57. /data/bin/{setup → setup-dd} +0 -0
@@ -1,40 +1,66 @@
1
1
  {
2
2
  "hostname": "hostname",
3
- "os": "gentoo|debian|ubuntu",
4
- "ipv4": "IPv4 to use for deployment",
5
- "ssh_user": "deploy-user",
6
- "ssh_key": "/home/path/to/deploy-user/ssh_key.",
3
+ "os": "gentoo || debian || fedora || ubuntu || opensuse",
4
+ "ipv4": "IPv4 to use for remote deployment",
5
+ "ssh_user": "ssh-user",
6
+ "ssh_key": "/home/path/to/ssh-user/ssh_key.",
7
7
  "packages": [
8
8
  "package1",
9
9
  "package2"
10
10
  ],
11
- "users": [
12
- {
13
- "username": "username",
11
+ "system": {
12
+ "update": "true || all || system || selected || none || false",
13
+ "fstab": {
14
+ "source": "builtin::system/fstab_gentoo_client.erb",
15
+ "mounts": [
16
+ {
17
+ "filesystem": "/",
18
+ "mountpoint": "/dev/sda3",
19
+ "type": "ext4",
20
+ "opts": "defaults,noatime",
21
+ "dump/pass": "0 0"
22
+ }
23
+ ]
24
+ }
25
+ },
26
+ "portage": {
27
+ "sync": false,
28
+ "templates": [
29
+ {
30
+ "target": "/etc/portage/make.conf",
31
+ "source": "builtin::portage/make.conf.erb",
32
+ "variables": {
33
+ "use": "bindist logrotate",
34
+ "features": "distcc"
35
+ }
36
+ }
37
+ ]
38
+ },
39
+ "users": {
40
+ "username": {
14
41
  "home": "/home/username",
15
42
  "uid": int,
16
43
  "gid": int,
17
- "sudoer": "username ALL = NOPASSWD: ALL",
18
- "ssh-authorized_keys": [
19
- "ssh-ed25519 it0C5o6GHC8lxqctpexakfdA5o7LeSe+QbMhIl+GYtZ2OCMFliLsODDrrazR+u2y user@hostname",
20
- "ssh-rsa K0APeEvotGunpBrl/LvSAG/gLUldCnOrL60v47QYjuqoGJmM3Fk8V29+8jZPp9Dl user@hostname"
44
+ "sudoer": ["username ALL=(ALL) NOPASSWD:ALL"],
45
+ "authorized_keys": [
46
+ "ssh-ed25519 it0C5o6GHC8lxqctpexakfdA5o7LeSe+QbMhIl+GYtZ2OCMFliLsODDrrazR+u2y user@hostname",
47
+ "ssh-rsa K0APeEvotGunpBrl/LvSAG/gLUldCnOrL60v47QYjuqoGJmM3Fk8V29+8jZPp9Dl user@hostname"
21
48
  ],
22
49
  "groups": [
23
- int,
24
- int
50
+ int
25
51
  ],
26
52
  "archives": [
27
- {
28
- "target": "/path/to/extract/to/",
29
- "source": "/path/to/tarball.(tar.{gz,bz2}|zip)"
30
- },
31
- {
32
- "target": "/path/to/extract/to/",
33
- "data": "couchdb:base64_encoded_data"
34
- }
53
+ {
54
+ "target": "/path/to/extract/to/",
55
+ "source": "/path/to/tarball.(tar.{gz,bz2}|zip)"
56
+ },
57
+ {
58
+ "target": "/path/to/extract/to/",
59
+ "data": "couchdb::base64_encoded_data"
60
+ }
35
61
  ]
36
62
  }
37
- ],
63
+ },
38
64
  "groups": [
39
65
  {
40
66
  "groupname": "groupname",
@@ -50,48 +76,48 @@
50
76
  ]
51
77
  },
52
78
  "archives": [
53
- {
54
- "target": "/path/to/extract/to/",
55
- "source": "/path/to/tarball.(tar.{gz,bz2}|zip)"
56
- },
57
- {
58
- "target": "/path/to/extract/to/",
59
- "data": "couchdb:base64_encoded_data"
60
- }
79
+ {
80
+ "target": "/path/to/extract/to/",
81
+ "source": "/path/to/tarball.(tar.{gz,bz2}|zip)"
82
+ },
83
+ {
84
+ "target": "/path/to/extract/to/",
85
+ "data": "couchdb::base64_encoded_data"
86
+ }
61
87
  ],
62
88
  "templates": [
63
- {
64
- "target": "/path/to/target/file",
65
- "source": "/path/to/source/erb",
66
- "dir_perms": {
89
+ {
90
+ "target": "/path/to/target/file",
91
+ "source": "/path/to/source/erb",
92
+ "dir_perms": {
67
93
  "owner": "username",
68
94
  "group": "groupname",
69
95
  "mode": "0755"
70
- },
71
- "file_perms": {
96
+ },
97
+ "file_perms": {
72
98
  "owner": "username",
73
99
  "group": "groupname",
74
100
  "mode": "0644"
75
- },
76
- "variables": {
77
- "var1": "value",
78
- "var2": "value"
79
- }
80
- },
81
- {
82
- "target": "/path/to/target/file",
83
- "data": "couchdb:base64_encoded_erb",
84
- "dir_perms": {
101
+ },
102
+ "variables": {
103
+ "var1": "value",
104
+ "var2": "value"
105
+ }
106
+ },
107
+ {
108
+ "target": "/path/to/target/file",
109
+ "data": "couchdb::base64_encoded_erb",
110
+ "dir_perms": {
85
111
  "owner": "username",
86
112
  "group": "groupname",
87
113
  "mode": "0755"
88
- },
89
- "file_perms": {
114
+ },
115
+ "file_perms": {
90
116
  "owner": "username",
91
117
  "group": "groupname",
92
118
  "mode": "0644"
93
- }
94
- }
119
+ }
120
+ }
95
121
  ]
96
122
  }
97
123
  }
@@ -0,0 +1,14 @@
1
+ # Deployed by dAnarchy_deploy: /etc/conf.d/distccd: config file for /etc/init.d/distccd
2
+
3
+ # this is the distccd executable
4
+ DISTCCD_EXEC="/usr/bin/distccd"
5
+
6
+ # this is where distccd will store its pid file
7
+ DISTCCD_PIDFILE="/var/run/distccd/distccd.pid"
8
+
9
+ <%= @variables[:opts] ? 'DISTCCD_OPTS=' + "\"#{@variables[:opts]}\"" : 'DISTCCD_OPTS=""' %>
10
+ <%= @variables[:port] ? 'DISTCCD_OPTS=' + "\"${DISTCCD_OPTS} --port #{@variables[:port]}\"" : 'DISTCCD_OPTS="${DISTCCD_OPTS} --port 3632"' %>
11
+ <%= @variables[:loglevel] ? 'DISTCCD_OPTS=' + "\"${DISTCCD_OPTS} --log-level #{@variables[:loglevel]}\"" : 'DISTCCD_OPTS="${DISTCCD_OPTS} --log-level critical"' %>
12
+ <%= @variables[:allow] ? 'DISTCCD_OPTS=' + "\"${DISTCCD_OPTS} --allow #{@variables[:allow]}\"" : '' %>
13
+ <%= @variables[:listen] ? 'DISTCCD_OPTS=' + "\"${DISTCCD_OPTS} --listen #{@variables[:listen]}\"" : '' %>
14
+ <%= @variables[:nice] ? 'DISTCCD_OPTS=' + "\"${DISTCCD_OPTS} -N #{@variables[:nice]}\"" : '' %>
@@ -0,0 +1,2 @@
1
+ # Deployed by dAnarchy_deploy: /etc/distcc/hosts
2
+ <%= @variables[:hosts] ? "#{@variables[:hosts]}" : 'localhost' -%>
@@ -0,0 +1,30 @@
1
+ # Deployed by dAnarchy_deploy: /etc/portage/make.conf
2
+ COMMON_FLAGS="-march=<%= `gcc -march=native -Q --help=target | grep march`.split[1] %> -O2 -pipe"
3
+ CFLAGS="${COMMON_FLAGS}"
4
+ CXXFLAGS="${COMMON_FLAGS}"
5
+ FCFLAGS="${COMMON_FLAGS}"
6
+ FFLAGS="${COMMON_FLAGS}"
7
+
8
+ MAKEOPTS="-j<%= `nproc`.to_i * 2 + 1 %> -l<%= `nproc`.to_i %>"
9
+ CPU_FLAGS_X86="<%= `cpuid2cpuflags`.split(': ').last.chomp %>"
10
+
11
+ <% if !@variables -%>
12
+ USE="bindist logrotate"
13
+ INPUT_DEVICES="evdev keyboard"
14
+ <% else -%>
15
+ <%= @variables[:use] ? 'USE=' + "\"bindist logrotate #{@variables[:use]}\"\n" : "USE=\"bindist logrotate\"\n" -%>
16
+ <%= @variables[:grub] ? 'GRUB_PLATFORMS=' + "\"#{@variables[:grub]}\"\n" : '' -%>
17
+ <%= @variables[:ruby] ? 'RUBY_TARGETS=' + "\"#{@variables[:ruby]}\"\n" : '' -%>
18
+ <%= @variables[:php] ? 'PHP_TARGETS=' + "\"#{@variables[:php]}\"\n" : '' -%>
19
+ <%= @variables[:features] ? 'FEATURES=' + "\"#{@variables[:features]}\"\n" : '' -%>
20
+ <%= @variables[:videocards] ? 'VIDEO_CARDS=' + "\"#{@variables[:videocards]}\"\n" : '' -%>
21
+ <%= @variables[:input] ? 'INPUT_DEVICES=' + "\"#{@variables[:input]}\"\n" : "INPUT_DEVICES=\"evdev keyboard\"\n" -%>
22
+ <% end -%>
23
+
24
+ # This sets the language of build output to English.
25
+ # Please keep this setting intact when reporting bugs.
26
+ LC_MESSAGES=C
27
+
28
+ PORTDIR="/var/db/repos/gentoo"
29
+ DISTDIR="/var/cache/distfiles"
30
+ PKGDIR="/var/cache/binpkgs"
@@ -0,0 +1,3 @@
1
+ # Allow EC algorithms in OpenSSL/OpenSSH (patents blocked with bindist)
2
+ dev-libs/openssl -bindist
3
+ net-misc/openssh -bindist
@@ -0,0 +1,3 @@
1
+ dev-lang/perl doc
2
+ dev-lang/python doc
3
+ dev-lang/ruby doc
@@ -0,0 +1,40 @@
1
+ # memcached config file
2
+
3
+ MEMCACHED_BINARY="/usr/bin/memcached"
4
+
5
+ # Specify memory usage in megabytes (do not use letters)
6
+ # 64MB is default
7
+ MEMUSAGE="64"
8
+
9
+ # User to run as
10
+ MEMCACHED_RUNAS="memcached"
11
+
12
+ # Specify maximum number of concurrent connections
13
+ # 1024 is default
14
+ MAXCONN="1024"
15
+
16
+ # Listen for connections on what address?
17
+ # If this is empty, memcached will listen on 0.0.0.0
18
+ # be sure you have a firewall in place!
19
+ LISTENON="<%= (@variables && @variables[:listenon]) ? @variables[:listenon] : '127.0.0.1' %>"
20
+
21
+ # Listen for connections on what port?
22
+ PORT="<%= (@variables && @variables[:port]) ? @variables[:port] : '11211' %>"
23
+
24
+ # Listen for UDP connecitons on what port? 0 means turn off UDP
25
+ UDPPORT="${PORT}"
26
+
27
+ # PID file location
28
+ # '-${PORT}.${CONF}.pid' will be appended to this!
29
+ # You do not normally need to change this.
30
+ PIDBASE="/var/run/memcached/memcached"
31
+
32
+ # Socket to listen on
33
+ #SOCKET="/var/run/memcached/memcached.sock"
34
+
35
+ # Socket mask
36
+ # 0700 is default
37
+ #SOCKET_MASK="0700"
38
+
39
+ # Other Options
40
+ MISC_OPTS=""
@@ -0,0 +1,143 @@
1
+ # /etc/mysql/my.cnf: The global mysql configuration file.
2
+
3
+ # The following options will be passed to all MySQL clients
4
+ [client]
5
+ #password = your_password
6
+ port = 3306
7
+ socket = /var/run/mysqld/mysqld.sock
8
+
9
+ [mysql]
10
+ character-sets-dir=/usr/share/mariadb/charsets
11
+ default-character-set=utf8
12
+
13
+ [mysqladmin]
14
+ character-sets-dir=/usr/share/mariadb/charsets
15
+ default-character-set=utf8
16
+
17
+ [mysqlcheck]
18
+ character-sets-dir=/usr/share/mariadb/charsets
19
+ default-character-set=utf8
20
+
21
+ [mysqldump]
22
+ character-sets-dir=/usr/share/mariadb/charsets
23
+ default-character-set=utf8
24
+
25
+ [mysqlimport]
26
+ character-sets-dir=/usr/share/mariadb/charsets
27
+ default-character-set=utf8
28
+
29
+ [mysqlshow]
30
+ character-sets-dir=/usr/share/mariadb/charsets
31
+ default-character-set=utf8
32
+
33
+ [myisamchk]
34
+ character-sets-dir=/usr/share/mariadb/charsets
35
+
36
+ [myisampack]
37
+ character-sets-dir=/usr/share/mariadb/charsets
38
+
39
+ # use [safe_mysqld] with mysql-3
40
+ [mysqld_safe]
41
+ err-log = /var/log/mysql/mysqld.err
42
+
43
+ # add a section [mysqld-4.1] or [mysqld-5.0] for specific configurations
44
+ [mysqld]
45
+ expire_logs_days = 30
46
+ character-set-server = utf8
47
+ user = mysql
48
+ port = 3306
49
+ socket = /var/run/mysqld/mysqld.sock
50
+ pid-file = /var/run/mysqld/mysqld.pid
51
+ log-error = /var/log/mysql/mysqld.err
52
+ basedir = /usr
53
+ datadir = <%= @variables[:datadir] ? @variables[:datadir] : '/var/lib/mysql' %>
54
+ skip-external-locking
55
+ key_buffer_size = 16M
56
+ max_allowed_packet = 4M
57
+ table_open_cache = 400
58
+ sort_buffer_size = 512K
59
+ net_buffer_length = 16K
60
+ read_buffer_size = 256K
61
+ read_rnd_buffer_size = 512K
62
+ myisam_sort_buffer_size = 8M
63
+ lc_messages_dir = /usr/share/mariadb
64
+ #Set this to your desired error message language
65
+ lc_messages = en_US
66
+
67
+ # security:
68
+ # using "localhost" in connects uses sockets by default
69
+ # skip-networking
70
+ bind-address = <%= @variables[:bind_address] ? @variables[:bind_address] : '127.0.0.1' %>
71
+ skip-name-resolve
72
+
73
+ log-bin = /var/log/mysql/mysql-bin.log
74
+ binlog_format = MIXED
75
+ binlog_expire_logs_seconds = 604800 # 7 days binlogs
76
+ server-id = 1
77
+
78
+ # point the following paths to different dedicated disks
79
+ tmpdir = /tmp/
80
+ #log-update = /path-to-dedicated-directory/hostname
81
+
82
+ # you need the debug USE flag enabled to use the following directives,
83
+ # if needed, uncomment them, start the server and issue
84
+ # #tail -f /tmp/mysqld.sql /tmp/mysqld.trace
85
+ # this will show you *exactly* what's happening in your server ;)
86
+
87
+ #log = /tmp/mysqld.sql
88
+ #gdb
89
+ #debug = d:t:i:o,/tmp/mysqld.trace
90
+ #one-thread
91
+
92
+ # the rest of the innodb config follows:
93
+ # don't eat too much memory, we're trying to be safe on 64Mb boxes
94
+ # you might want to bump this up a bit on boxes with more RAM
95
+ innodb_buffer_pool_size = 128M
96
+ #
97
+ # i'd like to use /var/lib/mysql/innodb, but that is seen as a database :-(
98
+ # and upstream wants things to be under /var/lib/mysql/, so that's the route
99
+ # we have to take for the moment
100
+ #innodb_data_home_dir = /var/lib/mysql/
101
+ #innodb_log_arch_dir = /var/lib/mysql/
102
+ #innodb_log_group_home_dir = /var/lib/mysql/
103
+ # you may wish to change this size to be more suitable for your system
104
+ # the max is there to avoid run-away growth on your machine
105
+ innodb_data_file_path = ibdata1:10M:autoextend:max:128M
106
+ # we keep this at around 25% of of innodb_buffer_pool_size
107
+ # sensible values range from 1MB to (1/innodb_log_files_in_group*innodb_buffer_pool_size)
108
+ innodb_log_file_size = 48M
109
+ # this is the default, increase it if you have very large transactions going on
110
+ innodb_log_buffer_size = 8M
111
+ # see the innodb config docs, the other options are not always safe
112
+ innodb_flush_log_at_trx_commit = 1
113
+ innodb_lock_wait_timeout = 50
114
+ innodb_file_per_table
115
+
116
+ # Uncomment this to get FEDERATED engine support
117
+ #plugin-load=federated=ha_federated.so
118
+ #loose-federated
119
+
120
+ [mysqldump]
121
+ quick
122
+ max_allowed_packet = 16M
123
+
124
+ [mysql]
125
+ # uncomment the next directive if you are not familiar with SQL
126
+ #safe-updates
127
+
128
+ [isamchk]
129
+ key_buffer_size = 20M
130
+ sort_buffer_size = 20M
131
+ read_buffer = 2M
132
+ write_buffer = 2M
133
+
134
+ [myisamchk]
135
+ key_buffer_size = 20M
136
+ sort_buffer_size = 20M
137
+ read_buffer_size = 2M
138
+ write_buffer_size = 2M
139
+
140
+ [mysqlhotcopy]
141
+ interactive-timeout
142
+
143
+ [mariadb]
@@ -0,0 +1,11 @@
1
+ [mysql]
2
+ <%= @variables[:host] ? "host=\"#{@variables[:host]}\"\n" : '' -%>
3
+ <%= @variables[:user] ? "user=\"#{@variables[:user]}\"\n" : '' -%>
4
+ <%= @variables[:pass] ? "password=\"#{@variables[:pass]}\"\n" : '' -%>
5
+ <%= @variables[:port] ? "port=\"#{@variables[:port]}\"\n" : '' -%>
6
+
7
+ [client]
8
+ <%= @variables[:host] ? "host=\"#{@variables[:host]}\"\n" : '' -%>
9
+ <%= @variables[:user] ? "user=\"#{@variables[:user]}\"\n" : '' -%>
10
+ <%= @variables[:pass] ? "password=\"#{@variables[:pass]}\"\n" : '' -%>
11
+ <%= @variables[:port] ? "port=\"#{@variables[:port]}\"\n" : '' -%>
@@ -0,0 +1,33 @@
1
+ DROP DATABASE IF EXISTS test;
2
+
3
+ <% @variables.each do |mysql| -%>
4
+ <% if mysql[:action] == 'grant' -%>
5
+
6
+ CREATE DATABASE IF NOT EXISTS `<%= mysql[:database] %>`;
7
+ GRANT <%= mysql[:grants].join(', ') %>
8
+ ON `<%= mysql[:database] %>`.*
9
+ TO `<%= mysql[:user] %>`@`<%= mysql[:host] %>`
10
+ IDENTIFIED BY '<%= DanarchyDeploy::Helpers.decode_base64(mysql[:password]) %>';
11
+
12
+ <% elsif mysql[:action] == 'revoke' -%>
13
+
14
+ REVOKE <%= mysql[:grants].join(', ') %>
15
+ ON `<%= mysql[:database] %>`.*
16
+ FROM `<%= mysql[:user] %>`@`<%= mysql[:host] %>`;
17
+
18
+ <% elsif mysql[:action] == 'drop' %>
19
+
20
+ DROP DATABASE IF EXISTS <%= mysql[:database] %>;
21
+ REVOKE ALL PRIVILEGES
22
+ ON `<%= mysql[:database] %>`.*
23
+ FROM `<%= mysql[:user] %>`@`<%= mysql[:host] %>`;
24
+ DROP USER `<%= mysql[:user] %>`;
25
+
26
+ <% elsif mysql[:action] == 'dropuser' %>
27
+
28
+ DROP USER IF EXISTS `<%= mysql[:user] %>`@`<%= mysql[:host] %>`;
29
+
30
+ <% end -%>
31
+ <% end -%>
32
+
33
+ FLUSH PRIVILEGES;
@@ -0,0 +1,52 @@
1
+ DROP DATABASE IF EXISTS test;
2
+
3
+ <% @variables.each do |mysql| -%>
4
+ <% if mysql[:action] == 'grant' -%>
5
+
6
+ CREATE DATABASE IF NOT EXISTS `<%= mysql[:database] %>`;
7
+ GRANT <%= mysql[:grants].join(', ') %>
8
+ ON `<%= mysql[:database] %>`.*
9
+ TO `<%= mysql[:user] %>`@`<%= mysql[:host] %>`
10
+ IDENTIFIED BY '<%= DanarchyDeploy::Helpers.decode_base64(mysql[:password]) %>';
11
+
12
+ <% elsif mysql[:action] == 'revoke' -%>
13
+
14
+ REVOKE <%= mysql[:grants].join(', ') %>
15
+ ON `<%= mysql[:database] %>`.*
16
+ FROM `<%= mysql[:user] %>`@`<%= mysql[:host] %>`;
17
+
18
+ <% elsif mysql[:action] == 'drop' %>
19
+
20
+ DROP DATABASE IF EXISTS <%= mysql[:database] %>;
21
+ REVOKE ALL PRIVILEGES
22
+ ON `<%= mysql[:database] %>`.*
23
+ FROM `<%= mysql[:user] %>`@`<%= mysql[:host] %>`;
24
+ DROP USER `<%= mysql[:user] %>`;
25
+
26
+ <% elsif mysql[:action] == 'dropuser' %>
27
+
28
+ DROP USER IF EXISTS `<%= mysql[:user] %>`@`<%= mysql[:host] %>`;
29
+
30
+ <% end -%>
31
+
32
+ # Cleanup user privileges without grants
33
+ SET @keep_hosts = NULL;
34
+ SELECT GROUP_CONCAT(Host) INTO @keep_hosts
35
+ FROM (
36
+ SELECT Host FROM mysql.db
37
+ WHERE User = '<%= mysql[:user] %>'
38
+ UNION
39
+ SELECT Host FROM mysql.tables_priv
40
+ WHERE User = '<%= mysql[:user] %>'
41
+ ) AS T;
42
+
43
+ SET @drop_users = SELECT GROUP_CONCAT('\'', user, '\'@\'', host, '\'') FROM mysql.user
44
+ WHERE User = '<%= mysql[:user] %>'
45
+ AND NOT FIND_IN_SET(Host, @keep_hosts);
46
+ PREPARE stmt1 FROM @drop_users;
47
+ EXECUTE stmt1;
48
+ DEALLOCATE PREPARE stmt1;
49
+
50
+ <% end -%>
51
+
52
+ FLUSH PRIVILEGES;
@@ -0,0 +1,48 @@
1
+ user <%= @variables[:web_user] ? @variables[:web_user] : 'nginx' %>;
2
+ worker_processes auto;
3
+
4
+ error_log /var/log/nginx/error_log info;
5
+
6
+ events {
7
+ worker_connections 1024;
8
+ use epoll;
9
+
10
+ }
11
+
12
+ http {
13
+ include /etc/nginx/mime.types;
14
+ default_type text/html;
15
+
16
+ log_format main
17
+ '$remote_addr - $remote_user [$time_local] '
18
+ '"$request" $status $bytes_sent '
19
+ '"$http_referer" "$http_user_agent" '
20
+ '"$gzip_ratio"';
21
+
22
+ client_header_timeout 10m;
23
+ client_body_timeout 10m;
24
+ client_max_body_size <%= @variables[:client_max_body_size] ? @variables[:client_max_body_size] : '32mm' %>;
25
+ send_timeout 10m;
26
+
27
+ connection_pool_size 256;
28
+ client_header_buffer_size 1k;
29
+ large_client_header_buffers 4 2k;
30
+ request_pool_size 4k;
31
+
32
+ gzip on;
33
+
34
+ output_buffers 1 32k;
35
+ postpone_output 1460;
36
+
37
+ sendfile on;
38
+ tcp_nopush on;
39
+ tcp_nodelay on;
40
+
41
+ keepalive_timeout 75 20;
42
+
43
+ ignore_invalid_headers on;
44
+
45
+ index index.html;
46
+
47
+ include /home/*/nginx/sites-enabled/*.conf;
48
+ }
@@ -0,0 +1,2 @@
1
+ [Global]
2
+ include=/home/*/php-fpm/sites-enabled/*.conf
@@ -0,0 +1,19 @@
1
+ #!/bin/bash
2
+
3
+ if [[ ${UID} != 0 ]]; then
4
+ echo 'Run this script as root!'
5
+ exit 1
6
+ fi
7
+
8
+ postfix upgrade-configuration
9
+ postfix check
10
+
11
+ newaliases
12
+
13
+ if [[ $(which rc-service) ]]; then
14
+ rc-service postfix restart
15
+ elif [[ $(which systemctl) ]]; then
16
+ systemctl restart postfix
17
+ else
18
+ echo 'Unable to determine init system! Restart postfix manually.'
19
+ fi
@@ -0,0 +1,41 @@
1
+
2
+ compatibility_level = 3.8
3
+
4
+
5
+ queue_directory = /var/spool/postfix
6
+ command_directory = /usr/sbin
7
+ daemon_directory = /usr/libexec/postfix
8
+ data_directory = /var/lib/postfix
9
+
10
+ mail_owner = postfix
11
+ myhostname = localhost
12
+ mydomain = localdomain
13
+
14
+ inet_interfaces = $myhostname, localhost
15
+ mydestination = $myhostname, localhost.$mydomain, localhost
16
+
17
+ unknown_local_recipient_reject_code = 550
18
+ mynetworks_style = host
19
+ default_transport = error:outside mail is not deliverable
20
+
21
+ debug_peer_level = 2
22
+ debugger_command =
23
+ PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
24
+ ddd $daemon_directory/$process_name $process_id & sleep 5
25
+
26
+
27
+ sendmail_path = /usr/sbin/sendmail
28
+ newaliases_path = /usr/bin/newaliases
29
+ mailq_path = /usr/bin/mailq
30
+
31
+ setgid_group = postdrop
32
+ html_directory = no
33
+
34
+ manpage_directory = /usr/share/man
35
+ sample_directory = /etc/postfix
36
+
37
+ readme_directory = no
38
+ inet_protocols = ipv4
39
+ shlib_directory = /usr/lib64/postfix/${mail_version}
40
+ meta_directory = /etc/postfix
41
+ home_mailbox = .maildir/
@@ -0,0 +1 @@
1
+ <%= @variables[:hostname] %>
@@ -0,0 +1,33 @@
1
+ smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
2
+ biff = no
3
+
4
+ # appending .domain is the MUA's job.
5
+ append_dot_mydomain = no
6
+
7
+ # Uncomment the next line to generate \"delayed mail\" warnings
8
+ #delay_warning_time = 4h
9
+
10
+ readme_directory = no
11
+
12
+ # TLS parameters
13
+ smtpd_tls_cert_file = <%= @variables[:ssl_cert] %>
14
+ smtpd_tls_key_file = <%= @variables[:ssl_key] %>
15
+ smtpd_use_tls = <%= @variables[:use_tls] || 'yes' %>
16
+ smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
17
+ smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
18
+
19
+ # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
20
+ # information on enabling SSL in the smtp client.
21
+
22
+ smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
23
+ myhostname = <%= @variables[:hostname] %>
24
+ alias_maps = hash:/etc/aliases
25
+ alias_database = hash:/etc/aliases
26
+ myorigin = /etc/mailname
27
+ mydestination = <%= @variables[:hostname] %>, localhost
28
+ relayhost = <%= @variables[:relayhost] %>
29
+ mynetworks = <%= @variables[:mynetworks] %> 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
30
+ mailbox_size_limit = 0
31
+ recipient_delimiter = +
32
+ inet_interfaces = all
33
+ inet_protocols = ipv4