---
- name: change fas db to readonly for most actions
  hosts: db-fas01.iad2.fedoraproject.org:db-fas01.stg.iad2.fedoraproject.org
  user: root
  vars_files:
   - /srv/web/infra/ansible/vars/global.yml
   - "/srv/private/ansible/vars.yml"
   - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
  tasks:
  - name: copy the sql script to file
    template: src=fas-readonly.sql dest=/var/lib/pgsql/fas-readonly.sql

  - name: change permissions for relevant tables in the fas db
    shell: psql -1 -v ON_ERROR_STOP=1 fas2 </var/lib/pgsql/fas-readonly.sql
    become: yes
    become_user: postgres
    become_method: su
