vi install_postgresql.yml
---
- hosts: all
become: yes
tasks:
- name: Install required packages
apt:
name: "{{ item }}"
update_cache: yes
loop:
- wget
- ca-certificates
- name: PostgreSQL Key
shell: wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
- name: PostgreSQL Repo Source List
shell: sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
- name: Install PostgreSQL
apt:
name: "{{ item }}"
update_cache: yes
loop:
- postgresql
- postgresql-contrib