---
- name: Ensure that the postgresql server is started
  service: name=postgresql state=started enabled=yes
  when:
    - postgresql_enabled
    - ansible_distribution_file_variety == "Debian"
  tags: [ 'postgresql', 'postgres' ]

- name: Ensure that the postgresql server is stopped and disabled
  service: name=postgresql state=stopped enabled=no
  when:
    - not postgresql_enabled
    - ansible_distribution_file_variety == "Debian"
  tags: [ 'postgresql', 'postgres' ]

- name: Ensure that the postgresql server is started
  service: name='postgresql-{{ psql_version }}' state=started enabled=yes
  when:
    - postgresql_enabled
    - ansible_distribution_file_variety == "RedHat"
  tags: [ 'postgresql', 'postgres' ]

- name: Ensure that the postgresql server is stopped and disabled
  service: name='postgresql-{{ psql_version }}' state=stopped enabled=no
  when:
    - not postgresql_enabled
    - ansible_distribution_file_variety == "RedHat"
  tags: [ 'postgresql', 'postgres' ]