diff --git a/examples/dynconf/large-sample.yaml b/examples/dynconf/large-sample.yaml new file mode 100644 index 0000000..0b4317f --- /dev/null +++ b/examples/dynconf/large-sample.yaml @@ -0,0 +1,188 @@ +--- +metadata: + kind: MainConfig + cluster: "" + version: 5 +config: + yaml_config_enabled: true + table_profiles_config: + table_profiles: + - name: default + compaction_policy: default + execution_policy: default + partitioning_policy: default + storage_policy: default + replication_policy: default + caching_policy: default + compaction_policies: + - name: default + execution_policies: + - name: default + partitioning_policies: + - name: default + auto_split: true + auto_merge: true + size_to_split: 2147483648 + storage_policies: + - name: default + column_families: + - storage_config: + sys_log: + preferred_pool_kind: ssd + log: + preferred_pool_kind: ssd + data: + preferred_pool_kind: ssd + replication_policies: + - name: default + caching_policies: + - name: default + interconnect_config: + merge_per_peer_counters: true + max_inflight_amount_of_data_in_kb: 10240 + counter_merge_mode: PER_PEER + handshake_timeout_duration: { seconds: 1 } + encryption_mode: REQUIRED + path_to_certificate_file: "/opt/ydb/certs/node.crt" + path_to_private_key_file: "/opt/ydb/certs/node.key" + path_to_ca_file: "/opt/ydb/certs/ca.crt" + +allowed_labels: + node_id: + type: string + host: + type: string + tenant: + type: string + +selector_config: + +- description: cookie=testdb-01 + selector: + tenant: /cluster1/testdb + config: + shared_cache_config: + memory_limit: 51539607552 + feature_flags: !inherit + enable_views: true + enable_data_shard_volatile_transactions: true + table_service_config: + sql_version: 1 + index_auto_choose_mode: MAX_USED_PREFIX + enable_implicit_query_parameter_types: true + enable_kqp_data_query_stream_lookup: true + enable_kqp_data_query_stream_idx_lookup_join: true + resource_manager: + kqp_pattern_cache_compiled_capacity_bytes: 524288000 + kqp_pattern_cache_capacity_bytes: 524288000 + query_limits: + result_rows_limit: 20000 + resource_broker_config: + queues: + - name: queue_restore + limit: + cpu: 8 + - name: queue_backup + limit: + cpu: 8 + actor_system_config: + executor: + - name: System + spin_threshold: '10' + threads: 2 + max_threads: 11 + type: BASIC + - name: User + spin_threshold: '1' + threads: 11 + max_threads: 15 + type: BASIC + - name: Batch + spin_threshold: '1' + threads: 2 + max_threads: 6 + type: BASIC + - name: IO + threads: 1 + type: IO + - name: IC + spin_threshold: '10' + threads: 7 + max_threads: 11 + time_per_mailbox_micro_secs: 100 + max_avg_ping_deviation: 500 + type: BASIC + scheduler: + progress_threshold: '10000' + resolution: '64' + spin_threshold: '0' + sys_executor: 0 + user_executor: 1 + batch_executor: 2 + io_executor: 3 + service_executor: + - executor_id: 4 + service_name: Interconnect + +- description: cookie=admin-01 + selector: + tenant: /cluster1/admin + config: + log_config: + default_level: 4 + shared_cache_config: + memory_limit: 17179869184 + feature_flags: !inherit + enable_views: false + enable_data_shard_volatile_transactions: false + table_service_config: + sql_version: 1 + index_auto_choose_mode: DISABLED + enable_implicit_query_parameter_types: true + enable_kqp_data_query_stream_lookup: false + enable_kqp_data_query_stream_idx_lookup_join: false + resource_manager: + kqp_pattern_cache_compiled_capacity_bytes: 524288000 + kqp_pattern_cache_capacity_bytes: 524288000 + query_limits: + result_rows_limit: 20000 + column_shard_config: + disabled_on_scheme_shard: false + actor_system_config: + executor: + - name: System + spin_threshold: '10' + threads: 1 + max_threads: 4 + type: BASIC + - name: User + spin_threshold: '1' + threads: 3 + max_threads: 7 + type: BASIC + - name: Batch + spin_threshold: '1' + threads: 1 + max_threads: 4 + type: BASIC + - name: IO + threads: 1 + type: IO + - name: IC + spin_threshold: '10' + threads: 2 + max_threads: 4 + time_per_mailbox_micro_secs: 100 + max_avg_ping_deviation: 500 + type: BASIC + scheduler: + progress_threshold: '10000' + resolution: '64' + spin_threshold: '0' + sys_executor: 0 + user_executor: 1 + batch_executor: 2 + io_executor: 3 + service_executor: + - executor_id: 4 + service_name: Interconnect diff --git a/install-dynamic.yaml b/install-dynamic.yaml index 0adb2c6..5478cb3 100644 --- a/install-dynamic.yaml +++ b/install-dynamic.yaml @@ -1,6 +1,7 @@ - hosts: ydbd_dynamic any_errors_fatal: true roles: + - role: ydbd_prepare - role: ydbd - role: ydbd_config - role: ydbd_dynamic diff --git a/install-static.yaml b/install-static.yaml index 420ed2d..ee738a3 100644 --- a/install-static.yaml +++ b/install-static.yaml @@ -1,6 +1,7 @@ - hosts: ydbd_static any_errors_fatal: true roles: + - role: ydbd_prepare - role: ydbd - role: ydbd_config - role: ydbd_static diff --git a/prepare-all.yaml b/prepare-all.yaml new file mode 100644 index 0000000..641c95a --- /dev/null +++ b/prepare-all.yaml @@ -0,0 +1,3 @@ +- hosts: all + roles: + - role: ydbd_prepare diff --git a/roles/ydbd/tasks/main.yml b/roles/ydbd/tasks/main.yml index cac2864..c7f542f 100644 --- a/roles/ydbd/tasks/main.yml +++ b/roles/ydbd/tasks/main.yml @@ -1,168 +1,5 @@ --- -# ydbd installation - -- name: Display the distribution type - ansible.builtin.debug: - var: ansible_distribution - -- name: Ensure libaio1t64 is installed - ansible.builtin.package: - name: libaio1t64 - state: present - when: ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('24.04', '>=') - -- name: Ensure libaio1 is installed - ansible.builtin.package: - name: libaio1 - state: present - when: (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('24.04', '<')) or ansible_distribution == 'Debian' or ansible_distribution == 'Astra Linux' - -- name: Ensure libaio is installed - ansible.builtin.package: - name: libaio - state: present - when: ansible_distribution == 'CentOS' or ansible_distribution == 'AlmaLinux' or ansible_distribution == 'RED' - -- name: Ensure acl is installed - ansible.builtin.package: - name: acl - state: present - when: ansible_distribution == 'Ubuntu' or ansible_distribution == 'Debian' or ansible_distribution == 'Astra Linux' - -- name: Ensure chrony is installed - ansible.builtin.package: - name: chrony - state: present - -- name: Ensure chrony is running - ansible.builtin.systemd: - enabled: true - state: started - name: chronyd - -- name: Ensure jq is installed - ansible.builtin.package: - name: jq - state: present - -- name: Copy the thp-config.sh script - copy: - src: thp-config.sh - dest: /usr/local/bin/ydbd-thp-config.sh - owner: root - group: bin - mode: '0755' - -- name: Generate the THP service files - template: - src: thp-service.j2 - dest: "/etc/systemd/system/ydb-hugepages.service" - owner: root - group: root - mode: '0644' - -- name: Refresh systemd services configuration - ansible.builtin.systemd: - daemon_reload: true - -- name: Activate THP - ansible.builtin.systemd: - enabled: true - state: started - name: ydb-hugepages - -- name: Congestion control kernel module setup - block: - - name: Ensure kernel-modules-extra is installed on RHEL variants - ansible.builtin.package: - name: kernel-modules-extra - state: present - when: ansible_distribution == 'CentOS' or ansible_distribution == 'AlmaLinux' - - name: Build the kernel module customization for congestion control - template: - src: network-modules.j2 - dest: /etc/modules-load.d/50-ydbd.conf - owner: root - group: root - mode: '0644' - - name: Load the {{ ydb_congestion_module }} module - command: "/sbin/modprobe {{ ydb_congestion_module }}" - when: ydb_congestion_module is defined - -- name: Build the kernel settings adjustments file - template: - src: kernel-settings.j2 - dest: /etc/sysctl.d/50-ydbd.conf - owner: root - group: root - mode: '0644' - -- name: Refresh the current sysctl settings - command: "/sbin/sysctl --system" - -- name: Create the YDB base directory - file: - state: directory - path: "{{ ydb_dir }}" - group: bin - owner: root - mode: '0755' - -- name: Create the ydb group - group: - name: ydb - system: true - -- name: Create the ydb user - user: - name: ydb - group: ydb - groups: disk - system: true - create_home: true - home: "{{ ydb_dir }}/home" - comment: "YDB Service Account" - -- name: Create the Ansible remote_tmp for ydb user - file: - path: "{{ ydb_dir }}/home/.ansible/tmp" - state: directory - recurse: true - group: ydb - owner: ydb - mode: '0750' - -- name: Create the YDB configuration directory - file: - state: directory - path: "{{ ydb_dir }}/cfg" - group: bin - owner: root - mode: '0755' - -- name: Create the YDB audit base directory - file: - state: directory - path: "{{ ydb_dir }}/audit" - group: ydb - owner: ydb - mode: '0700' - -- name: Create the YDB certs directory - file: - state: directory - path: "{{ ydb_dir }}/certs" - group: ydb - owner: ydb - mode: '0700' - -- name: Create the YDB configuration backup directory - file: - state: directory - path: "{{ ydb_dir }}/reserve" - group: ydb - owner: ydb - mode: '0700' +# ydbd binaries installation - name: Create the YDB release directory file: @@ -216,20 +53,3 @@ owner: root mode: '0755' force: yes - -- name: Create the YDB CLI default binary directory - file: - state: directory - path: "{{ ydb_dir }}/home/ydb/bin" - recurse: true - group: ydb - owner: ydb - mode: '0755' - -- name: Disable YDB CLI version checks - ansible.builtin.copy: - src: "ydb-cli-config.json" - dest: "{{ ydb_dir }}/home/ydb/bin/config.json" - group: ydb - owner: ydb - mode: '0644' diff --git a/roles/ydbd_dynamic/templates/dynnode-service.j2 b/roles/ydbd_dynamic/templates/dynnode-service.j2 index 0ca1760..a2344bc 100644 --- a/roles/ydbd_dynamic/templates/dynnode-service.j2 +++ b/roles/ydbd_dynamic/templates/dynnode-service.j2 @@ -11,6 +11,7 @@ Restart=always RestartSec=1 User=ydb UMask=077 +#AmbientCapabilities=CAP_SYS_PTRACE PermissionsStartOnly=true SyslogIdentifier=ydbd SyslogFacility=daemon diff --git a/roles/ydbd_fluentbit/tasks/main.yml b/roles/ydbd_fluentbit/tasks/main.yml index 39ad204..6d159c1 100644 --- a/roles/ydbd_fluentbit/tasks/main.yml +++ b/roles/ydbd_fluentbit/tasks/main.yml @@ -87,12 +87,12 @@ mode: '0755' - name: "Collect the per-node database services" - ansible.builtin.command: "{{ ydb_dir }}/home/list_all_db_services.sh {{ ydb_dbname }}" + ansible.builtin.command: "{{ ydb_dir }}/home/list_all_db_services.sh" register: ydbd_svc_data - name: "Extract the per-node database services as list" set_fact: - ydbd_svc: "{{ ydbd_svc_data.stdout_lines }}" + ydbd_svc: "{{ ydbd_svc_data.stdout_lines | map('regex_replace', '^([A-Za-z][A-Za-z0-9_].*$)[ ]', '\\1') | list }}" - name: Generate the YDB fluentbit config files template: diff --git a/roles/ydbd_fluentbit/templates/fluentbit-config.j2 b/roles/ydbd_fluentbit/templates/fluentbit-config.j2 index 2389ba7..ea2659b 100644 --- a/roles/ydbd_fluentbit/templates/fluentbit-config.j2 +++ b/roles/ydbd_fluentbit/templates/fluentbit-config.j2 @@ -15,12 +15,13 @@ {%- for x1 in ydbd_svc %} +{%- set x1_first = x1.split(' ')[0] %} [INPUT] name systemd - Tag {{ x1 }} + Tag {{ x1_first }} storage.type filesystem - DB {{ ydb_dir }}/fluentbit/data/{{ x1 }}.db - Systemd_Filter _SYSTEMD_UNIT={{ x1 }}.service + DB {{ ydb_dir }}/fluentbit/data/{{ x1_first }}.db + Systemd_Filter _SYSTEMD_UNIT={{ x1_first }}.service {%- endfor %} @@ -46,10 +47,11 @@ {%- for x2 in ydbd_svc %} +{%- set x2_first = x2.split(' ')[0] %} [FILTER] Name modify - Match {{ x2 }} - Add P_DB /{{ ydb_domain }}/{{ x2 | regex_replace('^ydbd-(.*)-*$', '\\1') }} + Match {{ x2_first }} + Add P_DB /{{ ydb_domain }}/{{ x2_first | regex_replace('^ydbd-(.*)-.*$', '\\1') }} {%- endfor %} diff --git a/roles/ydbd_fluentbit/templates/list_all_db_services.j2 b/roles/ydbd_fluentbit/templates/list_all_db_services.j2 deleted file mode 100644 index 44c85c6..0000000 --- a/roles/ydbd_fluentbit/templates/list_all_db_services.j2 +++ /dev/null @@ -1,14 +0,0 @@ -#! /bin/sh -# List the services for all YDB databases on the current host. - -set +e -set +u - -(cd /etc/systemd/system && ls ydbd-*-*.service) | while read sn; do - STATE=`systemctl show $sn | grep UnitFileState=enabled $tfile` - if [ ! -z "$STATE" ]; then - basename "$sn" .service - fi -done - -# End Of File diff --git a/roles/ydbd_prepare/tasks/main.yml b/roles/ydbd_prepare/tasks/main.yml new file mode 100644 index 0000000..3ac9195 --- /dev/null +++ b/roles/ydbd_prepare/tasks/main.yml @@ -0,0 +1,190 @@ +--- +# ydbd installation preparation + +- name: Display the distribution type + ansible.builtin.debug: + var: ansible_distribution + +- name: Ensure libaio1t64 is installed + ansible.builtin.package: + name: libaio1t64 + state: present + when: ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('24.04', '>=') + +- name: Ensure libaio1 is installed + ansible.builtin.package: + name: libaio1 + state: present + when: (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('24.04', '<')) or ansible_distribution == 'Debian' or ansible_distribution == 'Astra Linux' + +- name: Ensure libaio is installed + ansible.builtin.package: + name: libaio + state: present + when: ansible_distribution == 'CentOS' or ansible_distribution == 'AlmaLinux' or ansible_distribution == 'RED' + +- name: Ensure acl is installed + ansible.builtin.package: + name: acl + state: present + when: ansible_distribution == 'Ubuntu' or ansible_distribution == 'Debian' or ansible_distribution == 'Astra Linux' + +- name: Ensure chrony is installed + ansible.builtin.package: + name: chrony + state: present + +- name: Ensure chrony is running + ansible.builtin.systemd: + enabled: true + state: started + name: chronyd + +- name: Ensure jq is installed + ansible.builtin.package: + name: jq + state: present + +- name: Copy the thp-config.sh script + copy: + src: thp-config.sh + dest: /usr/local/bin/ydbd-thp-config.sh + owner: root + group: bin + mode: '0755' + +- name: Generate the THP service files + template: + src: thp-service.j2 + dest: "/etc/systemd/system/ydb-hugepages.service" + owner: root + group: root + mode: '0644' + +- name: Refresh systemd services configuration + ansible.builtin.systemd: + daemon_reload: true + +- name: Activate THP + ansible.builtin.systemd: + enabled: true + state: started + name: ydb-hugepages + +- name: Congestion control kernel module setup + block: + - name: Ensure kernel-modules-extra is installed on RHEL variants + ansible.builtin.package: + name: kernel-modules-extra + state: present + when: ansible_distribution == 'CentOS' or ansible_distribution == 'AlmaLinux' + - name: Build the kernel module customization for congestion control + template: + src: network-modules.j2 + dest: /etc/modules-load.d/50-ydbd.conf + owner: root + group: root + mode: '0644' + - name: Load the {{ ydb_congestion_module }} module + command: "/sbin/modprobe {{ ydb_congestion_module }}" + when: ydb_congestion_module is defined + +- name: Build the kernel settings adjustments file + template: + src: kernel-settings.j2 + dest: /etc/sysctl.d/50-ydbd.conf + owner: root + group: root + mode: '0644' + +- name: Refresh the current sysctl settings + command: "/sbin/sysctl --system" + +- name: Create the YDB base directory + file: + state: directory + path: "{{ ydb_dir }}" + group: bin + owner: root + mode: '0755' + +- name: Create the ydb group + group: + name: ydb + system: true + +- name: Create the ydb user + user: + name: ydb + group: ydb + groups: disk + system: true + create_home: true + home: "{{ ydb_dir }}/home" + comment: "YDB Service Account" + +- name: Create the Ansible remote_tmp for ydb user + file: + path: "{{ ydb_dir }}/home/.ansible/tmp" + state: directory + recurse: true + group: ydb + owner: ydb + mode: '0750' + +- name: Create the YDB configuration directory + file: + state: directory + path: "{{ ydb_dir }}/cfg" + group: bin + owner: root + mode: '0755' + +- name: Create the YDB audit base directory + file: + state: directory + path: "{{ ydb_dir }}/audit" + group: ydb + owner: ydb + mode: '0700' + +- name: Create the YDB certs directory + file: + state: directory + path: "{{ ydb_dir }}/certs" + group: ydb + owner: ydb + mode: '0700' + +- name: Create the YDB configuration backup directory + file: + state: directory + path: "{{ ydb_dir }}/reserve" + group: ydb + owner: ydb + mode: '0700' + +- name: Create the YDB release directory + file: + state: directory + path: "{{ ydb_dir }}/release" + group: bin + owner: root + mode: '0755' + +- name: Create the YDB CLI default binary directory + file: + state: directory + path: "{{ ydb_dir }}/home/ydb/bin" + recurse: true + group: ydb + owner: ydb + mode: '0755' + +- name: Disable YDB CLI version checks + ansible.builtin.copy: + src: "ydb-cli-config.json" + dest: "{{ ydb_dir }}/home/ydb/bin/config.json" + group: ydb + owner: ydb + mode: '0644' diff --git a/roles/ydbd/templates/kernel-settings.j2 b/roles/ydbd_prepare/templates/kernel-settings.j2 similarity index 100% rename from roles/ydbd/templates/kernel-settings.j2 rename to roles/ydbd_prepare/templates/kernel-settings.j2 diff --git a/roles/ydbd/templates/network-modules.j2 b/roles/ydbd_prepare/templates/network-modules.j2 similarity index 100% rename from roles/ydbd/templates/network-modules.j2 rename to roles/ydbd_prepare/templates/network-modules.j2 diff --git a/roles/ydbd/templates/thp-service.j2 b/roles/ydbd_prepare/templates/thp-service.j2 similarity index 100% rename from roles/ydbd/templates/thp-service.j2 rename to roles/ydbd_prepare/templates/thp-service.j2 diff --git a/roles/ydbd_rolling_dynamic/tasks/restart_dynamic.yml b/roles/ydbd_rolling_dynamic/tasks/restart_dynamic.yml index 5d5fd73..c27ac70 100644 --- a/roles/ydbd_rolling_dynamic/tasks/restart_dynamic.yml +++ b/roles/ydbd_rolling_dynamic/tasks/restart_dynamic.yml @@ -31,7 +31,7 @@ become_user: ydb loop: "{{ ydbd_db_svc.stdout_lines }}" ansible.builtin.command: - cmd: "{{ ydb_dir }}/home/wait_dynamic.sh {{ inventory_hostname }} {{ item.split(' ')[1] }} {{ ydb_dbname }}" + cmd: "{{ ydb_dir }}/home/wait_dynamic.sh {{ dynnode_name }} {{ item.split(' ')[1] }} {{ ydb_dbname }}" - name: "Cleanup the transferred secrets on {{ dynnode_name }}" file: state=absent path={{ ydb_dir }}/certs/secret - name: Additional delay to settle the dynamic nodes diff --git a/roles/ydbd_rolling_dynamic/templates/list_db_services.j2 b/roles/ydbd_rolling_dynamic/templates/list_db_services.j2 index 2e85b9e..2cf9965 100644 --- a/roles/ydbd_rolling_dynamic/templates/list_db_services.j2 +++ b/roles/ydbd_rolling_dynamic/templates/list_db_services.j2 @@ -7,13 +7,12 @@ set +u DB_NAME="$1" (cd /etc/systemd/system && ls ydbd-${DB_NAME}-*.service) | while read sn; do - tfile=`mktemp` - systemctl show $sn >$tfile - STATE=`grep UnitFileState $tfile | grep enabled` - PORT=`grep ExecStart= $tfile | sed -n 's|.*grpcs-port \([0-9][0-9]*\).*|\1|p'` - rm -f $tfile + NM=`basename $sn .service` + DB=`echo $sn | sed -n 's|ydbd-\([a-zA-Z][a-zA-Z0-9]*\)-.*|\1|p'` + STATE=`systemctl show -pUnitFileState $sn | grep enabled` + PORT=`systemctl show -pExecStart $sn | sed -n 's|.*grpcs-port \([0-9][0-9]*\).*|\1|p'` if [ ! -z "$STATE" ]; then - echo "$sn" ${PORT} + echo ${NM} ${PORT} ${DB} fi done diff --git a/roles/ydbd_static/templates/static-service.j2 b/roles/ydbd_static/templates/static-service.j2 index 90cf4ef..7f10a5d 100644 --- a/roles/ydbd_static/templates/static-service.j2 +++ b/roles/ydbd_static/templates/static-service.j2 @@ -11,6 +11,7 @@ Restart=always RestartSec=1 User=ydb UMask=077 +#AmbientCapabilities=CAP_SYS_PTRACE PermissionsStartOnly=true SyslogIdentifier=ydbd SyslogFacility=daemon @@ -28,8 +29,8 @@ ExecStart={{ ydb_dir }}/bin/ydbd server --tcp \ --grpc-public-host {{ ydb_front }} \ {%- endif %} --grpcs-port 2135 --ic-port 19001 --mon-port 8765 \ - --ca {{ ydb_dir }}/certs/ca.crt --grpc-ca {{ ydb_dir }}/certs/ca.crt \ - --grpc-cert {{ ydb_dir }}/certs/node.crt --grpc-key {{ ydb_dir }}/certs/node.key \ + --ca {{ ydb_dir }}/certs/ca.crt --cert {{ ydb_dir }}/certs/node.crt --key {{ ydb_dir }}/certs/node.key \ + --grpc-ca {{ ydb_dir }}/certs/ca.crt --grpc-cert {{ ydb_dir }}/certs/node.crt --grpc-key {{ ydb_dir }}/certs/node.key \ --mon-cert {{ ydb_dir }}/certs/web.pem LimitNOFILE=65536 LimitCORE=0 diff --git a/roles/ydbd_upgrade_dynamic/tasks/main.yml b/roles/ydbd_upgrade_dynamic/tasks/main.yml index 4288a38..3d378b2 100644 --- a/roles/ydbd_upgrade_dynamic/tasks/main.yml +++ b/roles/ydbd_upgrade_dynamic/tasks/main.yml @@ -1,6 +1,14 @@ --- # ydbd dynamic nodes rolling upgrade +- name: Update the database service listing script + template: + src: list_all_db_services.j2 + dest: "{{ ydb_dir }}/home/list_all_db_services.sh" + group: ydb + owner: ydb + mode: '0755' + - name: YDB database nodes rolling upgrade include_tasks: "upgrade_dynamic.yml" loop: "{{ groups['ydbd_dynamic']|flatten(levels=1) }}" diff --git a/roles/ydbd_upgrade_dynamic/tasks/upgrade_dynamic.yml b/roles/ydbd_upgrade_dynamic/tasks/upgrade_dynamic.yml index 9872236..78d3e1c 100644 --- a/roles/ydbd_upgrade_dynamic/tasks/upgrade_dynamic.yml +++ b/roles/ydbd_upgrade_dynamic/tasks/upgrade_dynamic.yml @@ -44,39 +44,38 @@ delegate_facts: true any_errors_fatal: true -- name: Restart the dynamic nodes on {{ dynnode_name }} - ansible.builtin.systemd: - state: restarted - name: "ydbd-{{ ydb_dbname }}-{{ item.instance }}" - throttle: 1 +- name: "Identify the services for all databases on {{ dynnode_name }}" delegate_to: "{{ dynnode_name }}" delegate_facts: true - loop: "{{ ydb_dynnodes }}" - any_errors_fatal: true + ansible.builtin.command: "{{ ydb_dir }}/home/list_all_db_services.sh" + register: ydbd_db_svc -- name: Transfer the secrets to {{ dynnode_name }} - copy: - src: secret - dest: "{{ ydb_dir }}/certs/secret" - group: ydb - owner: ydb - mode: '0700' +- name: "Restart the database services on {{ dynnode_name }}" + when: ydbd_db_svc.stdout_lines|length > 0 delegate_to: "{{ dynnode_name }}" delegate_facts: true any_errors_fatal: true - -- name: Wait for the dynamic nodes to come up - command: "{{ ydb_dir }}/home/wait_dynamic.sh {{ inventory_hostname }} {{ 2136 + item.offset }} {{ ydb_dbname }}" - become: true - become_user: ydb - delegate_to: "{{ dynnode_name }}" - delegate_facts: true - loop: "{{ ydb_dynnodes }}" - -- name: Cleanup the transferred secrets at {{ dynnode_name }} - file: state=absent path={{ ydb_dir }}/certs/secret - delegate_to: "{{ dynnode_name }}" - delegate_facts: true - -- name: Additional delay to settle the dynamic nodes - ansible.builtin.pause: seconds={{ dynnode_restart_sleep_seconds }} + block: + - name: "Invoke the service restart on {{ dynnode_name }}" + any_errors_fatal: true + loop: "{{ ydbd_db_svc.stdout_lines }}" + ansible.builtin.systemd: + state: restarted + name: "{{ item.split(' ')[0] }}.service" + - name: "Transfer the secrets to {{ dynnode_name }}" + copy: + src: secret + dest: "{{ ydb_dir }}/certs/secret" + group: ydb + owner: ydb + mode: '0700' + - name: "Wait for the dynamic nodes to come up on {{ dynnode_name }}" + become: true + become_user: ydb + loop: "{{ ydbd_db_svc.stdout_lines }}" + ansible.builtin.command: + cmd: "{{ ydb_dir }}/home/wait_dynamic.sh {{ dynnode_name }} {{ item.split(' ')[1] }} {{ item.split(' ')[2] }}" + - name: "Cleanup the transferred secrets on {{ dynnode_name }}" + file: state=absent path={{ ydb_dir }}/certs/secret + - name: Additional delay to settle the dynamic nodes + ansible.builtin.pause: seconds={{ dynnode_restart_sleep_seconds }} diff --git a/run-create-database.sh b/run-create-database.sh index 07f1112..8783421 100755 --- a/run-create-database.sh +++ b/run-create-database.sh @@ -1,4 +1,16 @@ #! /bin/sh . ./run-active-options.sh -${RUN_ANSIBLE} create-database.yaml + +set +e +set +u + +if [ -z "$1" ]; then + ${RUN_ANSIBLE} create-database.yaml +elif [ -z "$2" ]; then + ${RUN_ANSIBLE} create-database.yaml --extra-vars "ydb_dbname=$1" +elif [ -z "$3" ]; then + ${RUN_ANSIBLE} create-database.yaml --extra-vars "ydb_dbname=$1 ydb_default_groups=$2" +else + ${RUN_ANSIBLE} create-database.yaml --extra-vars "ydb_dbname=$1 ydb_default_groups=$2 ydb_pool_kind=$3" +fi diff --git a/run-prepare-all.sh b/run-prepare-all.sh new file mode 100755 index 0000000..e09a3ac --- /dev/null +++ b/run-prepare-all.sh @@ -0,0 +1,4 @@ +#! /bin/sh + +. ./run-active-options.sh +${RUN_ANSIBLE_PARALLEL} prepare-all.yaml diff --git a/run-rolling-dynamic.sh b/run-rolling-dynamic.sh index 8056019..e069caf 100755 --- a/run-rolling-dynamic.sh +++ b/run-rolling-dynamic.sh @@ -1,4 +1,12 @@ #! /bin/sh . ./run-active-options.sh -${RUN_ANSIBLE} rolling-dynamic.yaml + +set +e +set +u + +if [ -z "$1" ]; then + ${RUN_ANSIBLE} rolling-dynamic.yaml +else + ${RUN_ANSIBLE} rolling-dynamic.yaml --extra-vars "ydb_dbname=$1" +fi diff --git a/templates/list_all_db_services.j2 b/templates/list_all_db_services.j2 new file mode 100644 index 0000000..3cfbfc5 --- /dev/null +++ b/templates/list_all_db_services.j2 @@ -0,0 +1,17 @@ +#! /bin/sh +# List the services for all YDB databases on the current host. + +set +e +set +u + +(cd /etc/systemd/system && ls ydbd-*-*.service) | while read sn; do + NM=`basename $sn .service` + DB=`echo $sn | sed -n 's|ydbd-\([a-zA-Z][a-zA-Z0-9]*\)-.*|\1|p'` + STATE=`systemctl show -pUnitFileState $sn | grep enabled` + PORT=`systemctl show -pExecStart $sn | sed -n 's|.*grpcs-port \([0-9][0-9]*\).*|\1|p'` + if [ ! -z "$STATE" ]; then + echo ${NM} ${PORT} ${DB} + fi +done + +# End Of File