Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: include spaces around all variables #573

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

- name: PostgreSQL | Make sure the postgres data directory exists
file:
path: "{{postgresql_data_directory}}"
path: "{{ postgresql_data_directory }}"
owner: "{{ postgresql_service_user }}"
group: "{{ postgresql_service_group }}"
state: directory
Expand Down Expand Up @@ -138,7 +138,7 @@
- name: PostgreSQL | Update configuration - pt. 1 (pg_hba.conf)
template:
src: pg_hba.conf.j2
dest: "{{postgresql_conf_directory}}/pg_hba.conf"
dest: "{{ postgresql_conf_directory }}/pg_hba.conf"
owner: "{{ postgresql_service_user }}"
group: "{{ postgresql_service_group }}"
mode: 0640
Expand All @@ -149,7 +149,7 @@
template:
src: "postgresql.conf-{{ postgresql_version }}.j2"
# if using pgtune, save the template to ".untuned"
dest: "{{postgresql_conf_directory}}/postgresql.conf{% if postgresql_pgtune %}.untuned{% endif %}"
dest: "{{ postgresql_conf_directory }}/postgresql.conf{% if postgresql_pgtune %}.untuned{% endif %}"
owner: "{{ postgresql_service_user }}"
group: "{{ postgresql_service_group }}"
mode: 0640
Expand All @@ -163,9 +163,9 @@
TMPDIR=$(mktemp -d)
pgtune --input-config=postgresql.conf.untuned\
--output-config=$TMPDIR/postgresql.conf\
{% if postgresql_pgtune_memory %}--memory {{postgresql_pgtune_memory|int}}{% endif %}\
--type {{postgresql_pgtune_type|quote}}\
{% if postgresql_pgtune_connections %}--connections {{postgresql_pgtune_connections|int}}{% endif %}\
{% if postgresql_pgtune_memory %}--memory {{ postgresql_pgtune_memory|int }}{% endif %}\
--type {{ postgresql_pgtune_type|quote }}\
{% if postgresql_pgtune_connections %}--connections {{ postgresql_pgtune_connections|int }}{% endif %}\
# Compare the current config with the one procuded by pgtune (ignoring comments/blanks)
if diff --ignore-blank-lines \
<(sed -e 's/#.*//' postgresql.conf) \
Expand All @@ -179,7 +179,7 @@
rm $TMPDIR/postgresql.conf
rmdir $TMPDIR
args:
chdir: "{{postgresql_conf_directory}}"
chdir: "{{ postgresql_conf_directory }}"
executable: "/bin/bash"
when: postgresql_pgtune
register: postgresql_configuration_pt3
Expand All @@ -197,7 +197,7 @@

- name: PostgreSQL | Create folder for additional configuration files
file:
name: "{{postgresql_conf_directory}}/conf.d"
name: "{{ postgresql_conf_directory }}/conf.d"
state: directory
owner: "{{ postgresql_service_user }}"
group: "{{ postgresql_service_group }}"
Expand Down
52 changes: 26 additions & 26 deletions tasks/databases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@

- name: PostgreSQL | Make sure the PostgreSQL databases are present
postgresql_db:
name: "{{item.name}}"
name: "{{ item.name }}"
owner: "{{ item.owner | default(postgresql_database_owner) }}"
encoding: "{{ item.encoding | default(postgresql_encoding) }}"
lc_collate: "{{ item.lc_collate | default(postgresql_locale) }}"
lc_ctype: "{{ item.lc_ctype | default(postgresql_ctype) }}"
port: "{{postgresql_port}}"
port: "{{ postgresql_port }}"
template: "template0"
state: "{{ item.state | default('present') }}"
login_user: "{{postgresql_admin_user}}"
login_user: "{{ postgresql_admin_user }}"
become: yes
become_user: "{{postgresql_admin_user}}"
with_items: "{{postgresql_databases}}"
become_user: "{{ postgresql_admin_user }}"
with_items: "{{ postgresql_databases }}"
when: postgresql_databases|length > 0

