Skip to content

Commit

Permalink
Merge pull request #6 from cycloidio/gl_cc_5
Browse files Browse the repository at this point in the history
make playbook compatible also for concourse version 5.6
  • Loading branch information
gaelL authored Oct 11, 2019
2 parents 33aefe6 + cfc66fe commit fb0f13c
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 5 deletions.
19 changes: 18 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
55 changes: 54 additions & 1 deletion tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion templates/concourse-retire-worker.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 }} \
Expand Down
2 changes: 1 addition & 1 deletion templates/concourse-web.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 }} \
Expand Down
5 changes: 4 additions & 1 deletion templates/concourse-worker.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 }} \
Expand Down

0 comments on commit fb0f13c

Please sign in to comment.