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:
|
2022-10-27 10:53:10 +00:00
|
|
|
ansible_python_interpreter: /usr/local/bin/python
|
|
|
|
|
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 }}"
|
2022-10-10 12:56:13 +00:00
|
|
|
register: db_info
|
|
|
|
|
|
|
|
- name: Display PostgreSQL version
|
|
|
|
debug:
|
2022-10-24 12:24:56 +00:00
|
|
|
var: db_info.server_version.full
|
|
|
|
when: db_info 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 }}"
|
|
|
|
when: db_info is succeeded
|
2022-10-24 12:24:56 +00:00
|
|
|
register: change_info
|
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 }}"
|
2022-10-27 10:53:10 +00:00
|
|
|
when:
|
2023-01-31 09:57:06 +00:00
|
|
|
- db_info is succeeded
|
|
|
|
- change_info is succeeded
|