From a7d61bb1a047ff4110561116197f0f78e7d0ab90 Mon Sep 17 00:00:00 2001 From: Madhuri-chinta <2509.sweety@gmail.com> Date: Tue, 14 Mar 2023 21:46:05 +0530 Subject: [PATCH] added changes --- ansible/madhuri.service | 11 ++++++++++ ansible/spc.yaml | 28 ++++++++++++++++++++++++ spc.yaml | 48 ----------------------------------------- spc1.yaml | 32 --------------------------- 4 files changed, 39 insertions(+), 80 deletions(-) create mode 100644 ansible/madhuri.service create mode 100644 ansible/spc.yaml delete mode 100644 spc.yaml delete mode 100644 spc1.yaml diff --git a/ansible/madhuri.service b/ansible/madhuri.service new file mode 100644 index 000000000..32e7dce2d --- /dev/null +++ b/ansible/madhuri.service @@ -0,0 +1,11 @@ +[Unit] +Description=my springpetclinic application + +[Service] +User=ubuntu +WorkingDirectory=/home/jenkins +ExecStart=/usr/lib/jvm/java-17-openjdk-amd64/bin/java -jar /tmp/spring-petclinic-2.7.3.jar +Restart=always + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/ansible/spc.yaml b/ansible/spc.yaml new file mode 100644 index 000000000..94e768b4e --- /dev/null +++ b/ansible/spc.yaml @@ -0,0 +1,28 @@ +--- +- name: install springpetclinic + hosts: all + become: yes + tasks: + - name: install java17 and maven + ansible.builtin.apt: + name: + - openjdk-17-jdk + - maven + state: present + update_cache: yes + - name: get url from s3 bucket + ansible.builtin.get_url: + url: https://neelu-madhu.s3.ap-south-1.amazonaws.com/spring-petclinic-3.0.0-SNAPSHOT.jar + dest: /tmp + - name: copy service file + ansible.builtin.copy: + src: ./madhuri.service + dest: /etc/systemd/system/spring.service + - name: deamon-reload service + ansible.builtin.systemd: + state: started + daemon_reload: true + enabled: true + name: spring.service + + diff --git a/spc.yaml b/spc.yaml deleted file mode 100644 index c1b7e1679..000000000 --- a/spc.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -- name: spc deployment - hosts: localhost - become: yes - tasks: - - name: install java - ansible.builtin.apt: - name: openjdk-17-jdk - state: present - update_cache: true - - name: make a directory - ansible.builtin.file: - path: spc/ - state: "directory" - mode: '777' - - name: get url - ansible.builtin.get_url: - dest: /tmp/ - url: https://springpetclinic16feb.s3.ap-northeast-1.amazonaws.com/spring-petclinic-3.0.0-SNAPSHOT.jar - mode: '777' - - name: copy the content - ansible.builtin.copy: - src: /tmp/spring-petclinic-3.0.0-SNAPSHOT.jar - dest: spc/ - mode: '777' - - name: edit the service file - ansible.builtin.copy: - dest: /etc/systemd/system/spc.service - content: | - [Unit] - Description=Manage Java service - - [Service] - WorkingDirectory=/home/ubuntu/spc - ExecStart=java -jar spring-petclinic-3.0.0-SNAPSHOT.jar - Type=simple - Restart=on-failure - RestartSec=10 - - [Install] - WantedBy=multi-user.target - mode: '777' - - name: reload the systemd state - ansible.builtin.systemd: - name: spc.service - daemon_reload: true - enabled: true - state: "restarted" \ No newline at end of file diff --git a/spc1.yaml b/spc1.yaml deleted file mode 100644 index ba021c035..000000000 --- a/spc1.yaml +++ /dev/null @@ -1,32 +0,0 @@ ---- -- name: spc deployment - hosts: localhost - become: yes - tasks: - - name: install java - ansible.builtin.apt: - name: openjdk-17-jdk - state: present - update_cache: true - - name: edit the service file - ansible.builtin.copy: - dest: /etc/systemd/system/spc.service - content: | - [Unit] - Description=Manage Java service - - [Service] - WorkingDirectory=/home/ubuntu/spc/target - ExecStart=java -jar spring-petclinic-3.0.0-SNAPSHOT.jar - Type=simple - Restart=on-failure - RestartSec=10 - [Install] - WantedBy=multi-user.target - mode: '777' - - name: reload the systemd state - ansible.builtin.systemd: - name: spc.service - daemon_reload: true - enabled: true - state: "restarted"