test: fix syntax for ansible-lint

This commit is contained in:
Adrien Waksberg 2023-08-28 15:01:36 +02:00
parent 003f104851
commit db4f38e578
3 changed files with 49 additions and 48 deletions

View file

@ -1,5 +1,5 @@
---
- name: reload postgresql
- name: Reload postgresql
ansible.builtin.service:
name: 'postgresql@{{ postgresql_version }}-main'
name: "postgresql@{{ postgresql_version }}-main"
state: reloaded

View file

@ -1,98 +1,99 @@
---
- name: install depencies packages
- name: Install depencies packages
ansible.builtin.package:
name:
- gpg
- python3-psycopg2
tags: postgresql
- import_tasks: repo.yml
- name: Import repo tasks
ansible.builtin.import_tasks: repo.yml
when: postgresql_use_official_repository
- name: install packages
- name: Install packages
ansible.builtin.package:
name:
- 'postgresql-{{ postgresql_version }}'
- "postgresql-{{ postgresql_version }}"
tags: postgresql
- name: copy config
- name: Copy config
ansible.builtin.template:
src: '{{ item }}.j2'
dest: '/etc/postgresql/{{ postgresql_version }}/main/{{ item }}'
src: "{{ item }}.j2"
dest: "/etc/postgresql/{{ postgresql_version }}/main/{{ item }}"
owner: root
group: root
mode: 0644
mode: "0644"
loop:
- postgresql.conf
- pg_hba.conf
notify: reload postgresql
notify: Reload postgresql
tags: postgresql
- name: enable and start service
- name: Enable and start service
ansible.builtin.service:
name: 'postgresql@{{ postgresql_version }}-main'
name: "postgresql@{{ postgresql_version }}-main"
state: started
enabled: true
tags: postgresql
- name: wait for service is up
- name: Wait for service is up
ansible.builtin.wait_for:
port: 5432
tags: postgresql
- name: manage users
- name: Manage users
community.general.postgresql_user:
name: '{{ item.key }}'
password: '{{ item.value.password }}'
role_attr_flags: '{{ item.value.attributes | default([]) | join(",") }}'
state: '{{ item.value.state | default("present") }}'
loop: '{{ postgresql_users | dict2items }}'
name: "{{ item.key }}"
password: "{{ item.value.password }}"
role_attr_flags: "{{ item.value.attributes | default([]) | join(',') }}"
state: "{{ item.value.state | default('present') }}"
loop: "{{ postgresql_users | dict2items }}"
loop_control:
label: '{{ item.key }}'
label: "{{ item.key }}"
become: true
become_user: postgres
when: postgresql_primary
tags: postgresql
- name: manage databases
- name: Manage databases
community.general.postgresql_db:
name: '{{ item.name }}'
encoding: '{{ item.encoding | default("UTF-8") }}'
state: '{{ item.state | default("present") }}'
lc_collate: '{{ item.lc_collate | default("C.UTF-8") }}'
lc_ctype: '{{ item.lc_ctype | default("C.UTF-8") }}'
template: '{{ item.template | default("template0") }}'
owner: '{{ item.owner }}'
loop: '{{ postgresql_databases }}'
name: "{{ item.name }}"
encoding: "{{ item.encoding | default('UTF-8') }}"
state: "{{ item.state | default('present') }}"
lc_collate: "{{ item.lc_collate | default('C.UTF-8') }}"
lc_ctype: "{{ item.lc_ctype | default('C.UTF-8') }}"
template: "{{ item.template | default('template0') }}"
owner: "{{ item.owner }}"
loop: "{{ postgresql_databases }}"
become: true
become_user: postgres
when: postgresql_primary
tags: postgresql
- name: manage user's privileges
- name: Manage user"s privileges
community.postgresql.postgresql_privs:
db: '{{ item.database }}'
roles: '{{ item.role }}'
type: '{{ item.type | default("table") }}'
objs: '{{ item.objets | default(["ALL_IN_SCHEMA"]) | join(",") }}'
privs: '{{ item.privileges | join(",") }}'
state: '{{ item.state | default("present") }}'
loop: '{{ postgresql_privileges }}'
db: "{{ item.database }}"
roles: "{{ item.role }}"
type: "{{ item.type | default('table') }}"
objs: "{{ item.objets | default(['ALL_IN_SCHEMA']) | join(',') }}"
privs: "{{ item.privileges | join(',') }}"
state: "{{ item.state | default('present') }}"
loop: "{{ postgresql_privileges }}"
loop_control:
label: '{{ item.role }}/{{ item.database }}'
label: "{{ item.role }}/{{ item.database }}"
become: true
become_user: postgres
when: postgresql_primary
tags: postgresql
- name: manage role membership
- name: Manage role membership
community.postgresql.postgresql_membership:
groups: '{{ item.value.groups }}'
target_roles: '{{ item.key }}'
state: '{{ item.value.state | default("present") }}'
loop: '{{ postgresql_role_memberships | dict2items }}'
groups: "{{ item.value.groups }}"
target_roles: "{{ item.key }}"
state: "{{ item.value.state | default('present') }}"
loop: "{{ postgresql_role_memberships | dict2items }}"
loop_control:
label: '{{ item.key }}'
label: "{{ item.key }}"
become: true
become_user: postgres
when: postgresql_primary

View file

@ -1,11 +1,11 @@
---
- name: add official repository key
- name: Add official repository key
ansible.builtin.apt_key:
url: https://www.postgresql.org/media/keys/ACCC4CF8.asc
tags: postgresql
- name: add official repostiroy
- name: Add official repostiroy
ansible.builtin.apt_repository:
filename: postgresql
repo: 'deb http://apt.postgresql.org/pub/repos/apt {{ ansible_distribution_release }}-pgdg main'
repo: "deb http://apt.postgresql.org/pub/repos/apt {{ ansible_distribution_release }}-pgdg main"
tags: postgresql