|
|
|
---
|
|
|
|
|
|
|
|
- name: Install required dependencies
|
|
|
|
apt:
|
|
|
|
state: present
|
|
|
|
name:
|
|
|
|
- openjdk-11-jdk-headless
|
|
|
|
update_cache: yes
|
|
|
|
|
|
|
|
# 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
|
|
|
|
check_mode: no # only converts some data, does not change anything
|
|
|
|
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
|
|
|
|
check_mode: no # only converts some data, does not change anything
|
|
|
|
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: Store environments required for service
|
|
|
|
template:
|
|
|
|
src: service.env
|
|
|
|
dest: "{{ service_environment_file }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: u=rw,g=r,o=
|
|
|
|
notify:
|
|
|
|
- reload systemd # required for task below, systemd must reload before the service tries to restart
|
|
|
|
- restart spotme
|
|
|
|
|
|
|
|
- name: Register service for SpotMe
|
|
|
|
template:
|
|
|
|
src: spotme.service
|
|
|
|
dest: "{{ global_systemd_configuration_directory }}/{{ spotme_service_name }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "u=rw,g=r,o="
|
|
|
|
notify:
|
|
|
|
- reload systemd
|
|
|
|
- restart spotme
|