diff --git a/solutions/WebDeploy_Demonstration.docx b/solutions/WebDeploy_Demonstration.docx new file mode 100644 index 0000000..263f77e Binary files /dev/null and b/solutions/WebDeploy_Demonstration.docx differ diff --git a/solutions/jenkinsfile b/solutions/jenkinsfile new file mode 100644 index 0000000..5e463be --- /dev/null +++ b/solutions/jenkinsfile @@ -0,0 +1,30 @@ +pipeline { + agent any + + environment { + dest_ip = "54.198.18.170" + login_name = "root" + } + stages { + stage('Pre-Build') { + steps { + echo 'Pre-build step' + sh "cd /opt/working/" + sh "rm -rf webdeploy" + } + } + stage('Git Clone') { + steps { + echo 'Clone git repository' + + git clone https://github.com/watchmen-test/webdeploy.git + } + } + stage('Deploy') { + steps { + echo 'Deploy to target server' + sh "scp -rp /opt/working/webdeploy/* $login_name@dest_ip:/var/www/html" + + } + } +} \ No newline at end of file diff --git a/solutions/webdeploy.sh b/solutions/webdeploy.sh new file mode 100755 index 0000000..4a5d963 --- /dev/null +++ b/solutions/webdeploy.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +#User defined variables +Src="/opt/working/" +Dest="/var/www/html" +Login_Name="root" +Dest_IP="54.198.18.170" + +#Cloning from git repo +cd $Src +rm -rf webdeploy +git clone https://github.com/watchmen-test/webdeploy.git + +#Copying files to target server +scp -rp $Src/webdeploy/* $Login_Name@$Dest_IP:$Dest + diff --git a/solutions/webdeploy.yml b/solutions/webdeploy.yml new file mode 100644 index 0000000..3dad04a --- /dev/null +++ b/solutions/webdeploy.yml @@ -0,0 +1,23 @@ +--- + - hosts: webservers + become: true + gather_facts: no + + vars: + repo_url: https://github.com//watchmen-testebdeploy.git + destination: /var/www/html/ + + tasks: + - name: Install dependencies + yum: name={{ item }} state=latest update_cache=yes + with_items: + - git + - httpd + + - name: Git pull and deploy + git: repo={{ repo_url }} dest={{ destination }} + notify: restart httpd + + handlers: + - name: restart httpd + service: name=httpd state=restarted diff --git a/test-app/index.html b/test-app/index.html index f3bfea8..b410612 100644 --- a/test-app/index.html +++ b/test-app/index.html @@ -13,7 +13,9 @@ - + +

Webdeploy Technical Screening

- \ No newline at end of file +