main.yml 2.19 KB
---
# tasks file for redis-cluster

# install redis server

- name: Ensure libselinux-python is installed
  yum:
    name: libselinux-python
    state: installed
    update_cache: yes

- name: Check if redis already installed
  stat: path=/Data/local/redis/bin/redis-server
  register: redis_binary

- name: Check if twemproxy already installed
  stat: path=/Data/local/twemproxy/sbin/nutcracker
  register: nutcracker_binary

- name: Upload redis source package
  copy:
    src: "redis-3.2.12.tar.gz"
    dest: "/root/redis-3.2.12.tar.gz"
    mode: 0755
  when: redis_binary.stat.exists == False

- name: Upload twemproxy source package
  copy:
    src: "nutcracker-0.4.1.tar.gz"
    dest: "/root/nutcracker-0.4.1.tar.gz"
    mode: 0755
  when: nutcracker_binary.stat.exists == False


- name: Make sure autoconf268 utils installed
  yum:
    name: autoconf268,automake,libtool,gcc
    state: installed
    update_cache: yes
  when: not dc == "aws"

- name: Make sure autoconf utils installed
  yum:
    name: autoconf,automake,libtool,gcc
    state: installed
    update_cache: yes
  when: dc == "aws"


- name: Decompress and install redis
  shell: cd /root/ && mkdir -p /Data/local/ && tar -zxvf redis-3.2.12.tar.gz && cd redis-3.2.12 && make MALLOC=libc && make PREFIX=/Data/local/redis install && mkdir -p /Data/local/redis/conf /Data/logs/redis/ /Data/local/redis/data
  when: redis_binary.stat.exists == False

- name: Update redis configuration file
  template:
    src: "redis.conf.j2"
    dest: "/Data/local/redis/conf/redis.conf"
  notify:
    - stop redis
    - start redis

- name: set autoconf binary file
  set_fact:
    autoreconf: 'autoconf'
  when: dc == "aws"

- name: set autoconfa68 binary file
  set_fact:
    autoreconf: 'autoconf268 -ivf'
  when: not dc == "aws"

- name: Install twemproxy
  shell: cd /root/ && tar -zxvf nutcracker-0.4.1.tar.gz && cd nutcracker-0.4.1 && {{ autoreconf }} && ./configure --prefix=/Data/local/twemproxy && make && make install && mkdir -p /Data/local/twemproxy/conf
  when: nutcracker_binary.stat.exists == False

- name: Update twemproxy configuration file
  template:
    src: "nutcracker.yml.j2"
    dest: "/Data/local/twemproxy/conf/nutcracker.yml"
  notify:
    - start nutcracker