--- # TODO Role for nodejs application - name: Add key for source for nodejs apt_key: id: 9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280 url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key - name: Add source for nodejs apt_repository: repo: "deb https://deb.nodesource.com/node_11.x {{ ansible_distribution_release }} main" filename: nodesource - name: Install required dependencies apt: state: present name: - git - nginx-extras - nodejs - openjdk-8-jdk-headless update_cache: yes - name: Configure system user user: state: present name: "{{ spotme_system_user }}" system: yes shell: /bin/false home: "{{ spotme_user_directory }}" - name: Configure user directory file: path: "{{ spotme_user_directory }}" state: directory owner: "{{ spotme_system_user }}" group: "{{ spotme_system_user }}" mode: "u=rwx,g=rx" # TODO Role for Git Username / Password Configuration - name: Configure git to use credential helper become_user: "{{ spotme_system_user }}" git_config: scope: global name: credential.helper value: store - name: Encode username for SpotMe remote source become_user: "{{ spotme_system_user }}" command: "perl -p -e 's/%(..)/%\\L\\1\\E/g'" args: stdin: "{{ spotme_remote_user | urlencode }}" register: remote_user_encoded changed_when: False - name: Encode password for SpotMe remote source become_user: "{{ spotme_system_user }}" command: "perl -p -e 's/%(..)/%\\L\\1\\E/g'" args: stdin: "{{ spotme_remote_pass | urlencode }}" register: remote_pass_encoded changed_when: False - name: Store credentials for SpotMe remote source become_user: "{{ spotme_system_user }}" lineinfile: path: "~/.git-credentials" line: "{{ spotme_remote_addr | urlsplit('scheme') }}://{{ remote_user_encoded.stdout }}:{{ remote_pass_encoded.stdout }}@{{ spotme_remote_addr | urlsplit('hostname') }}" create: yes # TODO Remove force - name: Clone SpotMe Repository become_user: "{{ spotme_system_user }}" git: repo: "{{ spotme_remote_addr }}" dest: "{{ spotme_installation_directory }}" version: "{{ spotme_version }}" force: yes register: git_spotme # TODO Add changed detection - name: Build SpotMe become_user: "{{ spotme_system_user }}" command: npm run-script build args: chdir: "{{ spotme_installation_directory }}" notify: restart spotme - name: Register service for SpotMe template: src: spotme.service dest: "/etc/systemd/system/{{ spotme_service_name }}" notify: restart spotme