From f45de2059423e283dd1d42111c1c4dd5fb5871a6 Mon Sep 17 00:00:00 2001 From: wangjian Date: Fri, 5 Jul 2024 14:30:20 +0800 Subject: [PATCH] add some new redis config change and mysql install --- scripts/playbook/group_vars/all | 3 +- scripts/playbook/install_PilotGo.yaml | 43 ++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/scripts/playbook/group_vars/all b/scripts/playbook/group_vars/all index 31374876..0d9ebf23 100644 --- a/scripts/playbook/group_vars/all +++ b/scripts/playbook/group_vars/all @@ -1,2 +1,3 @@ --- -redis_password: "PilotGo13579!" \ No newline at end of file +redis_password: "PilotGo13579!" +mysql_password: "PilotGo13579!" \ No newline at end of file diff --git a/scripts/playbook/install_PilotGo.yaml b/scripts/playbook/install_PilotGo.yaml index 34cdbb31..87feb152 100644 --- a/scripts/playbook/install_PilotGo.yaml +++ b/scripts/playbook/install_PilotGo.yaml @@ -5,7 +5,7 @@ become_user: root tasks: - name: check redis rpm - shell: rpm -qa | grep -e 'redis*4*' + shell: rpm -qa | grep -e '^redis*4*' register: rpm_info ignore_errors: yes - name: uninstall redis4 @@ -18,8 +18,18 @@ name: redis6 state: present ignore_errors: yes - - name: change redis.conf - shell: sed -i 's#bind 0.0.0.0#bind {{ groups['standalone'][0] }}#g' /etc/redis/redis.conf + - name: change bind + lineinfile: + path: /etc/redis/redis.conf + regexp: '^#?bind' + line: 'bind {{ groups["standalone"][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 @@ -29,4 +39,29 @@ - name: restart redis service service: name: redis - state: restarted \ No newline at end of file + state: restarted + - name: install mysql through euler repo + dnf: + name: "{{ item }}" + state: present + with_items: + - mysql-server + - python3-pexpect + ignore_errors: yes + - name: start mysql + service: + name: mysqld + state: restarted + - name: change passwd + expect: + command: mysqladmin -u root -p password '{{ mysql_password }}' + responses: + (?i)password: "\n" + vars: + ansible_python_interpreter: /usr/bin/python3 + register: info + ignore_errors: yes + - name: change passwd + debug: + msg: '{{ info.stdout_lines }} mysql already has pqssword' + when: info.rc != 0 \ No newline at end of file -- Gitee