mimas-redis 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/mimas/plugins/redis/commands/configure.rb +25 -0
- data/lib/mimas/plugins/redis/commands/console.rb +22 -0
- data/lib/mimas/plugins/redis/commands/install.rb +25 -0
- data/lib/mimas/plugins/redis/commands/setup.rb +26 -0
- data/lib/mimas/plugins/redis/version.rb +7 -0
- data/lib/mimas/plugins/redis.rb +21 -0
- data/lib/mimas/plugins/server/console.rb +14 -0
- data/lib/mimas/plugins/server/redis.rb +39 -0
- data/lib/mimas/plugins/templates/redis/01-mimas.conf +8 -0
- data/lib/mimas-redis.rb +12 -0
- metadata +63 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 453433f59421c48919c0e7739c16025fcfccd455e6cc96a994cdcbbd93373409
|
|
4
|
+
data.tar.gz: ccbb11bd186784e5b52a1280de67aaade7e420f1007b2de4964c93c2c7ebaf58
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 45a41d9072a450c4fc0ff879610dc98f4b8d6af2ec82425cd1f226ef2d6225530439864fb03cf4c0c4e4eabf19e44bfecb7740dc18158c14d087d482890a5d8b
|
|
7
|
+
data.tar.gz: 33f3b8fb0d77a83eb5bea67bf603673cc99beed5742f69b27aa37e83624ed5f44832fabdc006cabae60a7f90fb73190ca5bb13be4d0878b8e993af2ff0a7ab0a
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Mimas
|
|
2
|
+
module Plugins
|
|
3
|
+
module Redis
|
|
4
|
+
module Commands
|
|
5
|
+
class Configure < Mimas::CLI::Commands::BaseCommand
|
|
6
|
+
desc "Install configuration files for Redis."
|
|
7
|
+
|
|
8
|
+
argument :server_name, required: true, desc: "The name of the server to install Redis on"
|
|
9
|
+
|
|
10
|
+
option :user, default: "admin", aliases: ["-u"], desc: "A user with sudo access"
|
|
11
|
+
|
|
12
|
+
def call(server_name:, **options)
|
|
13
|
+
server = Config.current.servers[server_name.to_sym]
|
|
14
|
+
sudo_user = options[:user]
|
|
15
|
+
|
|
16
|
+
server.configure_redis(sudo_user: sudo_user)
|
|
17
|
+
|
|
18
|
+
say ""
|
|
19
|
+
say "Redis has been configured! 🎉"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Mimas
|
|
2
|
+
module Plugins
|
|
3
|
+
module Redis
|
|
4
|
+
module Commands
|
|
5
|
+
class Console < Mimas::CLI::Commands::BaseCommand
|
|
6
|
+
desc "Start the Redis console."
|
|
7
|
+
|
|
8
|
+
argument :server_name, required: true, desc: "The name of the server"
|
|
9
|
+
|
|
10
|
+
option :user, default: "admin", aliases: ["-u"], desc: "A user with sudo access"
|
|
11
|
+
|
|
12
|
+
def call(server_name:, **options)
|
|
13
|
+
server = Config.current.servers[server_name.to_sym]
|
|
14
|
+
sudo_user = options[:user]
|
|
15
|
+
|
|
16
|
+
server.start_redis_console(sudo_user: sudo_user)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Mimas
|
|
2
|
+
module Plugins
|
|
3
|
+
module Redis
|
|
4
|
+
module Commands
|
|
5
|
+
class Install < Mimas::CLI::Commands::BaseCommand
|
|
6
|
+
desc "Install Redis on the server."
|
|
7
|
+
|
|
8
|
+
argument :server_name, required: true, desc: "The name of the server to install Redis on"
|
|
9
|
+
|
|
10
|
+
option :user, default: "admin", aliases: ["-u"], desc: "A user with sudo access"
|
|
11
|
+
|
|
12
|
+
def call(server_name:, **options)
|
|
13
|
+
server = Config.current.servers[server_name.to_sym]
|
|
14
|
+
sudo_user = options[:user]
|
|
15
|
+
|
|
16
|
+
server.install_redis(sudo_user: sudo_user)
|
|
17
|
+
|
|
18
|
+
say ""
|
|
19
|
+
say "Redis has been installed! 🎉"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Mimas
|
|
2
|
+
module Plugins
|
|
3
|
+
module Redis
|
|
4
|
+
module Commands
|
|
5
|
+
class Setup < Mimas::CLI::Commands::BaseCommand
|
|
6
|
+
desc "Install and configure Redis on the server."
|
|
7
|
+
|
|
8
|
+
argument :server_name, required: true, desc: "The name of the server to setup Redis on"
|
|
9
|
+
|
|
10
|
+
option :user, default: "admin", aliases: ["-u"], desc: "A user with sudo access"
|
|
11
|
+
|
|
12
|
+
def call(server_name:, **options)
|
|
13
|
+
server = Config.current.servers[server_name.to_sym]
|
|
14
|
+
sudo_user = options[:user]
|
|
15
|
+
|
|
16
|
+
server.install_redis(sudo_user: sudo_user)
|
|
17
|
+
server.configure_redis(sudo_user: sudo_user)
|
|
18
|
+
|
|
19
|
+
say ""
|
|
20
|
+
say "Redis has been installed and configured! 🎉"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Mimas
|
|
2
|
+
module Plugins
|
|
3
|
+
module Redis
|
|
4
|
+
extend self
|
|
5
|
+
|
|
6
|
+
def register_commands(cli)
|
|
7
|
+
cli.register "redis" do |redis|
|
|
8
|
+
redis.register "install", Commands::Install
|
|
9
|
+
redis.register "configure", Commands::Configure
|
|
10
|
+
redis.register "setup", Commands::Setup
|
|
11
|
+
redis.register "console", Commands::Console
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
TEMPLATES_DIR = Pathname.new(__dir__).join("templates")
|
|
16
|
+
def templates_dir
|
|
17
|
+
TEMPLATES_DIR
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Mimas
|
|
2
|
+
module Plugins
|
|
3
|
+
module Server
|
|
4
|
+
module RedisConsole
|
|
5
|
+
def start_redis_console(sudo_user:)
|
|
6
|
+
command = "sudo -u redis redis-cli -s /run/redis/redis-server.sock"
|
|
7
|
+
interactive_ssh(host, user: sudo_user, command: command)
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
::Mimas::Server.include Mimas::Plugins::Server::RedisConsole
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Mimas
|
|
2
|
+
module Plugins
|
|
3
|
+
module Server
|
|
4
|
+
module Redis
|
|
5
|
+
def install_redis(sudo_user:)
|
|
6
|
+
ssh(self, user: sudo_user) do |session|
|
|
7
|
+
session.run "sudo apt-get install redis-server -y"
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def configure_redis(sudo_user:)
|
|
12
|
+
config_destination = Pathname.new("/").join("etc", "redis", "conf.d")
|
|
13
|
+
|
|
14
|
+
ssh(self, user: sudo_user) do |session|
|
|
15
|
+
session.run "sudo -u redis mkdir -p #{config_destination}"
|
|
16
|
+
|
|
17
|
+
config_files = find_files("redis/*.conf")
|
|
18
|
+
tmp_dir = Pathname.new("/").join("tmp", "redis")
|
|
19
|
+
|
|
20
|
+
session.run "mkdir -p #{tmp_dir}"
|
|
21
|
+
|
|
22
|
+
config_files.each do |file_path|
|
|
23
|
+
file_name = Pathname.new(file_path).basename
|
|
24
|
+
session.upload file_path, tmp_dir.join(file_name)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
session.run "sudo rsync --archive --recursive --chown=redis:redis #{tmp_dir.join("*")} #{config_destination}"
|
|
28
|
+
session.run "rm -rf #{tmp_dir}"
|
|
29
|
+
session.run "sudo -u redis bash -c \"echo -e '\n\ninclude /etc/redis/conf.d/*.conf' >> /etc/redis/redis.conf\""
|
|
30
|
+
|
|
31
|
+
session.run "sudo systemctl restart redis"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
::Mimas::Server.include Mimas::Plugins::Server::Redis
|
data/lib/mimas-redis.rb
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require "mimas"
|
|
2
|
+
|
|
3
|
+
require_relative "mimas/plugins/redis"
|
|
4
|
+
require_relative "mimas/plugins/server/redis"
|
|
5
|
+
require_relative "mimas/plugins/server/console"
|
|
6
|
+
|
|
7
|
+
require_relative "mimas/plugins/redis/commands/install"
|
|
8
|
+
require_relative "mimas/plugins/redis/commands/configure"
|
|
9
|
+
require_relative "mimas/plugins/redis/commands/setup"
|
|
10
|
+
require_relative "mimas/plugins/redis/commands/console"
|
|
11
|
+
|
|
12
|
+
Mimas::Plugins.register(Mimas::Plugins::Redis)
|
metadata
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: mimas-redis
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ayush Newatia
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: mimas
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0.6'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0.6'
|
|
26
|
+
email: ayush@hey.com
|
|
27
|
+
executables: []
|
|
28
|
+
extensions: []
|
|
29
|
+
extra_rdoc_files: []
|
|
30
|
+
files:
|
|
31
|
+
- lib/mimas-redis.rb
|
|
32
|
+
- lib/mimas/plugins/redis.rb
|
|
33
|
+
- lib/mimas/plugins/redis/commands/configure.rb
|
|
34
|
+
- lib/mimas/plugins/redis/commands/console.rb
|
|
35
|
+
- lib/mimas/plugins/redis/commands/install.rb
|
|
36
|
+
- lib/mimas/plugins/redis/commands/setup.rb
|
|
37
|
+
- lib/mimas/plugins/redis/version.rb
|
|
38
|
+
- lib/mimas/plugins/server/console.rb
|
|
39
|
+
- lib/mimas/plugins/server/redis.rb
|
|
40
|
+
- lib/mimas/plugins/templates/redis/01-mimas.conf
|
|
41
|
+
homepage: https://codeberg.org/ayushn21/mimas-redis
|
|
42
|
+
licenses:
|
|
43
|
+
- MIT
|
|
44
|
+
metadata:
|
|
45
|
+
mimas_plugin: 'true'
|
|
46
|
+
rdoc_options: []
|
|
47
|
+
require_paths:
|
|
48
|
+
- lib
|
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: 3.4.0
|
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
|
+
requirements:
|
|
56
|
+
- - ">="
|
|
57
|
+
- !ruby/object:Gem::Version
|
|
58
|
+
version: '0'
|
|
59
|
+
requirements: []
|
|
60
|
+
rubygems_version: 4.0.18
|
|
61
|
+
specification_version: 4
|
|
62
|
+
summary: Install and manage Redis using Mimas
|
|
63
|
+
test_files: []
|