added ansible

This commit is contained in:
Mekalaabhiramreddy 2023-03-17 15:44:13 +05:30
parent 27fff64e72
commit 11428fbd8d
2 changed files with 41 additions and 0 deletions

29
abhi.yaml Normal file
View file

@ -0,0 +1,29 @@
---
- name: spring
become: all
hosts: yes
tasks:
- name: installing openjdk-17-jdk
ansible.builtin.apt:
name: openjdk-17-jdk
state: present
- name: creating directory
ansible.builtin.file:
path: /home/devops/
state: directory
mode: "777"
- name: download package
ansible.builtin.get_url:
url: "https://abhiram13.jfrog.io/artifactory/jfrog/org/springframework/samples/spring-petclinic/3.0.0-SNAPSHOT/spring-petclinic-3.0.0-SNAPSHOT.jar"
dest: /home/devops/
mode: "777"
- name: copy servicefile
ansible.builtin.copy:
src: spring.service
dest: /etc/systemd/system/spring.service
- name: service file
ansible.builtin.systemd:
name: spring
state: started
enabled: yes

12
spring.service Normal file
View file

@ -0,0 +1,12 @@
[Unit]
Description=for running spring service
[Service]
user=devops
Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64/bin"
WorkingDirectory=/home/devops/
ExecStart=/tmp/ java -jar spring-petclinic-3.0.0-SNAPSHOT.jar
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target