- name: PostgreSQL | Add extensions to the databases
Expand All @@ -36,57 +36,57 @@

- name: PostgreSQL | Add hstore to the databases with the requirement
become: yes
become_user: "{{postgresql_service_user}}"
shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --port={{ postgresql_port | int }} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS hstore;'"
with_items: "{{postgresql_databases}}"
become_user: "{{ postgresql_service_user }}"
shell: "{{ postgresql_bin_directory }}/psql {{ item.name }} --port={{ postgresql_port | int }} --username {{ postgresql_admin_user }} -c 'CREATE EXTENSION IF NOT EXISTS hstore;'"
with_items: "{{ postgresql_databases }}"
register: hstore_ext_result
failed_when: hstore_ext_result.rc != 0 and ("already exists, skipping" not in hstore_ext_result.stderr)
changed_when: hstore_ext_result.rc == 0 and ("already exists, skipping" not in hstore_ext_result.stderr)
when: item.hstore is defined and item.hstore

- name: PostgreSQL | Add uuid-ossp to the database with the requirement
become: yes
become_user: "{{postgresql_service_user}}"
shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --port={{ postgresql_port | int }} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'"
with_items: "{{postgresql_databases}}"
become_user: "{{ postgresql_service_user }}"
shell: "{{ postgresql_bin_directory }}/psql {{ item.name }} --port={{ postgresql_port | int }} --username {{ postgresql_admin_user }} -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'"
with_items: "{{ postgresql_databases }}"
register: uuid_ext_result
failed_when: uuid_ext_result.rc != 0 and ("already exists, skipping" not in uuid_ext_result.stderr)
changed_when: uuid_ext_result.rc == 0 and ("already exists, skipping" not in uuid_ext_result.stderr)
when: item.uuid_ossp is defined and item.uuid_ossp

- name: PostgreSQL | Add postgis to the databases with the requirement
become: yes
become_user: "{{postgresql_service_user}}"
shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --port={{ postgresql_port | int }} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS postgis;'&&psql {{item.name}} -c 'CREATE EXTENSION IF NOT EXISTS postgis_topology;'"
with_items: "{{postgresql_databases}}"
become_user: "{{ postgresql_service_user }}"
shell: "{{ postgresql_bin_directory }}/psql {{ item.name }} --port={{ postgresql_port | int }} --username {{ postgresql_admin_user }} -c 'CREATE EXTENSION IF NOT EXISTS postgis;'&&psql {{ item.name }} -c 'CREATE EXTENSION IF NOT EXISTS postgis_topology;'"
with_items: "{{ postgresql_databases }}"
when: item.gis is defined and item.gis

- name: PostgreSQL | add cube to the database with the requirement
become: yes
become_user: "{{postgresql_service_user}}"
shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --port={{ postgresql_port | int }} --username {{ postgresql_admin_user }} -c 'create extension if not exists cube;'"
with_items: "{{postgresql_databases}}"
become_user: "{{ postgresql_service_user }}"
shell: "{{ postgresql_bin_directory }}/psql {{ item.name }} --port={{ postgresql_port | int }} --username {{ postgresql_admin_user }} -c 'create extension if not exists cube;'"
with_items: "{{ postgresql_databases }}"
when: item.cube is defined and item.cube

- name: PostgreSQL | Add plpgsql to the database with the requirement
become: yes
become_user: "{{postgresql_service_user}}"
shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --port={{ postgresql_port | int }} --username {{ postgresql_admin_user }} -c 'CREATE EXTENSION IF NOT EXISTS plpgsql;'"
with_items: "{{postgresql_databases}}"
become_user: "{{ postgresql_service_user }}"
shell: "{{ postgresql_bin_directory }}/psql {{ item.name }} --port={{ postgresql_port | int }} --username {{ postgresql_admin_user }} -c 'CREATE EXTENSION IF NOT EXISTS plpgsql;'"
with_items: "{{ postgresql_databases }}"
when: item.plpgsql is defined and item.plpgsql

