From 472f5e20706e532be9680fd23b6f7a6a5e32ad1a Mon Sep 17 00:00:00 2001 From: wangjian Date: Tue, 19 Nov 2024 18:47:05 +0800 Subject: [PATCH] add roles and change deploy method --- playbook/host-multi-machine | 11 ++++++++++ playbook/host-standalone | 2 -- playbook/multi-machine.yml | 16 ++++++++++++++ playbook/roles/mysql/tasks/main.yml | 26 ++++++++++++++++++++++ playbook/roles/pilotgo/tasks/main.yml | 0 playbook/roles/redis/tasks/main.yml | 0 playbook/roles/topo/tasks/main.yml | 0 playbook/standalone.yml | 31 --------------------------- 8 files changed, 53 insertions(+), 33 deletions(-) create mode 100644 playbook/host-multi-machine delete mode 100644 playbook/host-standalone create mode 100644 playbook/multi-machine.yml create mode 100644 playbook/roles/mysql/tasks/main.yml create mode 100644 playbook/roles/pilotgo/tasks/main.yml create mode 100644 playbook/roles/redis/tasks/main.yml create mode 100644 playbook/roles/topo/tasks/main.yml delete mode 100644 playbook/standalone.yml diff --git a/playbook/host-multi-machine b/playbook/host-multi-machine new file mode 100644 index 0000000..6ef0026 --- /dev/null +++ b/playbook/host-multi-machine @@ -0,0 +1,11 @@ +[mysql] +1.1.1.1 + +[redis] +2.2.2.2 + +[pilotgo] +3.3.3.3 + +[topo] +4.4.4.4 diff --git a/playbook/host-standalone b/playbook/host-standalone deleted file mode 100644 index 9ee0aa6..0000000 --- a/playbook/host-standalone +++ /dev/null @@ -1,2 +0,0 @@ -[standalone] -1.1.1.1 \ No newline at end of file diff --git a/playbook/multi-machine.yml b/playbook/multi-machine.yml new file mode 100644 index 0000000..d9fca0f --- /dev/null +++ b/playbook/multi-machine.yml @@ -0,0 +1,16 @@ +--- +- name: install mysql for PilotGo platform + hosts: mysql + become: yes + become_user: root + + roles: + - mysql + tasks: + - name: Ensure a user can connect from a specific host + mysql_user: + name: root + host: '%' + password: '{{ mysql_password }}' + priv: '*.*:ALL,GRANT' + state: present diff --git a/playbook/roles/mysql/tasks/main.yml b/playbook/roles/mysql/tasks/main.yml new file mode 100644 index 0000000..4b6d2f7 --- /dev/null +++ b/playbook/roles/mysql/tasks/main.yml @@ -0,0 +1,26 @@ +--- +- 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 password' + when: info.rc != 0 \ No newline at end of file diff --git a/playbook/roles/pilotgo/tasks/main.yml b/playbook/roles/pilotgo/tasks/main.yml new file mode 100644 index 0000000..e69de29 diff --git a/playbook/roles/redis/tasks/main.yml b/playbook/roles/redis/tasks/main.yml new file mode 100644 index 0000000..e69de29 diff --git a/playbook/roles/topo/tasks/main.yml b/playbook/roles/topo/tasks/main.yml new file mode 100644 index 0000000..e69de29 diff --git a/playbook/standalone.yml b/playbook/standalone.yml deleted file mode 100644 index 37dca1c..0000000 --- a/playbook/standalone.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -- name: install pilotgo & topo plugin standlone - hosts: standalone - remote_user: root - - tasks: - - 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 password' - when: info.rc != 0 -- Gitee