Skip to content

Commit

Permalink
Issue Sunbird-Lern#28 chore: Deployment script for sunbird auth package
Browse files Browse the repository at this point in the history
  • Loading branch information
ahghatol committed Feb 27, 2018
1 parent e855598 commit 1abbfac
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 69 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion keycloak/scripts/ansible/keycloak.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- hosts: all
- hosts: localhost
become: true
vars_files:
- ['{{inventory_dir}}/secrets.yml']
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
- name: status service
become: yes
command: /etc/init.d/keycloak status
register: keycloak
poll: 5
async: 10

- name: stop service
become: yes
command: /etc/init.d/keycloak stop && Pkill keycloak
when: "keycloak.stdout.find('running') != -1"
poll: 5
async: 10
ignore_errors: yes

- name: Paste keycloak config package on server
copy: src="sunbird_auth_{{sunbird_auth_version}}.config.zip" dest="/tmp/" force=no owner={{wildfly_user}} group={{wildfly_group}}

- name: extarct the folder
unarchive: src="/tmp/sunbird_auth_{{sunbird_auth_version}}.config.zip" dest=/tmp/ copy=no owner={{wildfly_user}} group={{wildfly_group}}

- name: Keycloak configuration XML file
copy:
src: "/tmp/sunbird_auth_{{sunbird_auth_version}}.config/standalone-ha.xml"
dest: "{{keycloak_home}}/standalone/configuration/standalone-ha.xml"
mode: 0750
owner: "{{wildfly_user}}"
group: "{{wildfly_group}}"
remote_src: yes

- name: Postgresql Configuration- module.xml
copy:
src: "/tmp/sunbird_auth_{{sunbird_auth_version}}.config/module.xml"
dest: "{{keycloak_home}}/modules/system/layers/keycloak/org/postgresql/main/module.xml"
mode: 0750
owner: "{{wildfly_user}}"
group: "{{wildfly_group}}"
remote_src: yes

- name: Create a directory for SMS provider configuration
file:
path: "{{keycloak_home}}/bin/sms-provider"
state: directory
mode: 0755

- name: SMS provider configuration file
copy:
src: "/tmp/sunbird_auth_{{sunbird_auth_version}}.config/Msg91Creds.json"
dest: "{{keycloak_home}}/bin/sms-provider/Msg91Creds.json"
owner: "{{wildfly_user}}"
group: "{{wildfly_group}}"
mode: 0755
remote_src: yes

- name: Delete config directory
file:
path: "/tmp/sunbird_auth_{{sunbird_auth_version}}.config"
state: absent

- name: Delete config directory zip
file:
path: "/tmp/sunbird_auth_{{sunbird_auth_version}}.config.zip"
state: absent

- name: start service
become: yes
command: /etc/init.d/keycloak start
poll: 5
async: 5
57 changes: 57 additions & 0 deletions keycloak/scripts/ansible/roles/keycloak/tasks/auth-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
- stat:
path: /etc/init.d/keycloak
register: keycloak_service

- name: status service
become: yes
command: /etc/init.d/keycloak status
register: keycloak
poll: 5
async: 10
when: keycloak_service.stat.islnk is defined

- name: stop service
become: yes
command: /etc/init.d/keycloak stop && Pkill keycloak
when: "keycloak.stdout.find('running') != -1"
poll: 5
async: 10
ignore_errors: yes
when: keycloak_service.stat.islnk is defined

- name: remove keycloak
become: yes
file: path="{{keycloak_home}}" state=absent

- name: change build script permissions
become: yes
file: path=/opt owner={{wildfly_user}} group={{wildfly_group}} mode=0755 recurse=yes

- name: Paste keycloak package on server
copy: src="sunbird_auth_{{sunbird_auth_version}}.zip" dest="/opt/" force=no owner={{wildfly_user}} group={{wildfly_group}}

- name: extarct the folder
unarchive: src="/opt/sunbird_auth_{{sunbird_auth_version}}.zip" dest=/opt/ copy=no owner={{wildfly_user}} group={{wildfly_group}}

- name: move the folder name
command: mv sunbird_auth_{{sunbird_auth_version}} keycloak
args:
chdir: /opt

- name: remove the sunbird_auth_{{sunbird_auth_version}}
become: yes
file: path=/opt/sunbird_auth_{{sunbird_auth_version}} state=absent

- name: Create admin user
become_user: "{{ wildfly_user }}"
command: "{{ wildfly_dir }}/bin/add-user-keycloak.sh -r master -u {{ keycloak_management_user }} -p {{ keycloak_management_password }}"
when: keycloak_management_user is defined and
keycloak_management_password is defined
ignore_errors: yes

- name: start service
become: yes
command: /etc/init.d/keycloak start
poll: 5
async: 5
when: keycloak_service.stat.islnk is defined
27 changes: 26 additions & 1 deletion keycloak/scripts/ansible/roles/keycloak/tasks/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
state: directory
mode: 0755


- name: Get the postgresql driver
get_url: url={{postgresql_driver_src}} dest="sunbird_auth_{{sunbird_auth_version}}/modules/system/layers/keycloak/org/postgresql/main/" force=no

Expand Down Expand Up @@ -44,11 +45,35 @@
mode: 0755

- name: Copy Sunbird login theme
copy: src="artifacts/sunbird/" dest="sunbird_auth_{{sunbird_auth_version}}/themes/sunbird/login/" force="yes"
copy: src="artifacts/sunbird/login/" dest="sunbird_auth_{{sunbird_auth_version}}/themes/sunbird/login/" force="yes"

- name: Copy Custom Validation theme html to sunbird login theme
copy: src="../../sms-provider/templates/" dest="sunbird_auth_{{sunbird_auth_version}}/themes/sunbird/login/" force="yes"

- name: Create directory for sunbird email theme html folder
file:
path: sunbird_auth_{{sunbird_auth_version}}/themes/sunbird/email/html
state: directory
recurse: yes
mode: 0755

- name: Create directory for sunbird email theme messages folder
file:
path: sunbird_auth_{{sunbird_auth_version}}/themes/sunbird/email/messages
state: directory
recurse: yes
mode: 0755

- name: Create directory for sunbird email theme text folder
file:
path: sunbird_auth_{{sunbird_auth_version}}/themes/sunbird/email/text
state: directory
recurse: yes
mode: 0755

- name: Copy Sunbird email theme
copy: src="artifacts/sunbird/email" dest="sunbird_auth_{{sunbird_auth_version}}/themes/sunbird/" force="yes"

- name: Keycloak configuration XML file
template:
src: "roles/keycloak/templates/standalone-ha.xml"
Expand Down

0 comments on commit 1abbfac

Please sign in to comment.