From a56eb5b72d2b16ee3466bf10491279104c3ee479 Mon Sep 17 00:00:00 2001 From: wangjian Date: Thu, 21 Nov 2024 16:36:01 +0800 Subject: [PATCH] add redis install --- playbook/groups_vars/all | 3 ++- playbook/multi-machine.yml | 18 ++++++++++++++ playbook/roles/redis/tasks/main.yml | 37 +++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/playbook/groups_vars/all b/playbook/groups_vars/all index 2e4eac2..1fb59b7 100644 --- a/playbook/groups_vars/all +++ b/playbook/groups_vars/all @@ -1,2 +1,3 @@ --- -mysql_password: "PilotGo13579!" \ No newline at end of file +mysql_password: "PilotGo13579!" +redis_password: "PilotGo13579!" \ No newline at end of file diff --git a/playbook/multi-machine.yml b/playbook/multi-machine.yml index d9fca0f..e24e288 100644 --- a/playbook/multi-machine.yml +++ b/playbook/multi-machine.yml @@ -14,3 +14,21 @@ password: '{{ mysql_password }}' priv: '*.*:ALL,GRANT' state: present +- name: install redis for PilotGo platform + hosts: reids + become: yes + become_user: root + + roles: + - redis + tasks: + - name: change protected mode + lineinfile: + path: /etc/redis/redis.conf + regexp: '^#?protected-mode' + line: 'protected-mode no' + backrefs: yes + - name: restart redis service + service: + name: redis + state: restarted \ No newline at end of file diff --git a/playbook/roles/redis/tasks/main.yml b/playbook/roles/redis/tasks/main.yml index e69de29..05f29f5 100644 --- a/playbook/roles/redis/tasks/main.yml +++ b/playbook/roles/redis/tasks/main.yml @@ -0,0 +1,37 @@ +--- +- name: check redis rpm + shell: rpm -qa | grep -e '^redis*4*' + register: rpm_info + ignore_errors: yes +- name: uninstall redis4 + dnf: + name: redis + state: absent + when: rpm_info.rc == 0 +- name: install redis 6 through euler repo + dnf: + name: redis-6* + state: present + ignore_errors: yes +- name: change bind + lineinfile: + path: /etc/redis/redis.conf + regexp: '^#?bind' + line: 'bind {{ groups["redis"][0] }}' + backrefs: yes +- name: change daemonize + lineinfile: + path: /etc/redis/redis.conf + regexp: '^#?daemonize' + line: 'daemonize yes' + backrefs: yes +- name: change passwd + lineinfile: + path: /etc/redis/redis.conf + regexp: '^#?requirepass' + line: 'requirepass {{ redis_password }}' + backrefs: yes +- name: restart redis service + service: + name: redis + state: restarted \ No newline at end of file -- Gitee