From 17882967ef862fb7e6d9cb1c06ae253839e0ec49 Mon Sep 17 00:00:00 2001 From: Johan Guldmyr Date: Sat, 10 Feb 2018 11:18:01 +0200 Subject: [PATCH 1/2] postgresql 10.0 and ansible 2.4 import_tasks --- README.md | 2 +- tasks/databases.yml | 14 +++++++------- tasks/main.yml | 8 ++++---- vars/repo.yml | 3 +++ 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 9321042..588aadc 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Features: - supported distributions: 6 and 7 versions of Redhat, CentOS, Scientific Linux. - Oracle Linux also supported but uses RHEL repositories. -- supported PostgreSQL versions: 8.4, 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6. +- supported PostgreSQL versions: 8.4, 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 10.0 - allows specify users and databases which would be created after install. - ability to determine a set of postgresql.conf parameters and absense postgresql.conf template. Template is not used due to the fact that the postgresql.conf differs from version to version on a set of parameters. - ability to specify another cluster directory and setup symlink into /var/lib/pgsql/x.y/data location. diff --git a/tasks/databases.yml b/tasks/databases.yml index eb5b706..a2cef1d 100644 --- a/tasks/databases.yml +++ b/tasks/databases.yml @@ -2,13 +2,13 @@ - name: "Stage 4 add databases" postgresql_db: - state= present - name= "{{ item.name }}" - template= "{{ item.template }}" - encoding= "{{ item.encoding }}" - lc_collate= "{{ item.collate }}" - lc_ctype= "{{ item.ctype }}" - owner= "{{ item.owner }}" + state: "present" + name: "{{ item.name }}" + template: "{{ item.template }}" + encoding: "{{ item.encoding }}" + lc_collate: "{{ item.collate }}" + lc_ctype: "{{ item.ctype }}" + owner: "{{ item.owner }}" with_items: "{{ postgresql_databases }}" when: postgresql_databases|length > 0 diff --git a/tasks/main.yml b/tasks/main.yml index 2951d1c..394ae2c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -11,8 +11,8 @@ debug: msg="The following packet manager {{ ansible_pkg_mgr }} is not supported" fail=yes when: not ansible_pkg_mgr == "yum" -- include: install.yml -- include: configure.yml -- include: users.yml -- include: databases.yml +- import_tasks: install.yml +- import_tasks: configure.yml +- import_tasks: users.yml +- import_tasks: databases.yml when: postgresql_databases.0 is defined diff --git a/vars/repo.yml b/vars/repo.yml index 7874dcd..216ba8e 100644 --- a/vars/repo.yml +++ b/vars/repo.yml @@ -1,6 +1,7 @@ # file: roles/install-postgresql-on-el6/vars/main.yml -- here are the variables that you don't want to change unnecessarily. postgresql_repo_RedHat: + - { version: "10.0", repo: "https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat10-10-2.noarch.rpm" } - { version: "9.6", repo: "http://yum.postgresql.org/9.6/redhat/rhel-{{ el_version }}-x86_64/pgdg-redhat96-9.6-3.noarch.rpm" } - { version: "9.5", repo: "http://yum.postgresql.org/9.5/redhat/rhel-{{ el_version }}-x86_64/pgdg-redhat95-9.5-3.noarch.rpm" } - { version: "9.4", repo: "http://yum.postgresql.org/9.4/redhat/rhel-{{ el_version }}-x86_64/pgdg-redhat94-9.4-3.noarch.rpm" } @@ -11,6 +12,7 @@ postgresql_repo_RedHat: - { version: "8.4", repo: "http://yum.postgresql.org/8.4/redhat/rhel-{{ el_version }}-x86_64/pgdg-redhat-8.4-3.noarch.rpm" } postgresql_repo_Scientific: + - { version: "10.0", repo: "https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-sl10-10-2.noarch.rpm" } - { version: "9.6", repo: "http://yum.postgresql.org/9.6/redhat/rhel-{{ el_version }}-x86_64/pgdg-sl96-9.6-3.noarch.rpm" } - { version: "9.5", repo: "http://yum.postgresql.org/9.5/redhat/rhel-{{ el_version }}-x86_64/pgdg-sl95-9.5-3.noarch.rpm" } - { version: "9.4", repo: "http://yum.postgresql.org/9.4/redhat/rhel-{{ el_version }}-x86_64/pgdg-sl94-9.4-3.noarch.rpm" } @@ -21,6 +23,7 @@ postgresql_repo_Scientific: - { version: "8.4", repo: "http://yum.postgresql.org/8.4/redhat/rhel-{{ el_version }}-x86_64/pgdg-sl84-8.4-4.noarch.rpm" } postgresql_repo_CentOS: + - { version: "10.0", repo: "https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm" } - { version: "9.6", repo: "http://yum.postgresql.org/9.6/redhat/rhel-{{ el_version }}-x86_64/pgdg-centos96-9.6-3.noarch.rpm" } - { version: "9.5", repo: "http://yum.postgresql.org/9.5/redhat/rhel-{{ el_version }}-x86_64/pgdg-centos95-9.5-3.noarch.rpm" } - { version: "9.4", repo: "http://yum.postgresql.org/9.4/redhat/rhel-{{ el_version }}-x86_64/pgdg-centos94-9.4-3.noarch.rpm" } From 946d18437312675beb4d8248132a6cdf2d94b031 Mon Sep 17 00:00:00 2001 From: Johan Guldmyr Date: Sat, 10 Feb 2018 11:24:21 +0200 Subject: [PATCH 2/2] curly brackets in conditionals nowadays give warnings --- tasks/install.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/install.yml b/tasks/install.yml index 6a4377c..aefc514 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -2,17 +2,17 @@ - name: "Stage 1a: install repository package on CentOS" package: name="{{ item.repo }}" state=present - when: item.version == "{{ postgresql_version }}" and ansible_distribution == "CentOS" + when: item.version == postgresql_version and ansible_distribution == "CentOS" with_items: "{{ postgresql_repo_CentOS }}" - name: "Stage 1b: install repository package on RedHat" package: name="{{ item }}" state=present - when: item.version == "{{ postgresql_version }}" and ansible_distribution == "RedHat" + when: item.version == postgresql_version and ansible_distribution == "RedHat" with_items: "{{ postgresql_repo_RedHat }}" - name: "Stage 1c: install repository package on Scientific" package: name="{{ item }}" state=present - when: item.version == "{{ postgresql_version }}" and ansible_distribution == "Scientific" + when: item.version == postgresql_version and ansible_distribution == "Scientific" with_items: "{{ postgresql_repo_Scientific }}" - name: "Stage 1: install postgresql packages"