Skip to content

Commit baf660d

Browse files
SeanHaiilixiaocui
authored andcommitted
ansible: fix some issues
1 parent 5d15334 commit baf660d

34 files changed

+419
-1741
lines changed

curve-ansible/clean_curve_sdk.yml

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
hosts: client
2626
gather_facts: no
2727
any_errors_fatal: true
28+
become: "{{ sudo_or_not | bool }}"
2829
tags:
2930
- prepare
3031
roles:

curve-ansible/clean_nebd.yml

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
hosts: client
2929
gather_facts: no
3030
any_errors_fatal: true
31+
become: "{{ sudo_or_not | bool }}"
3132
tags:
3233
- prepare
3334
roles:

curve-ansible/common_tasks/check_chunkserver.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,13 @@
103103
that:
104104
- firmware_version.stdout|version_compare('24.3.0-0050', '>=')
105105

106+
- name: get chunkserver number
107+
include_tasks: "get_chunkserver_number.yml"
108+
106109
- name: check the disk schedule algorithm
107110
shell: cat /sys/block/sd*/queue/scheduler | grep "\[noop\]" | wc -l
108111
register: result
109-
failed_when: result.stdout | int != chunkserver_num
112+
failed_when: result.stdout | int < chunkserver_num | int
110113

111114
- name: check if the disk cache closed
112115
shell: sudo /sbin/hdparm -W /dev/sd* | grep "write-caching"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
#
3+
# Copyright (c) 2021 NetEase Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# Get chunkserver number
18+
19+
- name: get chunkserver number not get disk automatically
20+
set_fact:
21+
chunkserver_num: "{{ disk_list | length }}"
22+
when: not auto_get_disk_list | bool
23+
24+
- name: get chunkserver number get disk automatically
25+
block:
26+
- shell: echo '{{ get_disk_list_cmd }} | wc -l'
27+
register: result
28+
- set_fact:
29+
chunkserver_num: "{{ result.stdout }}"
30+
when: auto_get_disk_list | bool

curve-ansible/common_tasks/install_with_yum_apt.yml

+8
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@
4040
register: result
4141
- name: install lib with yum
4242
shell: sudo yum -y install {{ yum_lib_name }}
43+
register: install_result
4344
when: result.rc != 0
45+
- name: install latest repository
46+
shell: sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm
47+
register: repository
48+
when: install_result.rc != 0
49+
- name: retry install
50+
shell: sudo yum -y install {{ yum_lib_name }}
51+
when: install_result.rc != 0 and repository.rc != 0
4452
when:
4553
- "'CentOS' in distro"
4654

curve-ansible/roles/clean/tasks/include/clean_chunkserver_retain_chunkfilepool.yml

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
# limitations under the License.
1616
#
1717

18+
- name: get chunkserver number
19+
include_tasks: "common_tasks/get_chunkserver_number.yml"
20+
1821
- name: clean chunkserver dat
1922
vars:
2023
end_seq: "{{ chunkserver_num | int - 1}}"

curve-ansible/roles/clean/tasks/include/clean_chunkserver_totally.yml

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
# limitations under the License.
1616
#
1717

18+
- name: get chunkserver number
19+
include_tasks: "common_tasks/get_chunkserver_number.yml"
20+
1821
- name: clean data under data dir
1922
vars:
2023
end_seq: "{{ chunkserver_num | int - 1}}"

curve-ansible/roles/format_chunkserver/tasks/include/prepare_chunkserver_without_disk_format.yml

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
- name: clear data dir
1919
shell: sudo rm -rf {{ chunkserver_data_dir }}/chunkserver*
2020

21+
- name: get chunkserver number
22+
include_tasks: "common_tasks/get_chunkserver_number.yml"
23+
2124
- name: create data dir and log dir for each chunkserver
2225
vars:
2326
end_seq: "{{ chunkserver_num | int - 1}}"

curve-ansible/roles/generate_config/tasks/include/generate_config_with_template.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,13 @@
4747
- name: set backup true
4848
set_fact:
4949
backup: true
50+
- name: check config file exist
51+
stat:
52+
path: "{{ conf_path }}"
53+
register: file_status
5054
- name: backup config file
5155
shell: sudo cp {{ conf_path }} {{ conf_path }}.bak
52-
when: backup is defined
56+
when: backup is defined and file_status.stat.exists
5357
- name: mv config file
5458
shell: sudo mv /tmp/{{ template_name }} {{ conf_path }}
5559
- name: diff two files

curve-ansible/roles/install_package/tasks/include/install_curve-chunkserver.yml

+38-36
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,45 @@
1515
# limitations under the License.
1616
#
1717

18-
- name: install libunwind
19-
vars:
20-
apt_lib_name: libunwind8
21-
yum_lib_name: libunwind
22-
include_tasks: common_tasks/install_with_yum_apt.yml
23-
24-
- name: install libunwind-dev
25-
vars:
26-
apt_lib_name: libunwind8-dev
27-
yum_lib_name: libunwind-devel
28-
include_tasks: common_tasks/install_with_yum_apt.yml
29-
30-
- name: install bzip2
31-
vars:
32-
apt_lib_name: bzip2
33-
yum_lib_name: bzip2
34-
include_tasks: common_tasks/install_with_yum_apt.yml
18+
- name: install package via deb
19+
include_tasks: "install_deb_package.yml"
20+
when: install_with_deb | bool
3521

36-
- name: install jemalloc
37-
vars:
38-
lib_name: jemalloc
39-
download_url: "{{ jemalloc_download_url }}"
40-
include_tasks: install_jemalloc.yml
41-
42-
- name: install psmisc
43-
vars:
44-
apt_lib_name: psmisc
45-
yum_lib_name: psmisc
46-
include_tasks: common_tasks/install_with_yum_apt.yml
47-
when: chunkserver_format_disk | bool
48-
49-
- name: install chunkserver bin
50-
vars:
51-
remote_dir_name: "{{ curve_bin_dir }}"
52-
local_file_path: "{{ local_chunkserver_package_path }}/bin/"
53-
file_mode: 0755
54-
include_tasks: copy_file_to_remote.yml
22+
- name: install package via tar
23+
block:
24+
- name: install libunwind
25+
vars:
26+
apt_lib_name: libunwind8
27+
yum_lib_name: libunwind
28+
include_tasks: common_tasks/install_with_yum_apt.yml
29+
- name: install libunwind-dev
30+
vars:
31+
apt_lib_name: libunwind8-dev
32+
yum_lib_name: libunwind-devel
33+
include_tasks: common_tasks/install_with_yum_apt.yml
34+
- name: install bzip2
35+
vars:
36+
apt_lib_name: bzip2
37+
yum_lib_name: bzip2
38+
include_tasks: common_tasks/install_with_yum_apt.yml
39+
- name: install jemalloc
40+
vars:
41+
lib_name: jemalloc
42+
download_url: "{{ jemalloc_download_url }}"
43+
include_tasks: install_jemalloc.yml
44+
- name: install psmisc
45+
vars:
46+
apt_lib_name: psmisc
47+
yum_lib_name: psmisc
48+
include_tasks: common_tasks/install_with_yum_apt.yml
49+
when: chunkserver_format_disk | bool
50+
- name: install chunkserver bin
51+
vars:
52+
remote_dir_name: "{{ curve_bin_dir }}"
53+
local_file_path: "{{ local_chunkserver_package_path }}/bin/"
54+
file_mode: 0755
55+
include_tasks: copy_file_to_remote.yml
56+
when: not install_with_deb | bool
5557

5658
- name: generate chunkserver_ctl.sh
5759
vars:

curve-ansible/roles/install_package/tasks/include/install_curve-mds.yml

+41-40
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,47 @@
1515
# limitations under the License.
1616
#
1717

