Browse Source

setup using the ansible

Chris Mague 4 years ago
parent
commit
ef5737fa1a
2 changed files with 80 additions and 0 deletions
  1. 58 0
      packaging/tests/install.yml
  2. 22 0
      packaging/tests/templates/systemd_redis.j2

+ 58 - 0
packaging/tests/install.yml

@@ -0,0 +1,58 @@
+---
+
+- hosts: all
+  become: yes
+  become_user: root
+  become_method: sudo
+  gather_facts: yes
+
+  vars:
+    redis_ports:
+      - {"port": 19901, "start-hslot": 0, "end-hslot": 1365}
+      - {"port": 19902, "start-hslot": 1366, "end-hslot": 2730}
+      - {"port": 19903, "start-hslot": 2731, "end-hslot": 4096}
+      - {"port": 19904, "start-hslot": 4097, "end-hslot": 5460}
+      - {"port": 19905, "start-hslot": 5461, "end-hslot": 6826}
+      - {"port": 19906, "start-hslot": 6827, "end-hslot": 8191}
+      - {"port": 19907, "start-hslot": 8192, "end-hslot": 9557}
+      - {"port": 19908, "start-hslot": 9558, "end-hslot": 10921}
+      - {"port": 19909, "start-hslot": 10922, "end-hslot": 12287}
+      - {"port": 19910, "start-hslot": 12288, "end-hslot": 13651}
+      - {"port": 19911, "start-hslot": 13652, "end-hslot": 15017}
+      - {"port": 19912, "start-hslot": 15018, "end-hslot": 16383}
+
+  handlers:
+    - name: reload_redis_services
+      command: systemctl daemon-reload
+    - name: restart_redis_services
+      systemd:
+        name: "redis-{{ item['port'] }}"
+        state: restarted
+      with_items: "{{ redis_ports }}"
+
+  pre_tasks:
+
+    - name: Get the Redisraft package
+      copy:
+        src: redisraft_0.0.1_x86_64.rpm
+        dest: /tmp/redisraft_0.0.1_x86_64.rpm
+
+    - name: Install the Redisraft package
+      yum:
+        name: /tmp/redisraft_0.0.1_x86_64.rpm
+        state: present
+
+  tasks:
+
+    - name: Redis Systemd
+      template:
+        src: systemd_redis.j2
+        dest: /lib/systemd/system/redis-{{ item['port'] }}.service
+        owner: root
+        group: root
+        mode: 0644
+      with_items: "{{ redis_ports }}"
+      notify:
+        - reload_redis_services
+        - restart_redis_services
+

+ 22 - 0
packaging/tests/templates/systemd_redis.j2

@@ -0,0 +1,22 @@
+#####################################################################
+# {{ ansible_managed }}
+# {{ item['port'] }}
+
+#####################################################################
+[Unit]
+Description=Redis Server Port {{ item['port'] }}
+After=network.target
+
+[Service]
+WorkingDirectory=/opt/cpredis
+Type=simple
+LimitNOFILE=65535
+User=redis
+ExecStart=/usr/local/bin/redis-server --port {{ item['port'] }} --protected-mode no --dbfilename {{ item['port'] }}-redis.rdb --loadmodule /usr/local/share/redisraft/redisraft.so addr={{ ansible_default_ipv4.address }}:{{ item['port'] }} raft-log-fsync=no follower-proxy=no raftize-all-commands=yes cluster-start-hslot={{ item['start-hslot'] }} cluster-end-hslot={{ item['end-hslot'] }} raft-log-filename={{ item['port'] }}-raftlog.db cluster-mode=yes
+StandardOutput=file:/var/log/cpredis/redis-{{ item['port'] }}.log
+StandardError=file:/var/log/cpredis/redis-{{ item['port'] }}-error.log
+
+
+[Install]
+WantedBy=multi-user.target
+Alias=redis-{{ item['port'] }}.service