diff --git a/defaults/main.yml b/defaults/main.yml index c94fcbf..2caa8d6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,7 +1,13 @@ --- concourse_version: 3.14.1 + +# Installation variables + concourse_install_dir: /opt/concourse -concourse_binary_path: "{{ concourse_install_dir }}/concourse" +concourse_binary_path: "{{ concourse_install_dir }}/bin/concourse" + +concourse_worker_env: {} + concourse_binary_os: linux concourse_binary_arch: amd64 concourse_binary_fetch_timeout: 30 @@ -12,6 +18,17 @@ concourse_gid: "{{ concourse_uid }}" concourse_force_restart: no concourse_service_enabled: yes + +# Concourse source variables + +concourse_archive_name: concourse-{{ concourse_version }}-{{ concourse_archive_os }}-{{ concourse_archive_arch }}.tgz +concourse_archive_url: https://github.com/concourse/concourse/releases/download/v{{ concourse_version }}/{{ concourse_archive_name }} +concourse_archive_os: linux +concourse_archive_arch: amd64 +concourse_archive_fetch_timeout: 60 +concourse_archive_delete_after_unarchive: yes +concourse_binary_mode: "0750" + # Web variables concourse_web: no diff --git a/tasks/install.yml b/tasks/install.yml index 3c35306..39ed889 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -24,9 +24,62 @@ group: "{{ concourse_group }}" become: yes +- name: create binary directory | concourse + file: + path: "{{ concourse_binary_path | dirname }}" + state: directory + mode: 0755 + owner: "{{ concourse_user }}" + group: "{{ concourse_group }}" + become: yes + - include: stop.yml when: needs_install +# For Concourse version > 5 +- name: Install, configure, and start Apache + block: + - name: download archive + get_url: + url: "{{ concourse_archive_url }}" + dest: "{{ concourse_install_dir }}/{{ concourse_archive_name }}" + mode: 0755 + force: no + timeout: "{{ concourse_archive_fetch_timeout }}" + become: yes + register: binary_download + tags: + - no-test + - name: unpack archive + unarchive: + src: "{{ concourse_install_dir }}/{{ concourse_archive_name }}" + dest: "{{ concourse_install_dir }}" + remote_src: yes + mode: 0755 + owner: "{{ concourse_user }}" + group: "{{ concourse_group }}" + extra_opts: [--strip-components=1] + become: yes + when: binary_download is not defined or binary_download is changed + notify: + - restart concourse web + - restart concourse worker + - name: delete archive + file: + path: "{{ concourse_install_dir }}/{{ concourse_archive_name }}" + state: absent + become: yes + when: concourse_archive_delete_after_unarchive + - name: binary permissions + file: + path: "{{ concourse_binary_path }}" + owner: "{{ concourse_user }}" + group: "{{ concourse_group }}" + mode: "{{ concourse_binary_mode }}" + become: yes + when: needs_install and concourse_version is version('5.0', '>=') + +# For Concourse under version 5 - name: download binary | concourse get_url: url: https://github.com/concourse/concourse/releases/download/v{{ concourse_version }}/concourse_{{ concourse_binary_os }}_{{ concourse_binary_arch }} @@ -37,7 +90,7 @@ force: yes timeout: "{{ concourse_binary_fetch_timeout }}" become: yes - when: needs_install + when: needs_install and concourse_version is version('5.0', '<') register: binary_download notify: - restart concourse web diff --git a/templates/concourse-retire-worker.j2 b/templates/concourse-retire-worker.j2 index 751d9bf..59509d4 100644 --- a/templates/concourse-retire-worker.j2 +++ b/templates/concourse-retire-worker.j2 @@ -2,13 +2,17 @@ # {{ ansible_managed }} +{% for key, value in concourse_worker_env.items() %} +export {{ key }}="{{ value }}" +{% endfor %} + # If $1 PID of concourse worker is provided, do a kill instead of an api call # Mostly used by systemd for concourse compatiility issues https://github.com/concourse/concourse/pull/3929 until ! curl --fail 127.0.0.1:7777/ping; do if [[ -z "$1" ]]; then - {{ concourse_install_dir }}/concourse retire-worker \ + {{ concourse_binary_path }} retire-worker \ --tsa-host "{{ concourse_tsa_host }}:{{ concourse_tsa_port }}" \ --tsa-public-key {{ concourse_tsa_public_key_path }} \ --tsa-worker-private-key {{ concourse_tsa_worker_key_path }} \ diff --git a/templates/concourse-web.j2 b/templates/concourse-web.j2 index c4fc88d..ee58720 100644 --- a/templates/concourse-web.j2 +++ b/templates/concourse-web.j2 @@ -2,7 +2,7 @@ # {{ ansible_managed }} -exec {{ concourse_install_dir }}/concourse web \ +exec {{ concourse_binary_path }} web \ --session-signing-key {{ concourse_session_signing_key_path }} \ --tsa-bind-port {{ concourse_tsa_port }} \ --tsa-host-key {{ concourse_host_key_path }} \ diff --git a/templates/concourse-worker.j2 b/templates/concourse-worker.j2 index a158d67..e72a5b3 100644 --- a/templates/concourse-worker.j2 +++ b/templates/concourse-worker.j2 @@ -6,8 +6,11 @@ iptables -P FORWARD ACCEPT {% endif %} +{% for key, value in concourse_worker_env.items() %} +export {{ key }}="{{ value }}" +{% endfor %} -exec {{ concourse_install_dir }}/concourse worker \ +exec {{ concourse_binary_path }} worker \ --tsa-host "{{ concourse_tsa_host }}:{{ concourse_tsa_port }}" \ --tsa-public-key {{ concourse_tsa_public_key_path }} \ --tsa-worker-private-key {{ concourse_tsa_worker_key_path }} \