From ddff968be124cf4a25caa069099fd7745f37def6 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Wed, 8 Feb 2023 18:13:05 +0800 Subject: [PATCH] perf: postgresql ansible (#9469) Co-authored-by: feng <1304903146@qq.com> --- .../change_secret/database/postgresql/main.yml | 13 ++++++++----- .../automations/change_secret/host/windows/main.yml | 1 + .../verify_account/database/postgresql/main.yml | 3 +++ .../automations/ping/database/postgresql/main.yml | 2 ++ apps/assets/const/database.py | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/accounts/automations/change_secret/database/postgresql/main.yml b/apps/accounts/automations/change_secret/database/postgresql/main.yml index 6a903171f..96ee89dce 100644 --- a/apps/accounts/automations/change_secret/database/postgresql/main.yml +++ b/apps/accounts/automations/change_secret/database/postgresql/main.yml @@ -11,12 +11,13 @@ login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" login_db: "{{ jms_asset.spec_info.db_name }}" - register: db_info + register: result + failed_when: not result.is_available - name: Display PostgreSQL version debug: - var: db_info.server_version.full - when: db_info is succeeded + var: result.server_version.full + when: result is succeeded - name: Change PostgreSQL password community.postgresql.postgresql_user: @@ -27,7 +28,7 @@ db: "{{ jms_asset.spec_info.db_name }}" name: "{{ account.username }}" password: "{{ account.secret }}" - when: db_info is succeeded + when: result is succeeded register: change_info - name: Verify password @@ -38,5 +39,7 @@ login_port: "{{ jms_asset.port }}" db: "{{ jms_asset.spec_info.db_name }}" when: - - db_info is succeeded + - result is succeeded - change_info is succeeded + register: result + failed_when: not result.is_available diff --git a/apps/accounts/automations/change_secret/host/windows/main.yml b/apps/accounts/automations/change_secret/host/windows/main.yml index 0c27301dc..9ba28c075 100644 --- a/apps/accounts/automations/change_secret/host/windows/main.yml +++ b/apps/accounts/automations/change_secret/host/windows/main.yml @@ -12,6 +12,7 @@ ansible.windows.win_user: name: "{{ account.username }}" password: "{{ account.secret }}" + groups: "Administrators" update_password: always when: account.secret_type == "password" diff --git a/apps/accounts/automations/verify_account/database/postgresql/main.yml b/apps/accounts/automations/verify_account/database/postgresql/main.yml index cb6344b39..077a9ce76 100644 --- a/apps/accounts/automations/verify_account/database/postgresql/main.yml +++ b/apps/accounts/automations/verify_account/database/postgresql/main.yml @@ -3,6 +3,7 @@ vars: ansible_python_interpreter: /usr/local/bin/python + tasks: - name: Verify account community.postgresql.postgresql_ping: @@ -11,3 +12,5 @@ login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" db: "{{ jms_asset.spec_info.db_name }}" + register: result + failed_when: not result.is_available diff --git a/apps/assets/automations/ping/database/postgresql/main.yml b/apps/assets/automations/ping/database/postgresql/main.yml index f48c7d4f7..b7ecb55ee 100644 --- a/apps/assets/automations/ping/database/postgresql/main.yml +++ b/apps/assets/automations/ping/database/postgresql/main.yml @@ -11,3 +11,5 @@ login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" login_db: "{{ jms_asset.spec_info.db_name }}" + register: result + failed_when: not result.is_available diff --git a/apps/assets/const/database.py b/apps/assets/const/database.py index 13979890f..623b5b291 100644 --- a/apps/assets/const/database.py +++ b/apps/assets/const/database.py @@ -30,7 +30,7 @@ class DatabaseTypes(BaseType): 'ansible_connection': 'local', }, 'ping_enabled': True, - 'gather_facts_enabled': True, + 'gather_facts_enabled': False, 'gather_accounts_enabled': True, 'verify_account_enabled': True, 'change_secret_enabled': True,