29 lines
636 B
YAML
29 lines
636 B
YAML
---
|
|
- name: Create and run container
|
|
hosts: all
|
|
become : true
|
|
vars:
|
|
image_name: ubuntu
|
|
image_tag: latest
|
|
image_hostname: ubuntu
|
|
image_network:
|
|
- wp_net
|
|
image_volumes:
|
|
- "/usr/data/wp/wordpress/:/var/www"
|
|
|
|
|
|
tasks:
|
|
- name: Pull Image
|
|
docker_image:
|
|
name: "{{ image_name }}:{{ image_tag }}"
|
|
source: pull
|
|
|
|
- name: Create container with pulled image
|
|
docker_container:
|
|
name: "{{ image_name }}"
|
|
image: "{{ image_name }}"
|
|
networks:
|
|
- name: "{{ image_network }}"
|
|
hostname: "{{ image_hostname }}"
|
|
volumes: "{{image_volumes}}"
|
|
restart: true |