--- # tasks file for . ######## # User # ######## - name: Create cat user user: name: "{{ cat_user }}" ############ # Database # ############ - name: Install psql apt: name: "{{ packages }}" vars: packages: - psycopg2 - postgres-9.6 - name: Create database become: yes become_user: postgres postgresql_db: name: "{{ cat_postgres_db }}" - name: Create database user become: yes become_user: postgres postgresql_user: db: "{{ cat_postgres_db }}" name: "{{ cat_postgres_user }}" password: "{{ cat_postgres_password }}" - name: Clone cat repo repo: ssh://git@git.zeus.gent:2222/ZeusWPI/cat.git dest: "{{ cat_git_destination }}" accept_hostkey: yes ################################## # Download and install leiningen # ################################## - name: Make sure java is installed apt: name: java - name: set user bin dir set_fact: user_bin_dir: /usr/bin - name: Download leiningen get_url: url: https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein dest: "{{ user_bin_dir }}" - name: Add executable permission for lein script file: path: "{{ user_bin_dir }}/lein" mode: "a+x" ################### # Compile and run # ################### - name: Compile to jar shell: lein uberjar args: chdir: "{{ cat_git_destination }}" - name: Run jar shell: java -jar {{cat_git_destination }}/target/uberjar/cat.jar environment: DATABASE_URL: "postgresql://localhost:5432/{{ cat_postgres_db }}?user={{ cat_postgres_user }}&password={{ cat_postgres_password }}"