-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrole.yml
51 lines (50 loc) · 1.61 KB
/
role.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
- name: demo
hosts: localhost
roles:
- Azure.azure_preview_modules
vars:
resource_group: yungez-demo
registry_name: ansibleroledemo
repo_url: "https://github.com/yungez/helloworld.git"
workspace: ~/src/helloworld
image_name: helloworld
http_port: 80
email: test@email.com
tasks:
- name: Git Clone
git:
repo: "{{ repo_url }}"
dest: "{{ workspace }}"
- name: Create Azure Container Registry
azure_rm_containerregistry:
resource_group: "{{ resource_group }}"
name: "{{ registry_name}}"
admin_user_enabled: True
sku: Standard
register: acr_result
- name: Login docker registry
docker_login:
registry: "{{ registry_name }}.azurecr.io"
username: "{{ registry_name }}"
password: "{{ acr_result.credentials.password }}"
email: "{{ email }}"
- name: Docker Build and Push
docker_image:
path: "{{ workspace }}"
name: "{{ registry_name }}.azurecr.io/{{ image_name }}"
push: yes
- name: Create Azure Container Instance
azure_rm_containerinstance:
resource_group: "{{ resource_group }}"
name: "{{ image_name }}"
ip_address: public
ports:
- "{{ http_port }}"
registry_login_server: "{{ registry_name }}.azurecr.io"
registry_username: "{{ registry_name }}"
registry_password: "{{ acr_result.credentials.password }}"
containers:
- name: "{{ image_name }}"
ports:
- "{{ http_port }}"
image: "{{ registry_name }}.azurecr.io/{{ image_name }}"