18-
- name: install libunwind
19-
vars:
20-
apt_lib_name: libunwind8
21-
yum_lib_name: libunwind
22-
include_tasks: common_tasks/install_with_yum_apt.yml
23-
24-
- name: install libunwind-dev
25-
vars:
26-
apt_lib_name: libunwind8-dev
27-
yum_lib_name: libunwind-devel
28-
include_tasks: common_tasks/install_with_yum_apt.yml
29-
30-
- name: install libuuid
31-
vars:
32-
apt_lib_name: libuuid1
33-
yum_lib_name: libuuid
34-
include_tasks: common_tasks/install_with_yum_apt.yml
35-
36-
- name: install libuuid-dev
37-
vars:
38-
apt_lib_name: uuid-dev
39-
yum_lib_name: libuuid-devel
40-
include_tasks: common_tasks/install_with_yum_apt.yml
41-
42-
- name: install daemon
43-
include_tasks: install_daemon.yml
44-
45-
- name: install mds bin
46-
vars:
47-
remote_dir_name: "{{ curve_bin_dir }}"
48-
local_file_path: "{{ local_mds_package_path }}/bin/"
49-
file_mode: 0755
50-
include_tasks: copy_file_to_remote.yml
51-
52-
- name: install mds lib
53-
vars:
54-
remote_dir_name: "{{ curve_lib_dir }}"
55-
local_file_path: "{{ local_mds_package_path }}/lib/"
56-
file_mode: 0644
57-
include_tasks: copy_file_to_remote.yml
18+
- name: install package via deb
19+
include_tasks: "install_deb_package.yml"
20+
when: install_with_deb | bool
21+
22+
- name: install package via tar
23+
block:
24+
- name: install libunwind
25+
vars:
26+
apt_lib_name: libunwind8
27+
yum_lib_name: libunwind
28+
include_tasks: common_tasks/install_with_yum_apt.yml
29+
- name: install libunwind-dev
30+
vars:
31+
apt_lib_name: libunwind8-dev
32+
yum_lib_name: libunwind-devel
33+
include_tasks: common_tasks/install_with_yum_apt.yml
34+
- name: install libuuid
35+
vars:
36+
apt_lib_name: libuuid1
37+
yum_lib_name: libuuid
38+
include_tasks: common_tasks/install_with_yum_apt.yml
39+
- name: install libuuid-dev
40+
vars:
41+
apt_lib_name: uuid-dev
42+
yum_lib_name: libuuid-devel
43+
include_tasks: common_tasks/install_with_yum_apt.yml
44+
- name: install daemon
45+
include_tasks: install_daemon.yml
46+
- name: install mds bin
47+
vars:
48+
remote_dir_name: "{{ curve_bin_dir }}"
49+
local_file_path: "{{ local_mds_package_path }}/bin/"
50+
file_mode: 0755
51+
include_tasks: copy_file_to_remote.yml
52+
- name: install mds lib
53+
vars:
54+
remote_dir_name: "{{ curve_lib_dir }}"
55+
local_file_path: "{{ local_mds_package_path }}/lib/"
56+
file_mode: 0644
57+
include_tasks: copy_file_to_remote.yml
58+
when: not install_with_deb | bool
5859

5960
- name: generate mds-daemon.sh
6061
template: src=mds-daemon.sh.j2 dest={{ deploy_dir }}/mds-daemon.sh mode=0755

curve-ansible/roles/install_package/tasks/include/install_curve-monitor.yml

+23-23
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@
1515
# limitations under the License.
1616
#
1717

18-
- name: pull prom/prometheus:latest
19-
shell: sudo docker image pull prom/prometheus:latest
18+
- name: install package via deb
19+
include_tasks: "install_deb_package.yml"
20+
when: install_with_deb | bool
2021

21-
- name: pull grafana/grafana:latest
22-
shell: sudo docker image pull grafana/grafana:latest
23-
24-
- name: promoon/reporter:latest
25-
shell: sudo docker image pull promoon/reporter:latest
26-
27-
- name: install jq
28-
vars:
29-
apt_lib_name: jq
30-
yum_lib_name: jq
31-
include_tasks: common_tasks/install_with_yum_apt.yml
32-
33-
- name: install monitor work space
34-
vars:
35-
remote_dir_name: "{{ monitor_work_dir }}"
36-
local_file_path: "{{ local_monitor_package_path }}/"
37-
file_mode: 0777
38-
include_tasks: copy_file_to_remote.yml
39-
40-
- name: generate curve-monitor.sh
41-
template: src=curve-monitor.sh.j2 dest={{ deploy_dir }}/curve-monitor.sh mode=0755
22+
- name: install package via tar
23+
block:
24+
- name: pull prom/prometheus:latest
25+
shell: sudo docker image pull prom/prometheus:latest
26+
- name: pull grafana/grafana:latest
27+
shell: sudo docker image pull grafana/grafana:latest
28+
- name: promoon/reporter:latest
29+
shell: sudo docker image pull promoon/reporter:latest
30+
- name: install jq
31+
vars:
32+
apt_lib_name: jq
33+
yum_lib_name: jq
34+
include_tasks: common_tasks/install_with_yum_apt.yml
35+
- name: install monitor work space
36+
vars:
37+
remote_dir_name: "{{ monitor_work_dir }}"
38+
local_file_path: "{{ local_monitor_package_path }}/"
39+
file_mode: 0777
40+
include_tasks: copy_file_to_remote.yml
41+
when: not install_with_deb | bool

0 commit comments

Comments
 (0)