- name: PostgreSQL | add earthdistance to the database with the requirement
become: yes
become_user: "{{postgresql_service_user}}"
shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --port={{ postgresql_port | int }} --username {{ postgresql_admin_user }} -c 'create extension if not exists earthdistance;'"
with_items: "{{postgresql_databases}}"
become_user: "{{ postgresql_service_user }}"
shell: "{{ postgresql_bin_directory }}/psql {{ item.name }} --port={{ postgresql_port | int }} --username {{ postgresql_admin_user }} -c 'create extension if not exists earthdistance;'"
with_items: "{{ postgresql_databases }}"
when: item.earthdistance is defined and item.earthdistance

- name: PostgreSQL | Add citext to the database with the requirement
become: yes
become_user: "{{postgresql_service_user}}"
shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --port={{ postgresql_port | int }} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS citext;'"
with_items: "{{postgresql_databases}}"
become_user: "{{ postgresql_service_user }}"
shell: "{{ postgresql_bin_directory }}/psql {{ item.name }} --port={{ postgresql_port | int }} --username {{ postgresql_admin_user }} -c 'CREATE EXTENSION IF NOT EXISTS citext;'"
with_items: "{{ postgresql_databases }}"
register: citext_ext_result
failed_when: citext_ext_result.rc != 0 and ("already exists, skipping" not in citext_ext_result.stderr)
changed_when: citext_ext_result.rc == 0 and ("already exists, skipping" not in citext_ext_result.stderr)
Expand Down
2 changes: 1 addition & 1 deletion tasks/extensions/contrib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

- name: PostgreSQL | Extensions | Make sure the postgres contrib extensions are installed | Fedora
dnf:
name: "postgresql{{postgresql_version_terse}}-contrib"
name: "postgresql{{ postgresql_version_terse }}-contrib"
state: present
when: ansible_pkg_mgr == "dnf" and ansible_distribution == "Fedora"
notify:
Expand Down
2 changes: 1 addition & 1 deletion tasks/extensions/postgis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
name: "{{ postgresql_ext_postgis_deps }}"
state: present
update_cache: yes
cache_valid_time: "{{apt_cache_valid_time | default (3600)}}"
cache_valid_time: "{{ apt_cache_valid_time | default (3600) }}"
when: ansible_os_family == "Debian"
notify:
- restart postgresql
Expand Down
18 changes: 9 additions & 9 deletions tasks/install_apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@
pkg: "{{ postgresql_apt_dependencies }}"
state: present
update_cache: yes
cache_valid_time: "{{apt_cache_valid_time | default (3600)}}"
cache_valid_time: "{{ apt_cache_valid_time | default (3600) }}"

- name: PostgreSQL | Install PostgreSQL | apt
apt:
name:
- "postgresql-{{postgresql_version}}"
- "postgresql-client-{{postgresql_version}}"
- "postgresql-contrib-{{postgresql_version}}"
- "postgresql-{{ postgresql_version }}"
- "postgresql-client-{{ postgresql_version }}"
- "postgresql-contrib-{{ postgresql_version }}"
state: present
update_cache: yes
default_release: "{{postgresql_default_release | default(ansible_distribution_release + '-pgdg')}}"
cache_valid_time: "{{apt_cache_valid_time | default (3600)}}"
environment: "{{postgresql_env}}"
default_release: "{{ postgresql_default_release | default(ansible_distribution_release + '-pgdg') }}"
cache_valid_time: "{{ apt_cache_valid_time | default (3600) }}"
environment: "{{ postgresql_env }}"

- name: PostgreSQL | PGTune | apt
apt:
name: pgtune
state: present
update_cache: yes
cache_valid_time: "{{apt_cache_valid_time | default (3600)}}"
environment: "{{postgresql_env}}"
cache_valid_time: "{{ apt_cache_valid_time | default (3600) }}"
environment: "{{ postgresql_env }}"
when: postgresql_pgtune
10 changes: 5 additions & 5 deletions tasks/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

