standard-procedure-anvil 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50580aabd8ea329997f9a044178f08790aa12719e6d412da4a6a7a3b6c335fff
4
- data.tar.gz: c4ec1dbbd6ccc1945e6fab5f76f988578bd0df0cef15cc7801b2bbdfda5f6a30
3
+ metadata.gz: 7ce4bfd700a5d2b870087b7d983902c43bc377ebcba1abbb911caea507aba0e8
4
+ data.tar.gz: 4e902474667b96efaf5a86435b381f6e54f28d58a1ae6a216441d9de6eb35925
5
5
  SHA512:
6
- metadata.gz: e39c66044138540191d4214f5fa0b7f46d76f037b5268315f7fdb19cca214e545f93e9d89ce69d939339ca0133b7fa209281a21938ddd976d17e79160bc00167
7
- data.tar.gz: 968a6df094c5f7846c23af2148b04c3671ce15c8abffce3ba407c0e3014aee4bb15e64873a6cfa0287dcd19b6193883efa259b4f8c9eb2b047abb12f6fa5ed95
6
+ metadata.gz: 6a6c16d63f3b0c2bbbafcce079bdb7ba7ea8b44f2c5e0f4ac0f5a9beb3e1f2999852be11aeaed5c107bb88eaef1b7a09b0bf3fef4eaeabb9f5760c625f73c845
7
+ data.tar.gz: ca793262284e8938121d155fe18f0b6c527a50b9bf0bf437f9a3973d02d708060c317ece52f85713913ec0995937a88eb93d58af85293d01abcf50f5005d5493
@@ -0,0 +1,61 @@
1
+ #cloud-config
2
+ users:
3
+ - name: %{USER}
4
+ groups: users, admin, docker
5
+ sudo: ALL=(ALL) NOPASSWD:ALL
6
+ shell: /bin/bash
7
+ ssh_authorized_keys:
8
+ - %{PUBLIC_KEY}
9
+ packages:
10
+ - fail2ban
11
+ - ufw
12
+ - wget
13
+ - apt-transport-https
14
+ - mysql-client
15
+ - libmysqlclient-dev
16
+ package_update: true
17
+ package_upgrade: true
18
+ runcmd:
19
+ # General server setup
20
+ - timedatectl set-timezone UTC
21
+ # Install MySQL
22
+ - echo "mysql-server mysql-server/root_password password root" | sudo debconf-set-selections
23
+ - echo "mysql-server mysql-server/root_password_again password root" | sudo debconf-set-selections
24
+ - sudo apt-get -y install mysql-server
25
+ - |
26
+ cat >> /etc/mysql/mysql.conf.d/utf8.cnf << CONF
27
+ [client]
28
+ default-character-set=utf8mb4
29
+
30
+ [mysql]
31
+ default-character-set=utf8mb4
32
+
33
+ [mysqld]
34
+ init_connect='SET collation_connection = utf8mb4_unicode_ci'
35
+ init_connect='SET NAMES utf8mb4'
36
+ character-set-server=utf8mb4
37
+ collation-server=utf8mb4_unicode_ci
38
+ skip-character-set-client-handshake
39
+ CONF
40
+ - sed -i -e '/^\(#\|\)bind-address/s/^.*$/bind-address = 0.0.0.0/' /etc/mysql/mysql.conf.d/mysqld.cnf
41
+ # Start MySQL
42
+ - systemctl start mysql.service
43
+ # Fail2Ban setup
44
+ - printf "[sshd]\nenabled = true\nbanaction = iptables-multiport" > /etc/fail2ban/jail.local
45
+ - systemctl enable fail2ban
46
+ # UFW and SSH setup
47
+ - ufw allow 22/tcp
48
+ - ufw allow 80/tcp
49
+ - ufw allow 443/tcp
50
+ - ufw enable
51
+ # Harden SSH
52
+ - sed -i -e '/^\(#\|\)PermitRootLogin/s/^.*$/PermitRootLogin no/' /etc/ssh/sshd_config
53
+ - sed -i -e '/^\(#\|\)PasswordAuthentication/s/^.*$/PasswordAuthentication no/' /etc/ssh/sshd_config
54
+ - sed -i -e '/^\(#\|\)X11Forwarding/s/^.*$/X11Forwarding no/' /etc/ssh/sshd_config
55
+ - sed -i -e '/^\(#\|\)MaxAuthTries/s/^.*$/MaxAuthTries 2/' /etc/ssh/sshd_config
56
+ - sed -i -e '/^\(#\|\)AllowTcpForwarding/s/^.*$/AllowTcpForwarding no/' /etc/ssh/sshd_config
57
+ - sed -i -e '/^\(#\|\)AllowAgentForwarding/s/^.*$/AllowAgentForwarding no/' /etc/ssh/sshd_config
58
+ - sed -i -e '/^\(#\|\)AuthorizedKeysFile/s/^.*$/AuthorizedKeysFile .ssh\/authorized_keys/' /etc/ssh/sshd_config
59
+ - sed -i '$a AllowUsers %{USER} dokku' /etc/ssh/sshd_config
60
+ # And we're done
61
+ - reboot
@@ -33,16 +33,5 @@ runcmd:
33
33
  - sed -i -e '/^\(#\|\)AllowAgentForwarding/s/^.*$/AllowAgentForwarding no/' /etc/ssh/sshd_config
34
34
  - sed -i -e '/^\(#\|\)AuthorizedKeysFile/s/^.*$/AuthorizedKeysFile .ssh\/authorized_keys/' /etc/ssh/sshd_config
35
35
  - sed -i '$a AllowUsers %{USER} dokku' /etc/ssh/sshd_config
36
- # Dokku setup
37
- - echo "dokku dokku/vhost_enable boolean true" | sudo debconf-set-selections
38
- - wget https://dokku.com/install/v0.30.7/bootstrap.sh && sudo DOKKU_TAG=v0.30.7 bash bootstrap.sh
39
- - cat /home/%{USER}/.ssh/authorized_keys | dokku ssh-keys:add admin
40
- - dokku plugin:install https://github.com/dokku/dokku-cron-restart.git cron-restart
41
- - dokku plugin:install https://github.com/dokku/dokku-maintenance.git maintenance
42
- - dokku plugin:install https://github.com/dokku/dokku-redis.git redis
43
- - dokku plugin:install https://github.com/dokku/dokku-mariadb.git mariadb
44
- - dokku plugin:install https://github.com/dokku/dokku-memcached.git memcached
45
- - dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git letsencrypt
46
- - dokku config:set --global DOKKU_LETSENCRYPT_EMAIL=sysadmin@echodek.co
47
- - dokku git:set --global deploy-branch main
36
+ # And we're done
48
37
  - reboot
@@ -0,0 +1,13 @@
1
+ # SSH into your server and paste the script
2
+ sudo bash
3
+ echo "dokku dokku/vhost_enable boolean true" | sudo debconf-set-selections
4
+ wget https://dokku.com/install/v0.30.7/bootstrap.sh && sudo DOKKU_TAG=v0.30.7 bash bootstrap.sh
5
+ cat /home/app/.ssh/authorized_keys | dokku ssh-keys:add admin
6
+ dokku plugin:install https://github.com/dokku/dokku-cron-restart.git cron-restart
7
+ dokku plugin:install https://github.com/dokku/dokku-maintenance.git maintenance
8
+ dokku plugin:install https://github.com/dokku/dokku-redis.git redis
9
+ dokku plugin:install https://github.com/dokku/dokku-memcached.git memcached
10
+ dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git letsencrypt
11
+ dokku config:set --global DOKKU_LETSENCRYPT_EMAIL=sysadmin@echodek.co
12
+ dokku git:set --global deploy-branch main
13
+ exit
@@ -0,0 +1 @@
1
+ 185f01d498e635d91fcbc77ae60a47529b68f927302c67dc7b052a4b190d6aa1197c9c7d46d9626f927ea80b5d40162ed3e86177d63d5dbcd93b957dbf4238b7
@@ -0,0 +1 @@
1
+ 11a59b33098151fd6205adbd24c410acd58168066dc2942b93feb601557f527fecce250002d6157bacf0007a546a4a23abdc219f269bc73820236cae738b63a0
@@ -5,11 +5,13 @@ module Anvil
5
5
  require_relative "../logger"
6
6
  require_relative "../ssh_executor"
7
7
  require_relative "env"
8
+ require_relative "../configuration_reader"
8
9
  class App
9
10
  class HostInstaller < Struct.new(:configuration, :host, :secrets)
10
11
  include StandardProcedure::Async::Actor
12
+ include Anvil::ConfigurationReader
11
13
 
12
- async :call do
14
+ def call
13
15
  Anvil::SshExecutor.new(host, user_for(host), logger).call do |ssh|
14
16
  create_app ssh
15
17
  set_environment ssh
@@ -32,8 +34,13 @@ module Anvil
32
34
  ssh.exec! "dokku docker-options:add app run \"--add-host=host.docker.internal:host-gateway\"", "set_dokku_options"
33
35
  ssh.exec! "dokku domains:set app #{configuration_for_app["domain"]}", "set_dokku_options"
34
36
  ssh.exec! "dokku proxy:ports-add app http:80:#{configuration_for_app["port"]}", "set_dokku_options"
35
- ssh.exec! "dokku nginx:set app client-max-body-size 512m", "set_dokku_options"
36
- ssh.exec! "dokku nginx:set app proxy-read-timeout 60s", "set_dokku_options"
37
+ ssh.exec! "dokku nginx:set app client-max-body-size #{configuration_for_app["nginx"]["client_max_body_size"]}", "set_dokku_options"
38
+ ssh.exec! "dokku nginx:set app proxy-read-timeout #{configuration_for_app["nginx"]["proxy_read_timeout"]}", "set_dokku_options"
39
+ if configuration_for_app["nginx"]["forward_proxy_headers"]
40
+ ssh.exec! "dokku nginx:set $APP x-forwarded-for-value \"$http_x_forwarded_for\"", "set_dokku_options"
41
+ ssh.exec! "dokku nginx:set $APP x-forwarded-port-value \"$http_x_forwarded_port\"", "set_dokku_options"
42
+ ssh.exec! "dokku nginx:set $APP x-forwarded-proto-value \"$http_x_forwarded_proto\"", "set_dokku_options"
43
+ end
37
44
  ssh.exec! "dokku proxy:build-config app", "set_dokku_options"
38
45
  end
39
46
 
data/lib/anvil/app.rb CHANGED
@@ -6,6 +6,7 @@ require "yaml"
6
6
  module Anvil
7
7
  class App < Anvil::SubCommandBase
8
8
  require_relative "app/env"
9
+ require_relative "app/install"
9
10
 
10
11
  desc "env /path/to/config.yml", "Generate environment variables for an app"
11
12
  long_desc <<-DESC
data/lib/anvil/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Anvil
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.6"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standard-procedure-anvil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rahoul Baruah
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-30 00:00:00.000000000 Z
11
+ date: 2023-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -110,13 +110,16 @@ files:
110
110
  - LICENSE.txt
111
111
  - README.md
112
112
  - Rakefile
113
- - assets/cloudinit/dokku.mysql.opensearch.ubuntu-22.yml
113
+ - assets/cloudinit/dokku.mysql.ubuntu-22.yml
114
114
  - assets/cloudinit/dokku.ubuntu-22.yml
115
115
  - assets/cloudinit/memcached.ubuntu-22.yml
116
116
  - assets/cloudinit/mysql.ubuntu-22.yml
117
117
  - assets/cloudinit/opensearch.ubuntu-22.yml
118
118
  - assets/cloudinit/redis.ubuntu-22.yml
119
+ - assets/install/dokku.txt
119
120
  - checksums/standard-procedure-anvil-0.1.4.gem.sha512
121
+ - checksums/standard-procedure-anvil-0.1.5.gem.sha512
122
+ - checksums/standard-procedure-anvil-0.1.6.gem.sha512
120
123
  - exe/anvil
121
124
  - lib/anvil.rb
122
125
  - lib/anvil/app.rb
