Module: Enscalator::Plugins::Redis

Includes:
Ubuntu
Defined in:
lib/enscalator/plugins/redis.rb

Overview

Redis on EC2 instance

Constant Summary

Constants included from Ubuntu

Ubuntu::ARCH, Ubuntu::RELEASE, Ubuntu::STORAGE

Instance Method Summary collapse

Methods included from Ubuntu

get_mapping, #ubuntu_init

Instance Method Details

#redis_init(instance_name, key_name:, instance_type: 't2.medium') ⇒ Object

Create new Redis instance

Parameters:

  • instance_name (String)

    instance name

  • key_name (String)

    instance key

  • instance_type (String) (defaults to: 't2.medium')

    instance type



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/enscalator/plugins/redis.rb', line 12

def redis_init(instance_name,
               key_name:,
               instance_type: 't2.medium')

  parameter "Ubuntu#{instance_name}KeyName",
            Default: key_name,
            Description: 'Keypair name',
            Type: 'String'

  ubuntu_init instance_name, instance_type: instance_type, properties: { 'UserData' => redis_user_data }
end

#redis_user_dataString

Install and run Redis on EC2 instance

Returns:

  • (String)

    user-data



26
27
28
29
30
31
32
33
34
35
# File 'lib/enscalator/plugins/redis.rb', line 26

def redis_user_data
  Base64.encode64(%(
    #!/usr/bin/env bash
    apt-get update
    apt-get upgrade -y
    apt-get install -y redis-server
    sed -i 's/bind 127.0.0.1/bind 0.0.0.0/' /etc/redis/redis.conf
    service redis-server restart
  ).gsub(/^\s+/, ''))
end