123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- ---
- - hosts: all
- become: yes
- become_user: root
- become_method: sudo
- gather_facts: yes
- vars:
- consul_ui: true
- consul_server: true
- consul_server_nodes:
- - 10.161.8.1
- - 10.161.16.94
- - 10.161.13.176
- - 10.161.14.88
- - 10.161.18.146
- redis_ports:
- - 19901
- - 19902
- - 19903
- - 19904
- - 19905
- - 19906
- - 19907
- - 19908
- - 19909
- - 19910
- - 19911
- - 19912
- handlers:
- - name: restart_consul
- service:
- name: consul
- state: restarted
- - name: reload_redis_services
- command: systemctl daemon-reload
- - name: restart_redis_services
- systemd:
- name: "redis-{{ item }}"
- state: restarted
- with_items: "{{ redis_ports }}"
-
-
-
- pre_tasks:
- - name: Update Apt Cache
- apt: update_cache=yes cache_valid_time=86400
- when: ansible_os_family == "Debian"
- - name: Ubuntu Packages
- apt: >
- pkg={{item}}
- state=present
- with_items:
- - build-essential
- - autoconf
- - automake
- - libbsd-dev
- - libltdl-dev
- - libltdl7
- - libtool
- tasks:
- - name: create redis user
- user:
- name: redis
- uid: 4001
- shell: /bin/bash
- state: present
- - name: copy the redis raft library
- copy:
- src: redisraft.so
- dest: /usr/lib/redisraft.so
- owner: redis
- group: redis
- mode: '0755'
- notify:
- - restart_redis_services
- - name: create raft directories
- file:
- path: /redis/persistant/cpredis
- owner: redis
- group: redis
- mode: '0755'
- state: directory
- - name: create raft directories
- file:
- path: /var/log/cpredis
- owner: redis
- group: redis
- mode: '0755'
- state: directory
- - name: checkout redis git repo
- git:
- repo: 'https://github.com/antirez/redis'
- dest: /home/redis/redis
- version: 6.0
- - name: Build the default target
- make:
- chdir: /home/redis/redis
- - name: Run 'install' target as root
- make:
- chdir: /home/redis/redis
- target: install
- become: yes
- - name: Redis Systemd
- template:
- src: systemd_redis.j2
- dest: /lib/systemd/system/redis-{{item}}.service
- owner: root
- group: root
- mode: 0644
- with_items: "{{ redis_ports }}"
- notify:
- - reload_redis_services
- - restart_redis_services
- - name: Enable Redis Services
- systemd:
- name: redis-{{item}}
- enabled: yes
- state: started
- with_items: "{{ redis_ports }}"
- roles:
- - consul
- - ntp
- post_tasks:
- - name: Redis Consul Services
- template:
- src: redis.services.j2
- dest: /opt/consul/consul.d/redis.json
- owner: consul
- group: consul
- mode: 0644
- notify:
- - restart_consul
|