--- - name: install the postgresql packages apt: pkg={{ item }} state=installed with_items: postgresql_pkgs notify: Restart postgresql tags: - postgresql - postgres - name: Install the packages that ansible needs to manage the postgresql users and databases apt: pkg={{ item }} state=installed with_items: - python-psycopg2 tags: - postgresql - postgres - name: Ensure that the postgresql server is started service: name=postgresql state=started enabled=yes tags: - postgresql - postgres