- name: Install JDK
package:
name:
- java-latest-openjdk
- postgresql
- postgresql-server
- python3-psycopg2
state: present
become: true
- name: Create /tmp/zookeeper
file:
path: /tmp/zookeeper
state: directory
become: true
- name: Get and extract Zookeeper
unarchive:
src: https://archive.apache.org/dist/zookeeper/zookeeper-{{ zookeeper_version }}/apache-zookeeper-{{ zookeeper_version }}-bin.tar.gz
dest: /tmp/zookeeper
remote_src: yes
become: true
- name: Setup Zookeeper config file
copy:
src: /tmp/zookeeper/apache-zookeeper-{{ zookeeper_version }}-bin/conf/zoo_sample.cfg
dest: /tmp/zookeeper/apache-zookeeper-{{ zookeeper_version }}-bin/conf/zoo.cfg
remote_src: true
become: true
- name: Ensure Zookeeper not running
command: pkill -f zookeeper
ignore_errors: true
become: true
- name: Start Zookeeper
shell: /tmp/zookeeper/apache-zookeeper-{{ zookeeper_version }}-bin/bin/zkServer.sh start
become: true
- name: Init postgresql DB
shell: /usr/bin/postgresql-setup --initdb
ignore_errors: true
become: true
- name: Start postgres
service:
name: postgresql
state: started
become: true
- name: Wait for the service to be up
pause:
seconds: 15
- name: Setup a postgres admin password
shell: psql -c "ALTER USER postgres WITH PASSWORD 'mypassword';"
become_user: postgres
become: true
environment:
PGPASSWORD: mypassword
- name: Create the database for zuul
shell: createdb --owner=postgres zuul
register: cmd
failed_when: cmd.rc != 0 and not "'already exists' in cmd.stderr"
# ignore_errors: true
become_user: postgres
become: true
environment:
PGPASSWORD: mypassword
- name: Enable auth access
shell: sed -i 's|127.0.0.1/32 ident|127.0.0.1/32 md5|' /var/lib/pgsql/data/pg_hba.conf
become: true
- name: Restart postgres
service:
name: postgresql
state: restarted
become: true
- name: Ensure postgres access
shell: psql -h 127.0.0.1 -U postgres zuul -c "\dt"
environment:
PGPASSWORD: mypassword