fbo / rpms / zuul

Forked from rpms/zuul 4 years ago
Clone
686543e
- name: Install postgres
686543e
  package:
686543e
    name:
686543e
      - postgresql
7357b3d
      - postgresql-server
686543e
      - python3-psycopg2
686543e
    state: present
686543e
  become: true
686543e
9ce704c
- name: Init postgreql DB
9ce704c
  shell: /usr/bin/postgresql-setup --initdb
9ce704c
  ignore_errors: true
9ce704c
  become: true
9ce704c
7357b3d
- name: Start postgres
7357b3d
  service:
7357b3d
    name: postgresql
7357b3d
    state: started
7357b3d
  become: true
7357b3d
7357b3d
- name: Wait for the service to be up
7357b3d
  pause:
7357b3d
    seconds: 15
7357b3d
686543e
- name: Setup a postgres admin password 
686543e
  shell: psql -c "ALTER USER postgres WITH PASSWORD 'mypassword';"
686543e
  become_user: postgres
686543e
  become: true
686543e
  environment:
686543e
    PGPASSWORD: mypassword
686543e
686543e
- name: Create the database for zuul
686543e
  shell: createdb --owner=postgres zuul
686543e
  register: cmd
686543e
  failed_when: cmd.rc != 0 and not "'already exists' in cmd.stderr"
50eaa3f
  # ignore_errors: true
686543e
  become_user: postgres
686543e
  become: true
686543e
  environment:
686543e
    PGPASSWORD: mypassword
686543e
686543e
- name: Enable auth access
686543e
  shell: sed -i 's|127.0.0.1/32            ident|127.0.0.1/32            md5|' /var/lib/pgsql/data/pg_hba.conf
686543e
  become: true
686543e
686543e
- name: Restart postgres
686543e
  service:
686543e
    name: postgresql
686543e
    state: restarted
686543e
  become: true
686543e
686543e
- name: Ensure postgres access
686543e
  shell: psql -h 127.0.0.1 -U postgres zuul -c "\dt"
686543e
  environment:
686543e
    PGPASSWORD: mypassword
686543e