--- # This role installs the PostgreSQL server daemon and creates the mastodon # database user - name: Install PostgreSQL server and related packages apt: name={{ item }} state=latest update_cache=yes with_items: - postgresql - postgresql-contrib - python-psycopg2 - name: Stop any Mastodon services that may be running systemd: name={{ item }} state=stopped with_items: - mastodon-sidekiq - mastodon-streaming - mastodon-web - name: Add Mastodon PostgreSQL database user postgresql_user: name: mastodon role_attr_flags: CREATEDB state: present become: true become_user: postgres - name: Drop any existing database that may exist with the same name postgresql_db: name: "{{ DB_NAME }}" state: absent become: true become_user: postgres