-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.yaml
35 lines (32 loc) · 1.18 KB
/
deploy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- name: Deploy updated application
hosts: nodejs_group
become: true
vars:
ansible_python_interpreter: /usr/bin/python3 # Assuming Python path is consistent
app_path: /usr/src/app # Application path from existing tasks
image_name: my-nodejs-app # Image name from existing tasks
image_tag: latest # Tag for the Docker image
git_repo: your_git_repository_url # Git repository URL
git_version: main # Branch to pull from
tasks:
- name: Pull latest code from Git
ansible.builtin.git:
repo: "{{ git_repo }}"
dest: "{{ app_path }}"
version: "{{ git_version }}"
- name: Build Docker image
community.docker.docker_image:
build:
path: "{{ app_path }}"
name: "{{ image_name }}"
tag: "{{ image_tag }}"
source: build
- name: Restart Docker container
community.docker.docker_container:
name: "{{ image_name }}"
image: "{{ image_name }}:{{ image_tag }}"
state: started
ports:
- "80:3000"
recreate: true
restart_policy: always