--- # 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 }}" ######################## # Setup systemd script # ######################## - name: Copy start script template: - src: start.sh dest: "{{ cat_git_destination }}" owner: cat group: cat - name: Install service file template: src: cat.service dest: /home/{{ cat_user }}/.config/systemd/user/cat.service owner: cat group: cat - name: Make the user service execute on system start instead of user login shell: loginctl enable-linger {{ cat_user }} - name: Enable cat service systemd: enabled: yes state: started name: cat