-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpython-flask.yml
54 lines (53 loc) · 1.46 KB
/
python-flask.yml
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
- name: "Docker Image build & Push To Docker Hub"
hosts: localhost
become: true
vars:
git_repo_url: "Mention-GitHub-Repository"
git_clone: "Mention-Clone-Directory"
image_name: "Mention-Image-Name"
docker_password: "Mention-DockerHub-Password"
docker_username: "Mention-DockerHub-Username"
tasks:
- name: "Installing PIP"
yum:
name:
- pip
- git
state: present
- name: "Dependency Install dokcer-py"
pip:
name: docker-py
state: present
- name: "Cloning the conetents From GitHub"
git:
repo: '{{git_repo_url}}'
dest: '{{git_clone}}'
register: repo_status
- name: "Installing Docker"
shell: amazon-linux-extras install docker -y
- name: "Docker Service Starting / Enabling"
service:
name: docker
state: restarted
enabled: true
- name: "Log into DockerHub"
docker_login:
username: "{{docker_username}}"
password: "{{docker_password}}"
- name: "Build Python Image"
docker_image:
source: build
build:
path: "{{git_clone}}"
name: "{{image_name}}"
tag: latest
push: true
- name: "Removing Image Created"
docker_image:
state: absent
name: "{{ image_name }}"
tag: "{{ item }}"
with_items:
- "{{ repo_status.after }}"
- latest