Commit 9e61ee6e authored by Louis VINCHON's avatar Louis VINCHON
Browse files

Role postgresql: explode 'when' conditions

The conditions were all written on a single line which makes it hard to quickly
identify what they are.

This commit separates then each on their own line, which is easier to read.

Caveat: One must be aware that all conditions of all lines must be statisfied;
it's and 'AND' and not an 'OR'.
parent 4274856d
......@@ -9,24 +9,36 @@
command: /usr/pgsql-{{ external_postgresql_version }}/bin/initdb -D {{path_to_icat}}
become: true
become_user: postgres
when: (ansible_facts['distribution_major_version'] == "7" and stat_result_centos.stat.exists == False and not use_distribution_postgresql)
when:
- ansible_facts['distribution_major_version'] == "7"
- stat_result_centos.stat.exists == False
- not use_distribution_postgresql
- name: Initialization of ICAT database on CentOS 7
command: /usr/bin/initdb -D {{path_to_icat}}
become: true
become_user: postgres
when: (ansible_facts['distribution_major_version'] == "7" and stat_result_centos.stat.exists == False and use_distribution_postgresql)
when:
- ansible_facts['distribution_major_version'] == "7"
- stat_result_centos.stat.exists == False
- use_distribution_postgresql
- name: Initialization of ICAT database on CentOS 8
command: /usr/pgsql-{{ external_postgresql_version }}/bin/initdb -D {{path_to_icat}}
become: true
become_user: postgres
when: (ansible_facts['distribution_major_version'] == "8" and stat_result_centos.stat.exists == False and not use_distribution_postgresql)
when:
- ansible_facts['distribution_major_version'] == "8"
- stat_result_centos.stat.exists == False
- not use_distribution_postgresql
- name: Initialization of ICAT database on CentOS 8
command: /usr/bin/initdb -D {{path_to_icat}}
become: true
become_user: postgres
when: (ansible_facts['distribution_major_version'] == "8" and stat_result_centos.stat.exists == False and use_distribution_postgresql)
when:
- ansible_facts['distribution_major_version'] == "8"
- stat_result_centos.stat.exists == False
- use_distribution_postgresql
...
......@@ -7,7 +7,9 @@
- epel-release
state: present
update_cache: yes
when: (ansible_facts['distribution_major_version'] == "7" and use_external_epel)
when:
- ansible_facts['distribution_major_version'] == "7"
- use_external_epel
- name: Install ancillary packages for CentOS 7
yum:
......@@ -24,7 +26,9 @@
- 'postgresql{{ external_postgresql_version | replace(".", "") }}'
- 'postgresql{{ external_postgresql_version | replace(".", "") }}-server'
state: present
when: (ansible_facts['distribution_major_version'] == "7" and not use_distribution_postgresql)
when:
- ansible_facts['distribution_major_version'] == "7"
- not use_distribution_postgresql
- name: Install PostgreSQL 9.2 packages for CentOS 7
yum:
......@@ -33,7 +37,9 @@
- postgresql
- postgresql-server
state: present
when: (ansible_facts['distribution_major_version'] == "7" and use_distribution_postgresql)
when:
- ansible_facts['distribution_major_version'] == "7"
- use_distribution_postgresql
- name: Install ancillary packages for CentOS 8
dnf:
......@@ -46,7 +52,9 @@
- name: Disable the built-in PostgreSQL module
command: dnf -qy module disable postgresql
when: (ansible_facts['distribution_major_version'] == "8" and not use_distribution_postgresql)
when:
- ansible_facts['distribution_major_version'] == "8"
- not use_distribution_postgresql
- name: Install PostgreSQL {{ external_postgresql_version }} packages for CentOS 8
dnf:
......@@ -55,7 +63,9 @@
- 'postgresql{{ external_postgresql_version | replace(".", "") }}'
- 'postgresql{{ external_postgresql_version | replace(".", "") }}-server'
state: present
when: (ansible_facts['distribution_major_version'] == "8" and not use_distribution_postgresql)
when:
- ansible_facts['distribution_major_version'] == "8"
- not use_distribution_postgresql
- name: Install PostgreSQL 10 packages for CentOS 8
dnf:
......@@ -64,6 +74,8 @@
- postgresql
- postgresql-server
state: present
when: (ansible_facts['distribution_major_version'] == "8" and use_distribution_postgresql)
when:
- ansible_facts['distribution_major_version'] == "8"
- use_distribution_postgresql
...
......@@ -5,7 +5,9 @@
conf_file: '/etc/yum.conf'
name: https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
state: present
when: (ansible_facts['distribution_major_version'] == "7" and not use_distribution_postgresql)
when:
- ansible_facts['distribution_major_version'] == "7"
- not use_distribution_postgresql
- name: Install external PostgreSQL repository for CentOS 8
dnf:
......@@ -13,7 +15,8 @@
name: https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
state: present
disable_gpg_check: yes
when: (ansible_facts['distribution_major_version'] == "8" and not use_distribution_postgresql)
when:
- ansible_facts['distribution_major_version'] == "8"
- not use_distribution_postgresql
...
......@@ -16,6 +16,7 @@
system: yes
shell: /usr/bin/false
create_home: no
when: ansible_facts['distribution_major_version'] == "7"
when:
- ansible_facts['distribution_major_version'] == "7"
...
......@@ -9,6 +9,8 @@
command: /usr/bin/pg_createcluster -d {{ path_to_icat }} {{ postgresql_version.version.major }} {{ cluster_name }}
become: true
become_user: postgres
when: (ansible_facts['distribution_major_version'] == "10" and stat_result_debian.stat.exists == False)
when:
- ansible_facts['distribution_major_version'] == "10"
- stat_result_debian.stat.exists == False
...
......@@ -12,6 +12,7 @@
- name: Print PostgreSQL version
debug:
var: postgresql_version.version.major
when: ansible_facts['distribution_major_version'] == "18"
when:
- ansible_facts['distribution_major_version'] == "18"
...
......@@ -9,6 +9,8 @@
command: /usr/bin/pg_createcluster -d {{ path_to_icat }} {{ postgresql_version.version.major }} {{ cluster_name }}
become: true
become_user: postgres
when: (ansible_facts['distribution_major_version'] == "18" and stat_result_ubuntu.stat.exists == False)
when:
- ansible_facts['distribution_major_version'] == "18"
- stat_result_ubuntu.stat.exists == False
...
......@@ -6,12 +6,15 @@
- python-apt
- python-pip
state: present
when: ansible_facts['distribution_major_version'] == "18"
when:
- ansible_facts['distribution_major_version'] == "18"
- name: Install PostgreSQL 10 packages for Ubuntu 18.04
apt:
name: postgresql
state: present
when: (ansible_facts['distribution_major_version'] == "18" and use_distribution_postgresql)
when:
- ansible_facts['distribution_major_version'] == "18"
- use_distribution_postgresql
...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment