This repository has been archived by the owner on Dec 28, 2022. It is now read-only.
forked from geerlingguy/ansible-for-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.yml
56 lines (49 loc) · 1.48 KB
/
main.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
55
56
---
- hosts: localhost
gather_facts: false
vars:
image_name: hello-go
image_tag: latest
tasks:
- name: Build the Hello Go image.
docker_image:
build:
path: ../hello-go
pull: false
name: '{{ image_name }}'
tag: '{{ image_tag }}'
source: build
- name: Run the Hello Go image.
docker_container:
name: hello-go
image: '{{ image_name }}:{{ image_tag }}'
state: started
published_ports:
- 8180:8180
- name: Verify Hello Go is responding.
uri:
url: http://localhost:8180/test
return_content: true
register: hello_go_response
failed_when: "'/test' not in hello_go_response.content"
- name: Stop and remove the Hello Go container.
docker_container:
name: hello-go
state: absent
post_tasks:
- name: Log into Docker registry.
docker_login:
registry: '{{ registry_url }}'
username: '{{ registry_username }}'
password: '{{ registry_password }}'
when:
- registry_url is defined and registry_url != ''
- registry_username is defined and registry_username != ''
- registry_password is defined and registry_password != ''
- name: Push Hello Go image to Docker registry.
docker_image:
name: '{{ image_name }}'
tag: '{{ image_tag }}'
repository: 'localhost:5000/{{ image_name }}:{{ image_tag }}'
push: true
source: local