Compare commits
2 Commits
feature/an
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92602e6c79 | ||
|
|
bcff7b9713 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
.idea/*
|
.idea/*
|
||||||
|
target
|
||||||
48
Jenkinsfile
vendored
48
Jenkinsfile
vendored
@@ -1,38 +1,36 @@
|
|||||||
|
def gv
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
environment {
|
|
||||||
ANSIBLE_SERVER = "167.99.136.157"
|
|
||||||
}
|
|
||||||
stages {
|
stages {
|
||||||
stage("copy files to ansible server") {
|
stage("init") {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
echo "copying all neccessary files to ansible control node"
|
gv = load "script.groovy"
|
||||||
sshagent(['ansible-server-key']) {
|
|
||||||
sh "scp -o StrictHostKeyChecking=no ansible/* root@${ANSIBLE_SERVER}:/root"
|
|
||||||
|
|
||||||
withCredentials([sshUserPrivateKey(credentialsId: 'ec2-server-key', keyFileVariable: 'keyfile', usernameVariable: 'user')]) {
|
|
||||||
sh 'scp $keyfile root@$ANSIBLE_SERVER:/root/ssh-key.pem'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
stage("build jar") {
|
||||||
}
|
|
||||||
stage("execute ansible playbook") {
|
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
echo "calling ansible playbook to configure ec2 instances"
|
echo "building jar"
|
||||||
def remote = [:]
|
//gv.buildJar()
|
||||||
remote.name = "ansible-server"
|
}
|
||||||
remote.host = ANSIBLE_SERVER
|
}
|
||||||
remote.allowAnyHosts = true
|
}
|
||||||
|
stage("build image") {
|
||||||
withCredentials([sshUserPrivateKey(credentialsId: 'ansible-server-key', keyFileVariable: 'keyfile', usernameVariable: 'user')]){
|
steps {
|
||||||
remote.user = user
|
script {
|
||||||
remote.identityFile = keyfile
|
echo "building image"
|
||||||
sshScript remote: remote, script: "prepare-ansible-server.sh"
|
//gv.buildImage()
|
||||||
sshCommand remote: remote, command: "ansible-playbook my-playbook.yaml"
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
stage("deploy") {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
echo "deploying"
|
||||||
|
//gv.deployApp()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
[defaults]
|
|
||||||
host_key_checking = False
|
|
||||||
inventory = inventory_aws_ec2.yaml
|
|
||||||
|
|
||||||
interpreter_python = /usr/bin/python3
|
|
||||||
enable_plugins = aws_ec2
|
|
||||||
|
|
||||||
remote_user = ec2-user
|
|
||||||
private_key_file = ~/ssh-key.pem
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
plugin: aws_ec2
|
|
||||||
regions:
|
|
||||||
- eu-west-3
|
|
||||||
keyed_groups:
|
|
||||||
- key: tags
|
|
||||||
prefix: tag
|
|
||||||
- key: instance_type
|
|
||||||
prefix: instance_type
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Install python3, docker, docker-compose
|
|
||||||
hosts: all
|
|
||||||
become: yes
|
|
||||||
gather_facts: False
|
|
||||||
tasks:
|
|
||||||
- name: Install python3 and docker
|
|
||||||
vars:
|
|
||||||
ansible_python_interpreter: /usr/bin/python
|
|
||||||
yum:
|
|
||||||
name:
|
|
||||||
- python3
|
|
||||||
- docker
|
|
||||||
update_cache: yes
|
|
||||||
state: present
|
|
||||||
- name: Install Docker-compose
|
|
||||||
get_url:
|
|
||||||
url: https://github.com/docker/compose/releases/download/1.27.4/docker-compose-Linux-{{lookup('pipe', 'uname -m')}}
|
|
||||||
dest: /usr/local/bin/docker-compose
|
|
||||||
mode: +x
|
|
||||||
- name: Start docker daemon
|
|
||||||
systemd:
|
|
||||||
name: docker
|
|
||||||
state: started
|
|
||||||
- name: Install docker python module
|
|
||||||
pip:
|
|
||||||
name:
|
|
||||||
- docker
|
|
||||||
- docker-compose
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
apt update
|
|
||||||
apt install ansible -y
|
|
||||||
apt install python3-pip -y
|
|
||||||
pip3 install boto3 botocore
|
|
||||||
11
src/main/resources/static/index.html
Normal file
11
src/main/resources/static/index.html
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>MyApp</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Welcome to Java Maven Application</h1>
|
||||||
|
<!-- add image here <img src="" width="" /> -->
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user