@@ -1,126 +0,0 @@
1
- #cloud-config
2
- users:
3
- - name: %{USER}
4
- groups: users, admin, docker
5
- sudo: ALL=(ALL) NOPASSWD:ALL
6
- shell: /bin/bash
7
- ssh_authorized_keys:
8
- - %{PUBLIC_KEY}
9
- packages:
10
- - fail2ban
11
- - ufw
12
- - wget
13
- - apt-transport-https
14
- - docker.io
15
- - docker-compose
16
- - mysql-client
17
- - libmysqlclient-dev
18
- package_update: true
19
- package_upgrade: true
20
- runcmd:
21
- # General server setup
22
- - timedatectl set-timezone UTC
23
- # Prepare for OpenSearch
24
- - swapoff -a
25
- - echo "vm.max_map_count=262144" > /etc/sysctl.d/98-opensearch.conf
26
- - sysctl -p /etc/sysctl.d/98-opensearch.conf
27
- # Install MySQL
28
- - echo "mysql-server mysql-server/root_password password root" | sudo debconf-set-selections
29
- - echo "mysql-server mysql-server/root_password_again password root" | sudo debconf-set-selections
30
- - sudo apt-get -y install mysql-server
31
- - |
32
- cat >> /etc/mysql/mysql.conf.d/utf8.cnf << CONF
33
- [client]
34
- default-character-set=utf8mb4
35
-
36
- [mysql]
37
- default-character-set=utf8mb4
38
-
39
- [mysqld]
40
- init_connect='SET collation_connection = utf8mb4_unicode_ci'
41
- init_connect='SET NAMES utf8mb4'
42
- character-set-server=utf8mb4
43
- collation-server=utf8mb4_unicode_ci
44
- skip-character-set-client-handshake
45
- CONF
46
- - sed -i -e '/^\(#\|\)bind-address/s/^.*$/bind-address = 0.0.0.0/' /etc/mysql/mysql.conf.d/mysqld.cnf
47
- # Start MySQL
48
- - systemctl start mysql.service
49
- # Fail2Ban setup
50
- - printf "[sshd]\nenabled = true\nbanaction = iptables-multiport" > /etc/fail2ban/jail.local
51
- - systemctl enable fail2ban
52
- # UFW and SSH setup
53
- - ufw allow 22/tcp
54
- - ufw allow 80/tcp
55
- - ufw allow 443/tcp
56
- - ufw enable
57
- # Harden SSH
58
- - sed -i -e '/^\(#\|\)PermitRootLogin/s/^.*$/PermitRootLogin no/' /etc/ssh/sshd_config
59
- - sed -i -e '/^\(#\|\)PasswordAuthentication/s/^.*$/PasswordAuthentication no/' /etc/ssh/sshd_config
60
- - sed -i -e '/^\(#\|\)X11Forwarding/s/^.*$/X11Forwarding no/' /etc/ssh/sshd_config
61
- - sed -i -e '/^\(#\|\)MaxAuthTries/s/^.*$/MaxAuthTries 2/' /etc/ssh/sshd_config
62
- - sed -i -e '/^\(#\|\)AllowTcpForwarding/s/^.*$/AllowTcpForwarding no/' /etc/ssh/sshd_config
63
- - sed -i -e '/^\(#\|\)AllowAgentForwarding/s/^.*$/AllowAgentForwarding no/' /etc/ssh/sshd_config
64
- - sed -i -e '/^\(#\|\)AuthorizedKeysFile/s/^.*$/AuthorizedKeysFile .ssh\/authorized_keys/' /etc/ssh/sshd_config
65
- - sed -i '$a AllowUsers %{USER} dokku' /etc/ssh/sshd_config
66
- # Dokku setup
67
- - echo "dokku dokku/vhost_enable boolean true" | sudo debconf-set-selections
68
- - wget https://dokku.com/install/v0.30.7/bootstrap.sh && sudo DOKKU_TAG=v0.30.7 bash bootstrap.sh
69
- - cat /home/%{USER}/.ssh/authorized_keys | dokku ssh-keys:add admin
70
- - dokku plugin:install https://github.com/dokku/dokku-cron-restart.git cron-restart
71
- - dokku plugin:install https://github.com/dokku/dokku-maintenance.git maintenance
72
- - dokku plugin:install https://github.com/dokku/dokku-redis.git redis
73
- - dokku plugin:install https://github.com/dokku/dokku-mariadb.git mariadb
74
- - dokku plugin:install https://github.com/dokku/dokku-memcached.git memcached
75
- - dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git letsencrypt
76
- - dokku config:set --global DOKKU_LETSENCRYPT_EMAIL=sysadmin@echodek.co
77
- - dokku git:set --global deploy-branch main
78
- # OpenSearch setup
79
- - mkdir -p /etc/opensearch
80
- - docker pull opensearchproject/opensearch:latest
81
- - docker pull opensearchproject/opensearch-dashboards:latest
82
- - |
83
- cat >> /etc/opensearch/docker-compose.yml << EOF
84
- version: '3'
85
- services:
86
- search_db:
87
- image: opensearchproject/opensearch:latest
88
- container_name: search_db
89
- environment:
90
- - discovery.type=single-node
91
- - node.name=search_db
92
- - bootstrap.memory_lock=true
93
- - plugins.security.disabled=true
94
- - "OPENSEARCH_JAVA_OPTS=-Xms2048m -Xmx2048m"
95
- ulimits:
96
- memlock:
97
- soft: -1
98
- hard: -1
99
- nofile:
100
- soft: 65536
101
- hard: 65536
102
- volumes:
103
- - opensearch_data:/usr/share/opensearch/data
104
- ports:
105
- - 9200:9200
106
- - 9600:9600
107
- volumes:
108
- opensearch_data:
109
- EOF
110
- - |
111
- cat >> /etc/systemd/system/opensearch.service << EOF
112
- Description=OpenSearch container
113
- Requires=docker.service
114
- After=docker.service
115
- [Service]
116
- WorkingDirectory=/etc/opensearch
117
- Restart=always
118
- ExecStart=/usr/bin/docker-compose up
119
- ExecStop=/usr/bin/docker-compose down
120
- [Install]
121
- WantedBy=multi-user.target
122
- EOF
123
- - systemctl daemon-reload
124
- - systemctl enable opensearch.service
125
- - service opensearch start
126
- - reboot