From 824a17ad4d2e20cd390070e0c6f0d0b9f9ab931d Mon Sep 17 00:00:00 2001 From: Salt Date: Sun, 26 Apr 2020 01:22:36 -0500 Subject: [PATCH] Move Redis into its own role --- roles/gitlab/meta/main.yml | 4 +++ roles/gitlab/tasks/main.yml | 31 ------------------- roles/redis/handlers/main.yml | 8 +++++ roles/redis/meta/main.yml | 2 ++ roles/redis/tasks/main.yml | 31 +++++++++++++++++++ roles/redis/templates/main.cf | 5 +++ .../templates}/redis-tmpfile.conf | 0 .../files => redis/templates}/redis.conf | 0 8 files changed, 50 insertions(+), 31 deletions(-) create mode 100644 roles/redis/handlers/main.yml create mode 100644 roles/redis/meta/main.yml create mode 100644 roles/redis/tasks/main.yml create mode 100644 roles/redis/templates/main.cf rename roles/{gitlab/files => redis/templates}/redis-tmpfile.conf (100%) rename roles/{gitlab/files => redis/templates}/redis.conf (100%) diff --git a/roles/gitlab/meta/main.yml b/roles/gitlab/meta/main.yml index d5f3152..a341ca7 100644 --- a/roles/gitlab/meta/main.yml +++ b/roles/gitlab/meta/main.yml @@ -3,3 +3,7 @@ allow_duplicates: no dependencies: - role: apache-php - role: mysql + - role: redis + - role: postfix-null + vars: + postfix_domain: {{ gitlab_url }} diff --git a/roles/gitlab/tasks/main.yml b/roles/gitlab/tasks/main.yml index 8da3590..27614bd 100644 --- a/roles/gitlab/tasks/main.yml +++ b/roles/gitlab/tasks/main.yml @@ -52,37 +52,6 @@ - runit - yarn - zlib1g-dev - - name: Install and configure Redis - block: - - name: Install packages - apt: - name: "redis-server" - register: repo2 - - name: Disable service - service: - name: redis-server - state: stopped - when: repo2 is changed - - name: Copy config - copy: - src: redis.conf - dest: "/etc/redis/redis.conf" - - name: Copy tmpfiles config - copy: - src: redis-tmpfile.conf - dest: "/etc/tmpfiles.d/redis.conf" - - name: Create socket directory - file: - path: "/var/run/redis" - state: directory - mode: 755 - owner: redis - group: redis - - name: Enable and start service - service: - name: redis-server - state: started - enabled: yes - name: Add gitlab user user: name: git diff --git a/roles/redis/handlers/main.yml b/roles/redis/handlers/main.yml new file mode 100644 index 0000000..3cbd025 --- /dev/null +++ b/roles/redis/handlers/main.yml @@ -0,0 +1,8 @@ +#!/usr/bin/ansible-playbook +# vim:ft=ansible: +--- +- name: restart redis + service: + name: redis-server + state: restarted + become: yes diff --git a/roles/redis/meta/main.yml b/roles/redis/meta/main.yml new file mode 100644 index 0000000..d098f75 --- /dev/null +++ b/roles/redis/meta/main.yml @@ -0,0 +1,2 @@ +--- +allow_duplicates: no diff --git a/roles/redis/tasks/main.yml b/roles/redis/tasks/main.yml new file mode 100644 index 0000000..777f7dc --- /dev/null +++ b/roles/redis/tasks/main.yml @@ -0,0 +1,31 @@ +#!/usr/bin/ansible-playbook +# vim:ft=ansible: +--- +- name: Set up Redis + block: + - name: Install Redis + apt: + name: "redis-server" + register: apt-results + - name: Copy configs + template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + loop: + - { src: "redis.conf", dest: "/etc/redis/redis.conf" } + - { src: "redis-tmpfiles.conf", dest: "/etc/tmpfiles.d/redis.conf" } + notify: restart redis + - name: Create socket directory + file: + path: "/var/run/redis" + state: directory + mode: "0755" + owner: redis + group: redis + notify: restart redis + - name: Start service + service: + name: redis-server + state: started + enabled: yes + become: yes diff --git a/roles/redis/templates/main.cf b/roles/redis/templates/main.cf new file mode 100644 index 0000000..c32ed78 --- /dev/null +++ b/roles/redis/templates/main.cf @@ -0,0 +1,5 @@ +myhostname = {{ postfix_hostname }} +myorigin = $mydomain +#relayhost = $mydomain +inet_interfaces = loopback-only +mydestination = diff --git a/roles/gitlab/files/redis-tmpfile.conf b/roles/redis/templates/redis-tmpfile.conf similarity index 100% rename from roles/gitlab/files/redis-tmpfile.conf rename to roles/redis/templates/redis-tmpfile.conf diff --git a/roles/gitlab/files/redis.conf b/roles/redis/templates/redis.conf similarity index 100% rename from roles/gitlab/files/redis.conf rename to roles/redis/templates/redis.conf