This content originally appeared on DEV Community and was authored by DEV Community
create an ansible file to install docker and create docker images
---
- hosts: docker
become: true
vars:
container_count: 1
default_container_name: docker
default_container_image: ubuntu
default_container_command: sleep 1d
tasks:
- name: Install aptitude
apt:
name: aptitude
state: latest
update_cache: true
- name: Install required system packages
apt:
pkg:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
- python3-pip
- virtualenv
- python3-setuptools
state: latest
update_cache: true
- name: Add Docker GPG apt Key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker Repdoository
apt_repository:
repo: deb https://download.docker.com/linux/ubuntu focal stable
state: present
- name: Update apt and install docker-ce
apt:
name: docker-ce
state: latest
update_cache: true
notify: Restart docker
- name: Install Docker Module for Python
pip:
name: docker
- name: Pull default Docker image
docker_image:
name: "{{ default_container_image }}"
source: pull
- name: Create default containers
docker_container:
name: "{{ default_container_name }}{{ item }}"
image: "{{ default_container_image }}"
command: "{{ default_container_command }}"
state: present
with_sequence: count={{ container_count }}
handlers:
- name: Restart docker
service:
name: docker
state: restarted
This content originally appeared on DEV Community and was authored by DEV Community
Print
Share
Comment
Cite
Upload
Translate
Updates
There are no updates yet.
Click the Upload button above to add an update.
APA
MLA
DEV Community | Sciencx (2022-03-13T08:24:36+00:00) Ansible to install docker and create docker images. Retrieved from https://www.scien.cx/2022/03/13/ansible-to-install-docker-and-create-docker-images/
" » Ansible to install docker and create docker images." DEV Community | Sciencx - Sunday March 13, 2022, https://www.scien.cx/2022/03/13/ansible-to-install-docker-and-create-docker-images/
HARVARDDEV Community | Sciencx Sunday March 13, 2022 » Ansible to install docker and create docker images., viewed ,<https://www.scien.cx/2022/03/13/ansible-to-install-docker-and-create-docker-images/>
VANCOUVERDEV Community | Sciencx - » Ansible to install docker and create docker images. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/03/13/ansible-to-install-docker-and-create-docker-images/
CHICAGO" » Ansible to install docker and create docker images." DEV Community | Sciencx - Accessed . https://www.scien.cx/2022/03/13/ansible-to-install-docker-and-create-docker-images/
IEEE" » Ansible to install docker and create docker images." DEV Community | Sciencx [Online]. Available: https://www.scien.cx/2022/03/13/ansible-to-install-docker-and-create-docker-images/. [Accessed: ]
rf:citation » Ansible to install docker and create docker images | DEV Community | Sciencx | https://www.scien.cx/2022/03/13/ansible-to-install-docker-and-create-docker-images/ |
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.