Created
July 28, 2016 11:41
-
-
Save sebawebber/62afab04daf8881df390b4b63ca8779d to your computer and use it in GitHub Desktop.
[Ansible] PostgreSQL Installation on EL7 Systems
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| ## PostgreSQL Installation on EL7 Systems | |
| - hosts: all | |
| vars: | |
| pgdg_repo: "https://download.postgresql.org/pub/repos/yum" | |
| pg_version: "9.5" | |
| repo_file: "{{pgdg_repo}}/{{pg_version}}/redhat/rhel-7-x86_64/pgdg-centos{{pg_version | replace('.','')}}-{{pg_version}}-2.noarch.rpm" | |
| pg_packages_base: "postgresql{{pg_version | replace('.','')}}" | |
| tasks: | |
| - name: Install needed repos | |
| yum: name={{ item }} state=present | |
| with_items: | |
| - "{{repo_file}}" | |
| - epel-release | |
| - name: Install Admin packages | |
| yum: name={{ item }} state=present | |
| with_items: | |
| - vim | |
| - pgbadger | |
| - pg_activity | |
| - name: Install PostgreSQL | |
| yum: name={{ item }} state=present | |
| with_items: | |
| - "{{pg_packages_base}}-server" | |
| - "{{pg_packages_base}}-contrib" | |
| - block: | |
| - name: checking cluster directory | |
| command: /usr/pgsql-{{pg_version}}/bin/{{pg_packages_base}}-check-db-dir "/var/lib/pgsql/{{pg_version}}/data" | |
| rescue: | |
| - name: Setup initdb | |
| command: /usr/pgsql-{{pg_version}}/bin/{{pg_packages_base}}-setup initdb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment