mirror of
https://github.com/geerlingguy/ansible-role-docker.git
synced 2024-11-18 19:10:43 +01:00
Initial commit.
This commit is contained in:
commit
da3eb9cf1c
42
.travis.yml
Normal file
42
.travis.yml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
---
|
||||||
|
services: docker
|
||||||
|
|
||||||
|
env:
|
||||||
|
- distro: centos7
|
||||||
|
init: /usr/lib/systemd/systemd
|
||||||
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||||
|
- distro: ubuntu1604
|
||||||
|
init: /lib/systemd/systemd
|
||||||
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||||
|
- distro: ubuntu1404
|
||||||
|
init: /sbin/init
|
||||||
|
run_opts: ""
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
# Pull container.
|
||||||
|
- 'docker pull geerlingguy/docker-${distro}-ansible:latest'
|
||||||
|
|
||||||
|
script:
|
||||||
|
- container_id=$(mktemp)
|
||||||
|
# Run container in detached state.
|
||||||
|
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'
|
||||||
|
|
||||||
|
# Ansible syntax check.
|
||||||
|
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check'
|
||||||
|
|
||||||
|
# Test role.
|
||||||
|
- 'docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml'
|
||||||
|
|
||||||
|
# Test role idempotence.
|
||||||
|
- idempotence=$(mktemp)
|
||||||
|
- docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence}
|
||||||
|
- >
|
||||||
|
tail ${idempotence}
|
||||||
|
| grep -q 'changed=0.*failed=0'
|
||||||
|
&& (echo 'Idempotence test: pass' && exit 0)
|
||||||
|
|| (echo 'Idempotence test: fail' && exit 1)
|
||||||
|
|
||||||
|
# TODO: Test whether Docker is running correctly.
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
35
README.md
Normal file
35
README.md
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# Ansible Role: Docker
|
||||||
|
|
||||||
|
[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-docker.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-docker)
|
||||||
|
|
||||||
|
An Ansible Role that installs [Docker](https://www.docker.com) on Debian/Ubuntu.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
## Role Variables
|
||||||
|
|
||||||
|
Available variables are listed below, along with default values (see `defaults/main.yml`):
|
||||||
|
|
||||||
|
TODO.
|
||||||
|
|
||||||
|
TODO.
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
## Example Playbook
|
||||||
|
|
||||||
|
- hosts: all
|
||||||
|
roles:
|
||||||
|
- geerlingguy.docker
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT / BSD
|
||||||
|
|
||||||
|
## Author Information
|
||||||
|
|
||||||
|
This role was created in 2017 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).
|
5
defaults/main.yml
Normal file
5
defaults/main.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
docker_package: "docker-engine"
|
||||||
|
|
||||||
|
# Used only for Debian/Ubuntu. Add 'testing' if you don't want stable.
|
||||||
|
docker_apt_repository: "deb https://apt.dockerproject.org/repo {{ ansible_distribution|lower }}-{{ ansible_distribution_release }} main"
|
3
handlers/main.yml
Normal file
3
handlers/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
- name: restart docker
|
||||||
|
service: name=docker state=restarted
|
29
meta/main.yml
Normal file
29
meta/main.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
dependencies: []
|
||||||
|
|
||||||
|
galaxy_info:
|
||||||
|
author: geerlingguy
|
||||||
|
description: Docker for Linux.
|
||||||
|
company: "Midwestern Mac, LLC"
|
||||||
|
license: "license (BSD, MIT)"
|
||||||
|
min_ansible_version: 2.0
|
||||||
|
platforms:
|
||||||
|
- name: EL
|
||||||
|
versions:
|
||||||
|
- 6
|
||||||
|
- 7
|
||||||
|
- name: Debian
|
||||||
|
versions:
|
||||||
|
- jessie
|
||||||
|
- name: Ubuntu
|
||||||
|
versions:
|
||||||
|
- trusty
|
||||||
|
- xenial
|
||||||
|
galaxy_tags:
|
||||||
|
- web
|
||||||
|
- system
|
||||||
|
- containers
|
||||||
|
- docker
|
||||||
|
- orchestration
|
||||||
|
- compose
|
||||||
|
- server
|
15
tasks/main.yml
Normal file
15
tasks/main.yml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
- include: setup-RedHat.yml
|
||||||
|
when: ansible_os_family == 'RedHat'
|
||||||
|
|
||||||
|
- include: setup-Debian.yml
|
||||||
|
when: ansible_os_family == 'Debian'
|
||||||
|
|
||||||
|
- name: Install Docker.
|
||||||
|
package: name={{ docker_package }} state=present
|
||||||
|
|
||||||
|
- name: Ensure Docker is started and enabled at boot.
|
||||||
|
service:
|
||||||
|
name: docker
|
||||||
|
state: started
|
||||||
|
enabled: yes
|
20
tasks/setup-Debian.yml
Normal file
20
tasks/setup-Debian.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
- name: Ensure depdencies are installed.
|
||||||
|
apt:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: present
|
||||||
|
with_items:
|
||||||
|
- apt-transport-https
|
||||||
|
- ca-certificates
|
||||||
|
|
||||||
|
- name: Add Docker apt key.
|
||||||
|
apt_key:
|
||||||
|
url: https://apt.dockerproject.org/gpg
|
||||||
|
id: 58118E89F3A912897C070ADBF76221572C52609D
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Add Docker repository.
|
||||||
|
apt_repository:
|
||||||
|
repo: "{{ docker_apt_repository }}"
|
||||||
|
state: present
|
||||||
|
update_cache: yes
|
13
tasks/setup-RedHat.yml
Normal file
13
tasks/setup-RedHat.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
# - name: Add Docker GPG key.
|
||||||
|
# rpm_key:
|
||||||
|
# key: https://apt.dockerproject.org/gpg
|
||||||
|
# state: present
|
||||||
|
|
||||||
|
- name: Add Docker repository.
|
||||||
|
yum_repository:
|
||||||
|
name: docker
|
||||||
|
description: Docker repository.
|
||||||
|
baseurl: https://docs.docker.com/engine/installation/linux/repo_files/centos/docker.repo
|
||||||
|
gpgkey: https://apt.dockerproject.org/gpg
|
||||||
|
gpgcheck: yes
|
13
tests/test.yml
Normal file
13
tests/test.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
- hosts: all
|
||||||
|
|
||||||
|
pre_tasks:
|
||||||
|
- name: Update apt cache.
|
||||||
|
apt: update_cache=yes cache_valid_time=600
|
||||||
|
when: ansible_os_family == 'Debian'
|
||||||
|
|
||||||
|
- name: Install test dependencies.
|
||||||
|
package: name=curl state=present
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role_under_test
|
Loading…
Reference in New Issue
Block a user