2022-10-12 10:08:57 +00:00
|
|
|
- hosts: postgre
|
2022-10-10 12:56:13 +00:00
|
|
|
gather_facts: no
|
2022-09-19 01:52:09 +00:00
|
|
|
vars:
|
2023-11-13 10:09:09 +00:00
|
|
|
ansible_python_interpreter: /opt/py3/bin/python
|
2022-10-27 10:53:10 +00:00
|
|
|
|
2022-10-10 12:56:13 +00:00
|
|
|
tasks:
|
|
|
|
- name: Test PostgreSQL connection
|
2022-10-12 10:08:57 +00:00
|
|
|
community.postgresql.postgresql_ping:
|
2022-10-10 12:56:13 +00:00
|
|
|
login_user: "{{ jms_account.username }}"
|
|
|
|
login_password: "{{ jms_account.secret }}"
|
|
|
|
login_host: "{{ jms_asset.address }}"
|
|
|
|
login_port: "{{ jms_asset.port }}"
|
2023-01-31 09:57:06 +00:00
|
|
|
login_db: "{{ jms_asset.spec_info.db_name }}"
|
2023-02-08 10:13:05 +00:00
|
|
|
register: result
|
|
|
|
failed_when: not result.is_available
|
2022-10-10 12:56:13 +00:00
|
|
|
|
|
|
|
- name: Display PostgreSQL version
|
|
|
|
debug:
|
2023-02-08 10:13:05 +00:00
|
|
|
var: result.server_version.full
|
|
|
|
when: result is succeeded
|
2022-10-10 12:56:13 +00:00
|
|
|
|
|
|
|
- name: Change PostgreSQL password
|
|
|
|
community.postgresql.postgresql_user:
|
|
|
|
login_user: "{{ jms_account.username }}"
|
|
|
|
login_password: "{{ jms_account.secret }}"
|
|
|
|
login_host: "{{ jms_asset.address }}"
|
|
|
|
login_port: "{{ jms_asset.port }}"
|
2023-01-31 09:57:06 +00:00
|
|
|
db: "{{ jms_asset.spec_info.db_name }}"
|
2022-10-10 12:56:13 +00:00
|
|
|
name: "{{ account.username }}"
|
|
|
|
password: "{{ account.secret }}"
|
2023-02-17 11:00:44 +00:00
|
|
|
role_attr_flags: LOGIN
|
2023-06-09 08:52:54 +00:00
|
|
|
ignore_errors: true
|
2023-02-08 10:13:05 +00:00
|
|
|
when: result is succeeded
|
2022-10-10 12:56:13 +00:00
|
|
|
|
|
|
|
- name: Verify password
|
2022-10-12 10:08:57 +00:00
|
|
|
community.postgresql.postgresql_ping:
|
2022-10-10 12:56:13 +00:00
|
|
|
login_user: "{{ account.username }}"
|
|
|
|
login_password: "{{ account.secret }}"
|
|
|
|
login_host: "{{ jms_asset.address }}"
|
|
|
|
login_port: "{{ jms_asset.port }}"
|
2023-01-31 09:57:06 +00:00
|
|
|
db: "{{ jms_asset.spec_info.db_name }}"
|