Skip to content
This repository has been archived by the owner on May 23, 2020. It is now read-only.

Commit

Permalink
Fix lint error use shell only when shell functionality is required
Browse files Browse the repository at this point in the history
  • Loading branch information
kr4ut committed Aug 3, 2019
1 parent 2a8011a commit 35f3663
Showing 1 changed file with 30 additions and 37 deletions.
67 changes: 30 additions & 37 deletions tasks/postgresql.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,6 @@
---
# task file for postgresql

- name: "Set facts for usage in this playbook"
set_fact:
postgres_create_command:
- "cd {{ datafiles_path }} &&"
- "if [ -f create.sql.gz ]; then gunzip create.sql.gz ; fi &&"
- "psql -h '{{ zabbix_server_dbhost }}'"
- "-U '{{ zabbix_server_dbuser }}'"
- "-d '{{ zabbix_server_dbname }}'"
- "-p '{{ zabbix_server_dbport }}'"
- "-f create.sql && touch /etc/zabbix/schema.done"
postgres_schema_command:
- "cd {{ datafiles_path }} && "
- "if [ -f schema.sql.gz ]; then gunzip schema.sql.gz ; fi &&"
- "psql -h '{{ zabbix_server_dbhost }}'"
- "-U '{{ zabbix_server_dbuser }}'"
- "-d '{{ zabbix_server_dbname }}'"
- "-p '{{ zabbix_server_dbport }}'"
- "-f schema.sql && touch /etc/zabbix/schema.done"
postgres_images_command:
- "cd {{ datafiles_path }} &&"
- "psql -h '{{ zabbix_server_dbhost }}'"
- "-U '{{ zabbix_server_dbuser }}'"
- "-d '{{ zabbix_server_dbname }}'"
- "-p '{{ zabbix_server_dbport }}'"
- "-f images.sql && touch /etc/zabbix/images.done"
postgres_data_command:
- "cd {{ datafiles_path }} &&"
- "psql -h '{{ zabbix_server_dbhost }}'"
- "-U '{{ zabbix_server_dbuser }}'"
- "-d '{{ zabbix_server_dbname }}'"
- "-p '{{ zabbix_server_dbport }}'"
- "-f data.sql && touch /etc/zabbix/data.done"

- name: "Set the correct delegated_dbhost (to support postgres db deployment on a remote dbhost)"
set_fact:
delegated_dbhost: "{{ zabbix_server_dbhost if (zabbix_server_dbhost != 'localhost') else inventory_hostname }}"
Expand Down Expand Up @@ -95,7 +62,14 @@
- database

- name: "PostgreSQL | Create schema"
shell: "{{ postgres_create_command | join(' ') }}"
shell: >
cd {{ datafiles_path }} &&
if [ -f create.sql.gz ]; then gunzip create.sql.gz ; fi &&
psql -h '{{ zabbix_server_dbhost }}'
-U '{{ zabbix_server_dbuser }}'
-d '{{ zabbix_server_dbname }}'
-p '{{ zabbix_server_dbport }}'
-f create.sql && touch /etc/zabbix/schema.done
args:
creates: /etc/zabbix/schema.done
warn: no
Expand Down Expand Up @@ -133,7 +107,14 @@
- create_dir_or_not.stat.exists

- name: "PostgreSQL | Importing schema file"
shell: "{{ postgres_schema_command | join(' ') }}"
shell: >
cd {{ datafiles_path }} &&
if [ -f schema.sql.gz ]; then gunzip schema.sql.gz ; fi &&
psql -h '{{ zabbix_server_dbhost }}'
-U '{{ zabbix_server_dbuser }}'
-d '{{ zabbix_server_dbname }}'
-p '{{ zabbix_server_dbport }}'
-f schema.sql && touch /etc/zabbix/schema.done
args:
creates: /etc/zabbix/schema.done
warn: no
Expand All @@ -146,7 +127,13 @@
- database

- name: "PostgreSQL | Importing images file"
shell: "{{ postgres_images_command | join(' ') }}"
shell: >
cd {{ datafiles_path }} &&
psql -h '{{ zabbix_server_dbhost }}'
-U '{{ zabbix_server_dbuser }}'
-d '{{ zabbix_server_dbname }}'
-p '{{ zabbix_server_dbport }}'
-f images.sql && touch /etc/zabbix/images.done
args:
creates: /etc/zabbix/images.done
warn: no
Expand All @@ -158,7 +145,13 @@
- database

- name: "PostgreSQL | Importing data file"
shell: "{{ postgres_data_command | join(' ') }}"
shell: >
cd {{ datafiles_path }} &&
psql -h '{{ zabbix_server_dbhost }}'
-U '{{ zabbix_server_dbuser }}'
-d '{{ zabbix_server_dbname }}'
-p '{{ zabbix_server_dbport }}'
-f data.sql && touch /etc/zabbix/data.done
args:
creates: /etc/zabbix/data.done
warn: no
Expand Down

0 comments on commit 35f3663

Please sign in to comment.