From 9bf48f6fdf31d4a89f95e9cf7a4bac9618cb70a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=9E=E4=B8=90=E4=BA=A6=E5=BC=82?= Date: Fri, 22 Dec 2023 09:47:27 +0000 Subject: [PATCH 1/9] update docs/02-pre-set.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乞丐亦异 --- docs/02-pre-set.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/02-pre-set.md b/docs/02-pre-set.md index 7ac1ddf..2e890dd 100644 --- a/docs/02-pre-set.md +++ b/docs/02-pre-set.md @@ -56,14 +56,14 @@ opengauss_home: /opt/openGauss ``` # 安装目录 -opengauss_home: /openGauss +opengauss_home: /opengauss_data ``` 我们的脚本会通过 `/workdir/roles/pre-tasks/tasks/vars_combine.yml` 的处理后,替换默认变量并放置在 `combined_vars` 数组内。 ``` combined_vars: - opengauss_home: /openGauss + opengauss_home: /opengauss_data ``` 整个部署任务,都会大量使用 combined_vars 里的变量。 -- Gitee From c7f8b772d8c11a6f51650fe6b97db13fa92113b8 Mon Sep 17 00:00:00 2001 From: Haibin Lee Date: Wed, 7 Feb 2024 10:54:48 +0800 Subject: [PATCH 2/9] REV: Remove user 'root' in docker container for some safety reason REV: Pause 10s to review the cluster detail output --- ansible-docker/Dockerfile | 9 ++++----- roles/opengauss/tasks/post_tasks.yml | 4 ++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ansible-docker/Dockerfile b/ansible-docker/Dockerfile index e2ac216..f0078cd 100644 --- a/ansible-docker/Dockerfile +++ b/ansible-docker/Dockerfile @@ -13,15 +13,14 @@ RUN addgroup dbgrp \ && ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime \ && sed -i 's/\/bin\/ash/\/usr\/bin\/fish/g' /etc/passwd -ADD ssh_config /root/.ssh/config - ADD ssh_config /home/omm/.ssh/config +RUN chown -R omm:dbgrp /home/omm \ + && deluser root || echo "User 'root' has been deleted." + USER omm RUN byobu-select-backend tmux \ && byobu-ctrl-a screen \ && byobu-enable \ - && fish -c "alias pansible='ansible-playbook' && funcsave pansible" - - + && fish -c "alias pansible='ansible-playbook' && funcsave pansible" \ No newline at end of file diff --git a/roles/opengauss/tasks/post_tasks.yml b/roles/opengauss/tasks/post_tasks.yml index 5af0b3d..681a0e5 100644 --- a/roles/opengauss/tasks/post_tasks.yml +++ b/roles/opengauss/tasks/post_tasks.yml @@ -30,6 +30,10 @@ msg: | {{ cluster_status.stdout_lines }} + - name: Pause to review + pause: + seconds: 10 + - name: "Create report.md in {{ inventory_dir }}" ansible.builtin.template: src: report.md.j2 -- Gitee From b2a5cbd80814ab6000afe9df158b8e8957b90adb Mon Sep 17 00:00:00 2001 From: Haibin Lee Date: Wed, 28 Feb 2024 01:27:47 +0800 Subject: [PATCH 3/9] ADD: README --- inventories/opengauss/group_vars/README.md | 4 +++- roles/pre_tasks/tasks/vars_combine.yml | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/inventories/opengauss/group_vars/README.md b/inventories/opengauss/group_vars/README.md index e128a27..287ee67 100644 --- a/inventories/opengauss/group_vars/README.md +++ b/inventories/opengauss/group_vars/README.md @@ -1 +1,3 @@ -# Vars for groups \ No newline at end of file +# Vars for groups + +Copy `roles/opengauss/defaults/main.yml` in here and modify it. \ No newline at end of file diff --git a/roles/pre_tasks/tasks/vars_combine.yml b/roles/pre_tasks/tasks/vars_combine.yml index e64f8a0..0249d18 100644 --- a/roles/pre_tasks/tasks/vars_combine.yml +++ b/roles/pre_tasks/tasks/vars_combine.yml @@ -34,7 +34,6 @@ role_vars: "{{ lookup('vars', 'temp_role_vars') }}" group_vars: "{{ lookup('vars', 'temp_group_vars') }}" - # - debug: # msg: "{{ combined_vars }}" -- Gitee From 1853bed9093816de9aad9334f32123501906bde8 Mon Sep 17 00:00:00 2001 From: Haibin Lee Date: Sat, 23 Mar 2024 18:51:50 +0000 Subject: [PATCH 4/9] FIX: failed at cm tool install when not using python3 FIX: failed at disable selinux when using python3 --- inventories/opengauss/hosts.ini | 10 ++++++++-- roles/opengauss/defaults/main.yml | 1 - roles/opengauss/tasks/deploy/cluster_manager.yml | 11 ++++++++++- roles/opengauss/tasks/os/CentOS.yml | 1 + roles/opengauss/tasks/os/Debian.yml | 9 --------- roles/opengauss/tasks/os/openEuler.yml | 1 + vagrant/Vagrantfile-CentOS-79 | 2 +- 7 files changed, 21 insertions(+), 14 deletions(-) delete mode 100644 roles/opengauss/tasks/os/Debian.yml diff --git a/inventories/opengauss/hosts.ini b/inventories/opengauss/hosts.ini index 027af6c..63c58ac 100644 --- a/inventories/opengauss/hosts.ini +++ b/inventories/opengauss/hosts.ini @@ -1,16 +1,20 @@ ; 主机,仅设置 1 个目标机。 [opengauss_primary] -192.168.56.11 +192.168.56.15 ; 备机,可设置若干个或留空。 [opengauss_standby] 192.168.56.14 -192.168.56.15 +192.168.56.11 +192.168.56.16 +192.168.56.18 ; 级联机,可设置若干个或留空。前提是 opengauss_standby 组不为空。 [opengauss_cascade] 192.168.56.13 192.168.56.12 +192.168.56.19 +192.168.56.17 ; 以上 3 个分组的合并组,勿动。 [opengauss:children] @@ -31,3 +35,5 @@ ansible_ssh_user=vagrant ansible_ssh_pass=vagrant ; ssh 端口 ansible_ssh_port=22 +; Python3 +ansible_python_interpreter=python3 \ No newline at end of file diff --git a/roles/opengauss/defaults/main.yml b/roles/opengauss/defaults/main.yml index afd3da0..3ba6558 100644 --- a/roles/opengauss/defaults/main.yml +++ b/roles/opengauss/defaults/main.yml @@ -38,7 +38,6 @@ opengauss_env: lookup( 'password', inventory_dir + '/credentials/opengauss_ca_file_pass', - chars=['ascii_letters', 'digits'], length=8 ) }} diff --git a/roles/opengauss/tasks/deploy/cluster_manager.yml b/roles/opengauss/tasks/deploy/cluster_manager.yml index 7f81085..8d678b6 100644 --- a/roles/opengauss/tasks/deploy/cluster_manager.yml +++ b/roles/opengauss/tasks/deploy/cluster_manager.yml @@ -88,6 +88,10 @@ when: "ansible_loop.index == 1" delegate_to: "{{ hostvars[node]['node_ip'] }}" + - name: Import 'wait_for_started' tasks + ansible.builtin.import_tasks: + file: wait_for_started.yml + - name: Switchover back to primary node ansible.builtin.command: gs_ctl switchover -D {{ og_data_path }}/dn @@ -114,7 +118,7 @@ - name: Deploy CM tool ansible.builtin.expect: - command: "./cm_install -X {{ og_upload_path }}/cluster_config.xml --cmpkg {{ og_upload_path }}/{{ cm_pkg }}" + command: "python3 cm_install -X {{ og_upload_path }}/cluster_config.xml --cmpkg {{ og_upload_path }}/{{ cm_pkg }}" responses: (?i)password: "{{ og_ca_pass }}" chdir: "{{ og_home }}/install/app/tool/cm_tool" @@ -129,6 +133,11 @@ - "cm_install.rc is defined" - "cm_install.rc == 999" + - name: Print CM install log + debug: + msg: "{{ cm_install.stderr_lines }}" + when: "cm_install.stderr_lines is defined" + - name: Refresh cluster config ansible.builtin.command: gs_om -t refreshconf diff --git a/roles/opengauss/tasks/os/CentOS.yml b/roles/opengauss/tasks/os/CentOS.yml index e8e97b0..fe4b84c 100644 --- a/roles/opengauss/tasks/os/CentOS.yml +++ b/roles/opengauss/tasks/os/CentOS.yml @@ -12,6 +12,7 @@ - python36 - python36-pexpect - redhat-lsb-core + - libselinux-python3 use: "{{ custom_pkg_mgr | default(ansible_pkg_mgr) }}" register: pkg_inst until: pkg_inst is succeeded diff --git a/roles/opengauss/tasks/os/Debian.yml b/roles/opengauss/tasks/os/Debian.yml deleted file mode 100644 index 7ce1623..0000000 --- a/roles/opengauss/tasks/os/Debian.yml +++ /dev/null @@ -1,9 +0,0 @@ -- name: Install dependencies - apt: - name: - - libaio-dev - - flex - - bison - - patch - - readline-common - - python3-pexpect \ No newline at end of file diff --git a/roles/opengauss/tasks/os/openEuler.yml b/roles/opengauss/tasks/os/openEuler.yml index 67e76bf..a0bb568 100644 --- a/roles/opengauss/tasks/os/openEuler.yml +++ b/roles/opengauss/tasks/os/openEuler.yml @@ -4,6 +4,7 @@ - libnsl - readline-devel - python3-pexpect + - libselinux-python3 use: "{{ custom_pkg_mgr | default(ansible_pkg_mgr) }}" register: pkg_inst until: pkg_inst is succeeded diff --git a/vagrant/Vagrantfile-CentOS-79 b/vagrant/Vagrantfile-CentOS-79 index 5d75bb0..39d311b 100644 --- a/vagrant/Vagrantfile-CentOS-79 +++ b/vagrant/Vagrantfile-CentOS-79 @@ -13,7 +13,7 @@ Vagrant.configure("2") do |config| config.vm.guest = "centos" # How many vm do you want? - N = 5 + N = 9 config.vm.provider "virtualbox" do |vb| vb.memory = 1024 * 16 -- Gitee From 1f4231551079100730e08d12c75c7aa212b7c4d7 Mon Sep 17 00:00:00 2001 From: Haibin Lee Date: Thu, 13 Jun 2024 16:10:46 +0000 Subject: [PATCH 5/9] FIX: ansible v10 is not support python 3.6, user ansible v9.0.0 instead --- ansible-docker/Dockerfile | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/ansible-docker/Dockerfile b/ansible-docker/Dockerfile index f0078cd..8d154fb 100644 --- a/ansible-docker/Dockerfile +++ b/ansible-docker/Dockerfile @@ -1,26 +1,36 @@ FROM alpine -LABEL Creator="haibin.l@linkingcloud.cn" +LABEL Creator="haibin.lee@foxmail.com" ARG TIMEZONE="Asia/Shanghai" RUN addgroup dbgrp \ && adduser -D -G dbgrp omm \ && sed -i 's/dl-cdn.alpinelinux.org/mirrors.cloud.tencent.com/g' /etc/apk/repositories \ && apk upgrade -U --no-cache \ - && apk --no-cache add bzip2 nano ansible fish byobu \ + && apk --no-cache add bzip2 nano py3-pip fish byobu \ sshpass tzdata rsync wget curl net-tools tar unzip \ openssh-client py3-netaddr musl-locales py3-jmespath \ - inetutils-telnet \ + busybox-extras vim \ && ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime \ - && sed -i 's/\/bin\/ash/\/usr\/bin\/fish/g' /etc/passwd + && sed -i 's/\/bin\/ash/\/usr\/bin\/fish/g' /etc/passwd \ + && echo ". /home/omm/.pyansible/bin/activate" | tee -a /root/.profile \ + && mkdir -p /root/.ssh \ + && mkdir -p /home/omm/.ssh -ADD ssh_config /home/omm/.ssh/config +COPY ssh_config /root/.ssh/config +COPY ssh_config /home/omm/.ssh/config -RUN chown -R omm:dbgrp /home/omm \ - && deluser root || echo "User 'root' has been deleted." +RUN chown -R omm:dbgrp /home/omm USER omm +RUN python3 -m venv /home/omm/.pyansible \ + && . /home/omm/.pyansible/bin/activate \ + && pip install -i https://mirrors.tencent.com/pypi/simple -U pip \ + && pip install -i https://mirrors.tencent.com/pypi/simple -U ansible==9 netaddr + RUN byobu-select-backend tmux \ && byobu-ctrl-a screen \ && byobu-enable \ - && fish -c "alias pansible='ansible-playbook' && funcsave pansible" \ No newline at end of file + && fish -c "alias pansible='ansible-playbook' && funcsave pansible" \ + && echo ". /home/omm/.pyansible/bin/activate" | tee -a /home/omm/.profile + -- Gitee From 5fc333456ca7e2c3a436c5d712e97314b23987f1 Mon Sep 17 00:00:00 2001 From: Haibin Lee Date: Thu, 13 Jun 2024 16:13:15 +0000 Subject: [PATCH 6/9] FIX: failed to import tasks after ansible upgrade to 9.0.0 --- roles/opengauss/tasks/os/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/roles/opengauss/tasks/os/main.yml b/roles/opengauss/tasks/os/main.yml index 117bf60..1ac51e3 100644 --- a/roles/opengauss/tasks/os/main.yml +++ b/roles/opengauss/tasks/os/main.yml @@ -2,8 +2,8 @@ ansible.builtin.include_tasks: file: "{{ item }}" with_first_found: - - "{{ ansible_distribution | replace(' ', '_') }}.yml" - - "not_supported.yml" + - "os/{{ ansible_distribution | replace(' ', '_') }}.yml" + - "os/not_supported.yml" - name: Import Common tasks for all distribution ansible.builtin.import_tasks: @@ -13,8 +13,8 @@ ansible.builtin.include_tasks: file: "{{ item }}" with_first_found: - - "{{ ansible_os_family }}.yml" - - "not_supported.yml" + - "os/{{ ansible_os_family }}.yml" + - "os/not_supported.yml" - name: Import user config tasks ansible.builtin.include_tasks: -- Gitee From 2043fe6183f02469287e75586a2d9f96bcaf1f11 Mon Sep 17 00:00:00 2001 From: Haibin Lee Date: Thu, 13 Jun 2024 16:13:59 +0000 Subject: [PATCH 7/9] FIX: in some cases that the assembled group vars file is not existed --- roles/pre_tasks/tasks/vars_combine.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/roles/pre_tasks/tasks/vars_combine.yml b/roles/pre_tasks/tasks/vars_combine.yml index 0249d18..589ebf6 100644 --- a/roles/pre_tasks/tasks/vars_combine.yml +++ b/roles/pre_tasks/tasks/vars_combine.yml @@ -9,6 +9,15 @@ # - debug: # msg: "{{ temp_role_vars }}" + - name: Init assembled group vars files + file: + path: "{{ inventory_dir }}/assembled_vars/{{ group_names | hash('md5') }}.yml" + state: touch + mode: "0644" + delegate_to: localhost + become: false + run_once: true + - name: Assembling group vars files ansible.builtin.assemble: src: "{{ inventory_dir }}/group_vars/" -- Gitee From 76bf11a760a8b3ebb7ce16430a0b4503804e722c Mon Sep 17 00:00:00 2001 From: Haibin Lee Date: Thu, 13 Jun 2024 16:16:14 +0000 Subject: [PATCH 8/9] REV: some minor changes --- .vscode/settings.json | 3 ++- ansible.cfg | 3 +-- docs/01-ansible-in-docker.md | 9 +++++++++ inventories/opengauss/hosts.ini | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9d14cfb..1406086 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "ansible.python.interpreterPath": "/bin/python" + "ansible.python.interpreterPath": "/bin/python", + "git.ignoreLimitWarning": true } \ No newline at end of file diff --git a/ansible.cfg b/ansible.cfg index 5a2b6f7..5f665fb 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -2,7 +2,6 @@ nocows = True inventory = ./inventories/opengauss/hosts.ini roles_path = ~/.ansible/roles,/workdir/roles,./roles - remote_tmp = $HOME/.ansible/tmp local_tmp = $HOME/.ansible/tmp pipelining = True @@ -15,4 +14,4 @@ display_skipped_hosts = False stdout_callback = yaml [callback_log_plays] -log_folder = ./log/ \ No newline at end of file +log_folder = ./log/ diff --git a/docs/01-ansible-in-docker.md b/docs/01-ansible-in-docker.md index 84af9fe..e0b5aad 100644 --- a/docs/01-ansible-in-docker.md +++ b/docs/01-ansible-in-docker.md @@ -9,10 +9,19 @@ docker-compose up -d --build # 进入容器环境 + +Default user is 'omm' in the docker container + ``` docker exec -it ansible-for-opengauss byobu ``` +If you using 'root' account and you pull the source under any directory that not allowed for other users, use command instead + +``` +docker exec -it -uroot ansible-for-opengauss byobu +``` + # 声明 我个人比较喜爱使用 [fish](https://fishshell.com/) 作为默认的 shell,以及使用 [byobu](https://www.byobu.org/documentation) 作为单窗口多终端的工作环境。如果您不喜欢,可以自行修改 Dockerfile 的内容。 diff --git a/inventories/opengauss/hosts.ini b/inventories/opengauss/hosts.ini index 63c58ac..5fd827c 100644 --- a/inventories/opengauss/hosts.ini +++ b/inventories/opengauss/hosts.ini @@ -36,4 +36,4 @@ ansible_ssh_pass=vagrant ; ssh 端口 ansible_ssh_port=22 ; Python3 -ansible_python_interpreter=python3 \ No newline at end of file +ansible_python_interpreter=python3 -- Gitee From 27de71fb4b1ec88d22cf95950380bc781775bced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=9E=E4=B8=90=E4=BA=A6=E5=BC=82?= Date: Thu, 13 Jun 2024 16:58:30 +0000 Subject: [PATCH 9/9] =?UTF-8?q?update=20docs/01-ansible-in-docker.md.=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=BF=E7=94=A8=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乞丐亦异 --- docs/01-ansible-in-docker.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/01-ansible-in-docker.md b/docs/01-ansible-in-docker.md index e0b5aad..84d5753 100644 --- a/docs/01-ansible-in-docker.md +++ b/docs/01-ansible-in-docker.md @@ -10,13 +10,19 @@ docker-compose up -d --build # 进入容器环境 -Default user is 'omm' in the docker container +容器内默认使用 omm 用户,id 1001。因此克隆下来的目录需首先改变所属权,`/path/to/ansible-for-opengauss` 改为实际的目录。这个改动同样适用于非 root 用户但 id 不是 1001 的情况。 + +``` +chown -R 1001:1001 /path/to/ansible-for-opengauss +``` + +进入容器 ``` docker exec -it ansible-for-opengauss byobu ``` -If you using 'root' account and you pull the source under any directory that not allowed for other users, use command instead +如果你使用的是 root 账号,请指定以 root 用户进入容器内。 ``` docker exec -it -uroot ansible-for-opengauss byobu -- Gitee