- name: PostgreSQL | Make sure the PostgreSQL users are present
postgresql_user:
name: "{{item.name}}"
name: "{{ item.name }}"
password: "{{ item.pass | default(omit) }}"
encrypted: "{{ item.encrypted | default(omit) }}"
port: "{{postgresql_port}}"
port: "{{ postgresql_port }}"
state: "{{ item.state | default('present') }}"
login_user: "{{postgresql_admin_user}}"
login_user: "{{ postgresql_admin_user }}"
no_log: "{{ postgresql_hide_passwords }}"
become: yes
become_user: "{{postgresql_admin_user}}"
with_items: "{{postgresql_users}}"
become_user: "{{ postgresql_admin_user }}"
with_items: "{{ postgresql_users }}"
when: postgresql_users|length > 0
18 changes: 9 additions & 9 deletions tasks/users_privileges.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

- name: PostgreSQL | Update the user privileges
postgresql_user:
name: "{{item.name}}"
db: "{{item.db | default(omit)}}"
port: "{{postgresql_port}}"
priv: "{{item.priv | default(omit)}}"
name: "{{ item.name }}"
db: "{{ item.db | default(omit) }}"
port: "{{ postgresql_port }}"
priv: "{{ item.priv | default(omit) }}"
state: present
login_host: "{{item.host | default(omit)}}"
login_user: "{{postgresql_admin_user}}"
role_attr_flags: "{{item.role_attr_flags | default(omit)}}"
login_host: "{{ item.host | default(omit) }}"
login_user: "{{ postgresql_admin_user }}"
role_attr_flags: "{{ item.role_attr_flags | default(omit) }}"
become: yes
become_user: "{{postgresql_admin_user}}"
with_items: "{{postgresql_user_privileges}}"
become_user: "{{ postgresql_admin_user }}"
with_items: "{{ postgresql_user_privileges }}"
when: postgresql_users|length > 0
2 changes: 1 addition & 1 deletion templates/etc_monit_conf.d_postgresql.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# {{ ansible_managed }}
check process postgresql with pidfile /var/run/postgresql/{{postgresql_version}}-{{postgresql_cluster_name}}.pid
check process postgresql with pidfile /var/run/postgresql/{{ postgresql_version }}-{{ postgresql_cluster_name }}.pid
group database
start program = "/etc/init.d/postgresql start"
stop program = "/etc/init.d/postgresql stop"
Expand Down
14 changes: 7 additions & 7 deletions templates/pg_hba.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -116,30 +116,30 @@
# Default:
{% for connection in postgresql_pg_hba_default %}
{% if connection.comment is defined %}
# {{connection.comment}}
# {{ connection.comment }}
{% endif %}
{{connection.type}} {{connection.database}} {{connection.user}} {{connection.address}} {{connection.method}}
{{ connection.type }} {{ connection.database }} {{ connection.user }} {{ connection.address }} {{ connection.method }}
{% endfor %}

# MD5 hashed password hosts
{% for host in postgresql_pg_hba_md5_hosts %}
host all all {{host}} md5
host all all {{ host }} md5
{% endfor %}

# Password hosts
{% for host in postgresql_pg_hba_passwd_hosts %}
host all all {{host}} password
host all all {{ host }} password
{% endfor %}

# Trusted hosts
{% for host in postgresql_pg_hba_trust_hosts %}
host all all {{host}} trust
host all all {{ host }} trust
{% endfor %}

# User custom
{% for connection in postgresql_pg_hba_custom %}
{% if connection.comment is defined %}
# {{connection.comment}}
# {{ connection.comment }}
{% endif %}
{{connection.type}} {{connection.database}} {{connection.user}} {{connection.address}} {{connection.method}}
{{ connection.type }} {{ connection.database }} {{ connection.user }} {{ connection.address }} {{ connection.method }}
{% endfor %}
Loading