##############################################################################
# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
---
- name: "stop redis server"
  service:
    name: "redis-server"
    state: "stopped"

- name: "modify redis server configuration"
  replace:
    dest: "/etc/redis/redis.conf"
    regexp: "{{ item.regexp }}"
    replace: "{{ item.replace }}"
  with_items:
    - { regexp: "^\\s*bind", replace: "#bind" }
    - { regexp: "^\\s*save", replace: "#save" }
    - { regexp: "^\\s*dbfilename", replace: "#dbfilename" }
    - { regexp: "^\\s*lua-time-limit\\s*\\d*", replace: "lua-time-limit 15000" }

- name: "delete redis dump"
  file:
    dest: "/var/lib/redis/dump.rdb"
    state: "absent"

- name: "start redis server"
  service:
    name: "redis-server"
    state: "started"