- name: start pg container docker: name: vagrant_pg_1 image: alpine-postgres ports: 5432:5432 env: POSTGRES_USER: solar POSTGRES_PASSWORD: solar POSTGRES_DATABASE: solar - name: Waiting for postgresql in container shell: docker exec vagrant_pg_1 psql -h localhost -U solar -c "SELECT NOW();" register: result until: result.rc == 0 retries: 15 delay: 1 - shell: docker exec vagrant_pg_1 psql -h localhost -U solar postgres -c "DROP DATABASE solar;" - shell: docker exec vagrant_pg_1 psql -h localhost -U solar postgres -c "CREATE DATABASE solar WITH owner=postgres LC_COLLATE='C' TEMPLATE template0;" - lineinfile: dest: /.solar_config_override line: "solar_db: postgresql://solar:solar@127.0.0.1:5432/solar?solar_pool=True" state: present create: yes