generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 112
Closed
Description
feature idea for module postgresql_pg_hba: bulk rule editing
Some of my pg_hba.conf have over 700 managed rules, which takes some time and memory to loop over (repeated parsing, editing and writing). My current usecase looks like this:
- name: manage pg_hba.conf
community.postgresql.postgresql_pg_hba:
create: yes
dest: "{{ data_dir }}/pg_hba.conf"
backup: yes
backup_file: "{{ data_dir }}/pg_hba.conf.ansible_backup"
keep_comments_at_rules: true
# not used here: attributes, group, mode, owner, selevel, serole, setype, seuser, unsafe_writes
contype: "{{ entry.host }}"
method: "{{ entry.method }}"
options: "{{ entry.options }}"
address: "{{ entry.address }}"
netmask: "{{ entry.netmask }}"
databases: "{{ entry.databases }}"
state: "{{ entry.state }}"
users: "{{ entry.users }}"
comment: "{{ entry.comment }}"
loop: "{{ desired_state.pghba|default([]) }}"
loop_control:
loop_var: entryI would like to optimize that by adding/removing multiple rules with a single call to the module, which could look like this:
- name: manage pg_hba.conf
community.postgresql.postgresql_pg_hba:
create: yes
dest: "{{ data_dir }}/pg_hba.conf"
backup: yes
backup_file: "{{ data_dir }}/pg_hba.conf.ansible_backup"
keep_comments_at_rules: true
# not used here: attributes, group, mode, owner, selevel, serole, setype, seuser, unsafe_writes
bulk: "{{ desired_state.pghba|default([]) }}"The new bulk argument (or rules?) would take a list of objects, each specifying a rule using the existing arguments:
address
comment
contype
databases
method
netmask
options
state
users
If one object is missing one of these, the default is taken, if possible.
When the arguments which can be put into the bulk argument are set normally (example below), they could either
- connflict with the
bulkargument - be appended to the
bulkargument - be treated as defaults for missing values in the
bulkargument
- name: manage pg_hba.conf
community.postgresql.postgresql_pg_hba:
contype: host
address: "2001:db8:1::/64"
databases: db1
users: user1
state: absent
bulk:
- contype: host
address: "2001:db8:2::/64"
databases: db2
users: user2
# option 1 would let the module fail
# option 2 would be equivalent to:
- name: manage pg_hba.conf
community.postgresql.postgresql_pg_hba:
bulk:
- contype: host
address: "2001:db8:1::/64"
databases: db1
users: user1
state: absent
- contype: host
address: "2001:db8:2::/64"
databases: db2
users: user2
# implicit "state: present"
# option 3 would be equivalent to:
- name: manage pg_hba.conf
community.postgresql.postgresql_pg_hba:
bulk:
- contype: host
address: "2001:db8:2::/64"
databases: db2
users: user2
state: absent # normal "state" argument used as defaultReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels