Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Shaun Smiley 2019-01-14 10:57:00 -08:00
commit 2628692004
15 changed files with 115 additions and 97 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
*.retry *.retry
tests/test.sh */__pycache__
*.pyc

View File

@ -1,28 +1,31 @@
--- ---
language: python
services: docker services: docker
env: env:
- distro: centos7 global:
- distro: ubuntu1804 - ROLE_NAME: docker
- distro: ubuntu1604 matrix:
- distro: ubuntu1404 - MOLECULE_DISTRO: centos7
- distro: debian9 - MOLECULE_DISTRO: ubuntu1804
- distro: fedora27 - MOLECULE_DISTRO: ubuntu1604
- MOLECULE_DISTRO: ubuntu1404
- MOLECULE_DISTRO: debian9
- MOLECULE_DISTRO: fedora27
install:
# Install test dependencies.
- pip install molecule docker
before_script:
# Use actual Ansible Galaxy role name for the project directory.
- cd ../
- mv ansible-role-$ROLE_NAME geerlingguy.$ROLE_NAME
- cd geerlingguy.$ROLE_NAME
script: script:
# Configure test script so we can run extra tests after playbook is run.
- export container_id=$(date +%s)
- export cleanup=false
# Download test shim.
- wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
- chmod +x ${PWD}/tests/test.sh
# Run tests. # Run tests.
- ${PWD}/tests/test.sh - molecule test
# Test whether Docker is running correctly (Dockerception!).
- docker exec --tty ${container_id} docker run hello-world
notifications: notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/ webhooks: https://galaxy.ansible.com/api/v1/notifications/

View File

