Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ansible/roles/keycloak-deploy/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
- name: wait for keycloak to start
uri:
url: "http://{{ inventory_hostname }}:8080/auth/"
status_code: 200
method: GET
register: _result
until: _result.status == 200
until: _result['status']|default(0) == 200
delay: 5
retries: 60
47 changes: 29 additions & 18 deletions ansible/roles/keycloak-deploy/tasks/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,41 @@

- meta: flush_handlers

- name: Install dependencies for keycloak
apt:
name: ["python-setuptools"]
update_cache: true

- name: Ensure python packages are installed
apt:
name: ["python-pip", "python-dev"]
update_cache: yes
when: ansible_os_family == 'Debian' and ansible_distribution_version | float < 18

- name: Ensure python packages are installed
apt:
name: ["python3-pip", "python3-dev"]
update_cache: yes
when: ansible_os_family == 'Debian' and ansible_distribution_version | float > 18
# force to use python2 as a possible workaround
# - name: Install dependencies for keycloak
# apt:
# name: ["python-setuptools"]
# update_cache: true
#
# - name: Ensure python packages are installed
# apt:
# name: ["python-pip", "python-dev"]
# update_cache: yes
# when: ansible_os_family == 'Debian' and ansible_distribution_version | float < 18
#
# - name: Ensure python packages are installed
# apt:
# name: ["python3-pip", "python3-dev"]
# update_cache: yes
# when: ansible_os_family == 'Debian' and ansible_distribution_version | float > 18
#
#- name: Install dependencies for keycloak (python2)
# apt:
# name: "{{ item }}"
# update_cache: true
# with_items:
# - python-pip
# - python-setuptools
# run_once: true


- name: Copying python libraries
copy:
src: "{{ role_path }}/files/python-keycloak-0.12.0"
dest: /tmp/

- name: Initialize python library to run keycloak bootstrap script
shell: cd /tmp/python-keycloak-0.12.0 && python setup.py install
shell: cd /tmp/python-keycloak-0.12.0 && /usr/bin/python2 setup.py install

- name: Save keycloak vars to json
template:
Expand All @@ -81,7 +92,7 @@
dest: /tmp

- name: Run the keycloak bootstrap script
shell: cd /tmp/keycloak/ && python keycloak_main.py /tmp/keycloak-bootstrap.conf.json
shell: cd /tmp/keycloak/ && /usr/bin/python2 keycloak_main.py /tmp/keycloak-bootstrap.conf.json
register: out
until: '"404" not in out.stderr'
retries: 2
Expand Down