v1
This commit is contained in:
7
main.yml
7
main.yml
@@ -1,6 +1,11 @@
|
|||||||
---
|
---
|
||||||
- name: main task
|
- name: main task
|
||||||
hosts: "{{ inputHostsGroups }}"
|
hosts: "{{ inputHostsGroups }}"
|
||||||
gather_facts: false
|
become: yes
|
||||||
|
vars:
|
||||||
|
build_root_abspath: "/home/dietpi/build/{{ ansible_date_time.iso8601_basic_short }}"
|
||||||
|
demobackend_version: "latest"
|
||||||
roles:
|
roles:
|
||||||
- role: demolamp
|
- role: demolamp
|
||||||
|
collections:
|
||||||
|
- community.docker
|
||||||
@@ -2,6 +2,35 @@
|
|||||||
- name: show remote host
|
- name: show remote host
|
||||||
debug:
|
debug:
|
||||||
msg: "the remote server is {{ ansible_host }}"
|
msg: "the remote server is {{ ansible_host }}"
|
||||||
- name: show vars of this playbook
|
- name: create build dir if not exists
|
||||||
|
file:
|
||||||
|
path: "{{ build_root_abspath }}"
|
||||||
|
state: directory
|
||||||
|
- name: demolamp
|
||||||
|
community.docker.docker_image:
|
||||||
|
name: demolamp
|
||||||
|
source: build
|
||||||
|
build:
|
||||||
|
path: "{{ build_root_abspath }}"
|
||||||
|
pull: false
|
||||||
|
tag: "{{ demobackend_version }}"
|
||||||
|
- name: run docker
|
||||||
|
community.docker.docker_container:
|
||||||
|
name: demolamp
|
||||||
|
state: started
|
||||||
|
recreate: yes
|
||||||
|
image: "demolamp:{{ demobackend_version }}"
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
- name: wait for the api ready
|
||||||
|
wait_for:
|
||||||
|
host: 0.0.0.0
|
||||||
|
port: 80
|
||||||
|
delay: 10
|
||||||
|
- name: testing api locally
|
||||||
|
shell: "curl -k localhost:80"
|
||||||
|
register: reg_curl_result
|
||||||
|
- name: show curl result
|
||||||
debug:
|
debug:
|
||||||
msg: "{{ greeting }}"
|
msg: "{{ reg_curl_result.stdout }}"
|
||||||
|
|
||||||
Reference in New Issue
Block a user