Skip to content

Commit

Permalink
Issue Sunbird-Lern#24 chore:Sunbird auth package build
Browse files Browse the repository at this point in the history
  • Loading branch information
ahghatol committed Dec 19, 2017
1 parent b14fb7c commit 9d6c993
Show file tree
Hide file tree
Showing 10 changed files with 1,294 additions and 0 deletions.
44 changes: 44 additions & 0 deletions keycloak/scripts/ansible/roles/keycloak/tasks/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
- name: Create sunbird auth directory
file:
path: sunbird_auth_{{sunbird_auth_version}}
state: directory
mode: 0755

- name: get the keycloak tarball
get_url: url={{keycloak_pkg_src}} dest=sunbird_auth_{{sunbird_auth_version}} force=no owner={{wildfly_user}} group={{wildfly_group}}

- 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 owner={{wildfly_user}} group={{wildfly_group}}

- name: Clone sunbird auth repo
git:
repo: https://github.com/project-sunbird/sunbird-auth.git
dest: sunbird-auth
refspec: refs/heads/master

- name: Build provider package
shell: cd sunbird-auth/keycloak/sms-provider && mvn package

- name: Copy SMS OTP jar file to providers dir
copy: src=sunbird-auth/keycloak/sms-provider/target/keycloak-email-phone-autthenticator-1.0-SNAPSHOT.jar dest="sunbird_auth_{{sunbird_auth_version}}/providers"

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

- name: Copy configuration templates to Keycloak
copy: src=sunbird-auth/keycloak/scripts/ansible/roles/keycloak/templates/ dest="sunbird_auth_{{sunbird_auth_version}}/standalone/configuration/standalone-ha.xml"

- name: XML file
template:
src: sunbird-auth/keycloak/scripts/ansible/roles/keycloak/templates/standalone-ha.xml
dest: "sunbird_auth_{{sunbird_auth_version}}/standalone/configuration/standalone-ha.xml"

- name: Copy module.xml
template:
src: sunbird-auth/keycloak/scripts/ansible/roles/keycloak/templates/module.xml.j2
dest: "sunbird_auth_{{sunbird_auth_version}}/modules/system/layers/keycloak/org/postgresql/main/module.xml"

- name: Create SMS provider configuration file
template:
src: "sunbird-auth/keycloak/scripts/ansible/roles/keycloak/Msg91Creds.json.j2"
dest: "sunbird_auth_{{sunbird_auth_version}}/bin/sms-provider/Msg91Creds.json"
4 changes: 4 additions & 0 deletions keycloak/scripts/ansible/roles/keycloak/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- include: build.yml
tags:
- build

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"auth_key": "{{vault_auth_key}}",
"sender": "{{vault_sender}}",
"country": "{{vault_country}}",
"route": "{{vault_route}}",
"sms_method_type": "{{vault_sms_method_type}}"
}
10 changes: 10 additions & 0 deletions keycloak/scripts/ansible/roles/keycloak/templates/module.xml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.postgresql">
<resources>
<resource-root path="postgresql-9.4.1212.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
571 changes: 571 additions & 0 deletions keycloak/scripts/ansible/roles/keycloak/templates/standalone-ha.xml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions keycloak/scripts/ansible/roles/keycloak/vars/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
sunbird_auth_version: 1.0v
keycloak_pkg_src: https://downloads.jboss.org/keycloak/3.2.0.Final/keycloak-3.2.0.Final.tar.gz
postgresql_driver_src: https://jdbc.postgresql.org/download/postgresql-9.4.1212.jar
70 changes: 70 additions & 0 deletions keycloak/scripts/pipelines/keycloak-build/Jenkinsfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!groovy

node('build-slave') {

currentBuild.result = "SUCCESS"

try {

stage('Cleanup'){
sh('rm -rf sunbird-auth')
sh('rm -rf project-sunbird-devops')
sh('rm -rf keycloak-3.2.0.Final.tar.gz')
sh('rm -rf keycloak_build/login.tar.gz')
sh('rm -rf ansible/artifacts/sunbird/login.tar.gz')
sh('rm -rf keycloak_build')
}

stage('Checkout'){
checkout scm
sh('git clone https://github.com/project-sunbird/sunbird-auth.git')

// @Todo Update the URL
// sh('git clone https://github.com/ahghatol/sunbird-devops-1.git project-sunbird-devops')

sh('git clone https://github.com/project-sunbird/sunbird-devops project-sunbird-devops')

// Download keycloak package and driver
sh('wget https://downloads.jboss.org/keycloak/3.2.0.Final/keycloak-3.2.0.Final.tar.gz')
sh('wget https://jdbc.postgresql.org/download/postgresql-9.4.1212.jar')
}

stage('Build'){
sh('mkdir -p sunbird-auth-0.1v');

// Login theme build
sh('cd ansible/artifacts/sunbird && tar -zcvf login.tar.gz *')

// Sms plugin build
sh('cd sunbird-auth/keycloak/sms-provider && mvn package')


sh('cp keycloak-3.2.0.Final.tar.gz keycloak_build')
sh('cp postgresql-9.4.1212.jar keycloak_build')

// Copy file to keycloak_build directory
sh('cp sunbird-auth/keycloak/sms-provider/target/keycloak-email-phone-autthenticator-1.0-SNAPSHOT.jar keycloak_build')

// Create zip and Copy file to keycloak_build directory
sh('cd sunbird-auth/keycloak/sms-provider/templates && tar -zcvf templates.tar.gz *')
sh('cp sunbird-auth/keycloak/sms-provider/templates/templates.tar.gz keycloak_build')

// Copy ansible template for Provider config and keycloak configuration
sh('mkdir -p keycloak_build/ansible-templates');

sh('cp project-sunbird-devops/ansible/roles/keycloak/templates/* keycloak_build/ansible-templates')

sh('cp ansible/artifacts/sunbird/login.tar.gz keycloak_build')
sh('tar -zcvf keycloak_build.tar.gz keycloak_build')
}

stage('Archive'){
archiveArtifacts 'keycloak_build/login.tar.gz'
archiveArtifacts 'keycloak_build.tar.gz'
}
}
catch (err) {
currentBuild.result = "FAILURE"
throw err
}
}
27 changes: 27 additions & 0 deletions keycloak/scripts/pipelines/keycloak-build/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
# Build script
# set -o errexit

#!/bin/sh
# Build script
# set -o errexit
set -e
e () {
echo $( echo ${1} | jq ".${2}" | sed 's/\"//g')
}
m=$(cat $METADATA_FILE)

org=$(e "${m}" "org")
name=$(e "${m}" "name")
version=$(e "${m}" "version")

artifactLabel=${ARTIFACT_LABEL:-bronze}
env=${ENV:-null}

echo "artifactLabel: ${artifactLabel}"
echo "env: ${env}"
echo "org: ${org}"
echo "name: ${name}"
echo "version: ${version}"
echo "ANSIBLE_PATH: $ANSIBLE_PATH"

1 change: 1 addition & 0 deletions keycloak/scripts/pipelines/keycloak-build/installDeps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apk -v add ansible=2.3.0.0-r1

0 comments on commit 9d6c993

Please sign in to comment.