@ -22,12 +22,12 @@ The `docker_edition` should be either `ce` (Community Edition) or `ee` (Enterpri
You can control whether the package is installed, uninstalled, or at the latest version by setting `docker_package_state` to `present`, `absent`, or `latest`, respectively. Note that the Docker daemon will be automatically restarted if the Docker package is updated. This is a side effect of flushing all handlers (running any of the handlers that have been notified by this and any other role up to this point in the play). You can control whether the package is installed, uninstalled, or at the latest version by setting `docker_package_state` to `present`, `absent`, or `latest`, respectively. Note that the Docker daemon will be automatically restarted if the Docker package is updated. This is a side effect of flushing all handlers (running any of the handlers that have been notified by this and any other role up to this point in the play).
docker_service_state: started docker_service_state: started
docker_service_enabled: yes docker_service_enabled: true
docker_restart_handler_state: restarted docker_restart_handler_state: restarted
Variables to control the state of the `docker` service, and whether it should start on boot. If you're installing Docker inside a Docker container without systemd or sysvinit, you should set these to `stopped` and set the enabled variable to `no`. Variables to control the state of the `docker` service, and whether it should start on boot. If you're installing Docker inside a Docker container without systemd or sysvinit, you should set these to `stopped` and set the enabled variable to `no`.
docker_install_compose: True docker_install_compose: true
docker_compose_version: "1.22.0" docker_compose_version: "1.22.0"
docker_compose_path: /usr/local/bin/docker-compose docker_compose_path: /usr/local/bin/docker-compose

View File

@ -6,11 +6,11 @@ docker_package_state: present
# Service options. # Service options.
docker_service_state: started docker_service_state: started
docker_service_enabled: yes docker_service_enabled: true
docker_restart_handler_state: restarted docker_restart_handler_state: restarted
# Docker Compose options. # Docker Compose options.
docker_install_compose: True docker_install_compose: true
docker_compose_version: "1.22.0" docker_compose_version: "1.22.0"
docker_compose_path: /usr/local/bin/docker-compose docker_compose_path: /usr/local/bin/docker-compose
@ -18,7 +18,7 @@ docker_compose_path: /usr/local/bin/docker-compose
docker_apt_release_channel: stable docker_apt_release_channel: stable
docker_apt_arch: amd64 docker_apt_arch: amd64
docker_apt_repository: "deb [arch={{ docker_apt_arch }}] https://download.docker.com/linux/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} {{ docker_apt_release_channel }}" docker_apt_repository: "deb [arch={{ docker_apt_arch }}] https://download.docker.com/linux/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} {{ docker_apt_release_channel }}"
docker_apt_ignore_key_error: True docker_apt_ignore_key_error: true
# Used only for RedHat/CentOS/Fedora. # Used only for RedHat/CentOS/Fedora.
docker_yum_repo_url: https://download.docker.com/linux/{{ (ansible_distribution == "Fedora") | ternary("fedora","centos") }}/docker-{{ docker_edition }}.repo docker_yum_repo_url: https://download.docker.com/linux/{{ (ansible_distribution == "Fedora") | ternary("fedora","centos") }}/docker-{{ docker_edition }}.repo

View File

@ -18,6 +18,7 @@ galaxy_info:
- name: Debian - name: Debian
versions: versions:
- jessie - jessie
- stretch
- name: Ubuntu - name: Ubuntu
versions: versions:
- trusty - trusty

View File

@ -0,0 +1,29 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
options:
config-file: molecule/default/yaml-lint.yml
platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
provisioner:
name: ansible
lint:
name: ansible-lint
playbooks:
converge: ${MOLECULE_PLAYBOOK:-playbook.yml}
scenario:
name: default
verifier:
name: testinfra
lint:
name: flake8

View File

@ -1,13 +1,12 @@
--- ---
- hosts: all - name: Converge
hosts: all
become: true
pre_tasks: pre_tasks:
- name: Update apt cache. - name: Update apt cache.
apt: update_cache=yes cache_valid_time=600 apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == 'Debian' when: ansible_os_family == 'Debian'
- name: Install test dependencies.
package: name=curl state=present
roles: roles:
- role_under_test - role: geerlingguy.docker

View File

@ -0,0 +1,6 @@
---
extends: default
rules:
line-length:
max: 200
level: warning

View File

@ -0,0 +1,16 @@
---
- name: Ensure containerd service dir exists.
file:
path: /etc/systemd/system/containerd.service.d
state: directory
- name: Add shim to ensure Docker can start in all environments.
template:
src: override.conf.j2
dest: /etc/systemd/system/containerd.service.d/override.conf
register: override_template
- name: Reload systemd daemon if template is changed.
systemd:
daemon_reload: true
when: override_template is changed

View File

@ -3,5 +3,5 @@
user: user:
name: "{{ item }}" name: "{{ item }}"
groups: docker groups: docker
append: yes append: true
with_items: "{{ docker_users }}" with_items: "{{ docker_users }}"

View File

@ -11,36 +11,9 @@
state: "{{ docker_package_state }}" state: "{{ docker_package_state }}"
notify: restart docker notify: restart docker
- name: enable remote docker access # TODO: Remove this shim once 18.09.1 or later is released.
block: - import_tasks: docker-1809-shim.yml
- name: add docker.service.d/override.conf override when: ansible_service_mgr == 'systemd'
copy:
dest: /etc/systemd/system/docker.service.d/startup_options.conf
content: |
# /etc/systemd/system/docker.service.d/override.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375
register: docker_override
- name: reload docker daemon
systemd:
daemon_reload: yes
when: docker_override is changed
- name: restart docker service
service:
name: docker
state: restarted
daemon_reload: yes
when: docker_override is changed
when: (
docker_remote_access is defined
) and (
( docker_remote_access )
)
- name: Ensure Docker is started and enabled at boot. - name: Ensure Docker is started and enabled at boot.
service: service:

View File

@ -1,11 +1,10 @@
--- ---
- name: Ensure old versions of Docker are not installed. - name: Ensure old versions of Docker are not installed.
package: package:
name: '{{ item }}' name:
state: absent
with_items:
- docker - docker
- docker-engine - docker-engine
state: absent
- name: Ensure dependencies are installed. - name: Ensure dependencies are installed.
apt: apt:
@ -29,11 +28,11 @@
- name: Add Docker apt key (alternative for older systems without SNI). - name: Add Docker apt key (alternative for older systems without SNI).
shell: "curl -sSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -" shell: "curl -sSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -"
args: args:
warn: no warn: false
when: add_repository_key is failed when: add_repository_key is failed
- name: Add Docker repository. - name: Add Docker repository.
apt_repository: apt_repository:
repo: "{{ docker_apt_repository }}" repo: "{{ docker_apt_repository }}"
state: present state: present
update_cache: yes update_cache: true

View File

@ -1,12 +1,11 @@
--- ---
- name: Ensure old versions of Docker are not installed. - name: Ensure old versions of Docker are not installed.
package: package:
name: '{{ item }}' name:
state: absent
with_items:
- docker - docker
- docker-common - docker-common
- docker-engine - docker-engine
state: absent
- name: Add Docker GPG key. - name: Add Docker GPG key.
rpm_key: rpm_key:

View File

@ -0,0 +1,3 @@
# {{ ansible_managed }}
[Service]
ExecStartPre=

View File

@ -1,11 +0,0 @@
# Ansible Role tests
To run the test playbook(s) in this directory:
1. Install and start Docker.
1. Download the test shim (see .travis.yml file for the URL) into `tests/test.sh`:
- `wget -O tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/`
1. Make the test shim executable: `chmod +x tests/test.sh`.
1. Run (from the role root directory) `distro=[distro] playbook=[playbook] ./tests/test.sh`
If you don't want the container to be automatically deleted after the test playbook is run, add the following environment variables: `cleanup=false container_id=$(date +%s)`