![]()
What is Ansible ?
Ansible is a software built in Python. A very easy framework for configuration management & application deployment with 100% automation and continuous integration. Ansible is an agent-less software, which means you can control destination machine without installing agents on it. For more information, you can refer https://www.ansible.com/
How to deploy WSO2 Identity server with Ansible in Ubuntu?
Prerequisites : You should have two machines at least to test it. One your Local machine and another Remote machine. Consider both the machines are running in Ubuntu 14.x, the IP addresses of the Local machine is 192.168.9.15 , the Remote machine is 10.10.100.172 and the MySQL database server is 192.168.9.6.
Setup SSH keys in both Local and Remote machine.
- [Local machine] Create SSH key in Local machine
[crayon-58586dcb7ee77681814101/]
- [Local machine] Store the key and phrase
[crayon-58586dcb7ee87461389522/]
- [Local machine] The whole key generation process looks like below:
[crayon-58586dcb7ee90804849261/]
- [Local machine] The public key is in /home/shankar/.ssh/id_rsa.pub The private key is in /home/shankar/.ssh/id_rsa
- [Local machine] The public key needs to be copied to the remote machine. For doing that use the below command from Local Machine
[crayon-58586dcb7ee99087713091/]
- You will get an output of the command as below authenticity of host '10.10.100.17 (10.10.100.172)' can't be established.
[crayon-58586dcb7eea1776382476/]
Creating Ansible Scripts to deploy WSO2 Identity Server
- [Local Machine] Install ansible on your local machine,
[crayon-58586dcb7eeaa912491429/]
- [Local Machine] Create a folder in home directory called ansible and navigate to it,
[crayon-58586dcb7eeb2100692684/]
- [Local Machine] Create two files hosts and playbook.yml inside ansible folder
[crayon-58586dcb7eeba216374031/]
- [Local Machine] Open hosts and give the IP for remote host under host called "[wso2server]". Paste the below content in hosts files
[crayon-58586dcb7eec2877613446/]
- [Local Machine] Open playbook.yml and give the role and host. Paste the below content in hosts files
[crayon-58586dcb7eecb395890064/]
- [Local Machine] Create roles within Ansible for different purposes, here we are going to create one role for setting up considering MySQL database server is up and running. Use below command to create role "server"
[crayon-58586dcb7eed4647972816/]
- [Local Machine] The above command will create a directory called roles/server also, the output of above command looks like below
[crayon-58586dcb7eedc109579598/]
[crayon-58586dcb7eee5558787709/]
- Paste the below content
[crayon-58586dcb7eeed941741524/]
- [Local Machine] Create a folder called files in your ansible directory to keep the source of WSO2 IS server
-
[crayon-58586dcb7eefc064419785/]
- [Local Machine] These two files are configuration files which are used for configuring the MySQL database (master-datasources.xml.j2) and configuring the WSO2 IS server startup scripts.
-
[crayon-58586dcb7ef06153494570/]
- [Local Machine] Paste the below content inside master-datasources.xml.j2
[crayon-58586dcb7ef0f324398209/]
- [Local Machine] Server init.d scripts has to be placed in wos2is.j2
[crayon-58586dcb7ef20463495299/]
- [Local Machine] Paste the below code in wso2is.j2
[crayon-58586dcb7ef2a910405267/]
- [Local Machine] Download WSO2 IS and place it inside files folder.
[crayon-58586dcb7ef33034355366/]
- [Local Machine] Configure the variable for Database and other stuffs in ~/ansible/roles/server/defaults/main.yml file
[crayon-58586dcb7ef3a254220081/]
- [Local Machine] Paste the below code in it.
[crayon-58586dcb7ef43867796040/]
- Once you're done with all the configuration as mentioned above, run the below command.
[crayon-58586dcb7ef4b210539060/]
- [Local Machine] Give the password for the user "shankar" created in remote machine(10.10.100.172) You should wait for the script to get executed without failure if something failed you can write a comment to this post or follow the steps carefully.