From 8c298973a502b1e8540c74ef377588ae5854b021 Mon Sep 17 00:00:00 2001 From: wangjian Date: Thu, 5 Dec 2024 11:08:55 +0800 Subject: [PATCH] add pilotgo agent standalone and multi deploy methods --- scripts/playbook/group_vars/all | 3 ++- scripts/playbook/host-multi-machine | 6 +++++- scripts/playbook/install_PilotGo.yaml | 1 + scripts/playbook/multi-machine.yml | 9 ++++++++- scripts/playbook/roles/pagent/tasks/main.yml | 13 +++++++++++++ .../playbook/templates/pagent/config_agent.yaml.j2 | 14 ++++++++++++++ 6 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 scripts/playbook/roles/pagent/tasks/main.yml create mode 100644 scripts/playbook/templates/pagent/config_agent.yaml.j2 diff --git a/scripts/playbook/group_vars/all b/scripts/playbook/group_vars/all index c32e4ad3..4c8acc90 100644 --- a/scripts/playbook/group_vars/all +++ b/scripts/playbook/group_vars/all @@ -1,4 +1,5 @@ --- redis_password: "PilotGo13579!" mysql_password: "PilotGo13579!" -pserver_config: /opt/PilotGo/server/config_server.yaml \ No newline at end of file +pserver_config: /opt/PilotGo/server/config_server.yaml +pagent_config: /opt/PilotGo/agent/config_agent.yaml \ No newline at end of file diff --git a/scripts/playbook/host-multi-machine b/scripts/playbook/host-multi-machine index c710692e..41eb5e44 100644 --- a/scripts/playbook/host-multi-machine +++ b/scripts/playbook/host-multi-machine @@ -5,4 +5,8 @@ 2.2.2.2 [pserver] -3.3.3.3 \ No newline at end of file +3.3.3.3 + +[pagent] +4.4.4.4 +5.5.5.5 \ No newline at end of file diff --git a/scripts/playbook/install_PilotGo.yaml b/scripts/playbook/install_PilotGo.yaml index 70ac89ad..5dbf0313 100644 --- a/scripts/playbook/install_PilotGo.yaml +++ b/scripts/playbook/install_PilotGo.yaml @@ -8,5 +8,6 @@ - redis - mysql - pserver + - pagent \ No newline at end of file diff --git a/scripts/playbook/multi-machine.yml b/scripts/playbook/multi-machine.yml index 7f708bc8..da0b43fa 100644 --- a/scripts/playbook/multi-machine.yml +++ b/scripts/playbook/multi-machine.yml @@ -38,4 +38,11 @@ become_user: root roles: - - pserver \ No newline at end of file + - pserver +- name: install pagent for PilotGo platform + hosts: pagent + become: yes + become_user: root + + roles: + - pagent \ No newline at end of file diff --git a/scripts/playbook/roles/pagent/tasks/main.yml b/scripts/playbook/roles/pagent/tasks/main.yml new file mode 100644 index 00000000..a785cdef --- /dev/null +++ b/scripts/playbook/roles/pagent/tasks/main.yml @@ -0,0 +1,13 @@ +--- +- name: install pilotgo-agent + dnf: + name: PilotGo-agent + state: present + register: pilotgo_agent_info + ignore_errors: yes +- name: exit when pilotgo-agent fail install + fail: + msg: 'dnf install PilotGo-agent failed' + when: pilotgo_agent_info.rc != 0 +- name: change PilotGo agent config + template: src=templates/pagent/config_agent.yaml.j2 dest={{ pagent_config }} \ No newline at end of file diff --git a/scripts/playbook/templates/pagent/config_agent.yaml.j2 b/scripts/playbook/templates/pagent/config_agent.yaml.j2 new file mode 100644 index 00000000..26bef676 --- /dev/null +++ b/scripts/playbook/templates/pagent/config_agent.yaml.j2 @@ -0,0 +1,14 @@ +server: + {% if groups | length == 1 %} + + addr: {{ groups['standalone'][0] }}:8879 + {% else %} + + addr: {{ groups['pserver'][0] }}:8879 + {% endif %} +log: + level: debug + driver: file #可选stdout和file。stdout:输出到终端控制台;file:输出到path下的指定文件。 + path: ./log/pilotgo_agent.log + max_file: 3 + max_size: 10485760 -- Gitee