Merge pull request #1 from mongrelion/master

update
master
Paweł Krupa 7 years ago committed by GitHub
commit 754dc5d40b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

4
.gitignore vendored

@ -1,5 +1,9 @@
# Ignore Vagrant cache files
/.vagrant/
# Ignore molecule and pytest files
**__pycache__**
.molecule
# Ignore retry files
*.retry

@ -1,29 +1,20 @@
---
sudo: required
language: python
python: "2.7"
# Use the new container infrastructure
sudo: false
# Install ansible
addons:
apt:
packages:
- python-pip
cache: pip
services:
- docker
env:
- ANSIBLE='ansible>=2.2.0,<2.3.0'
- ANSIBLE='ansible>=2.3.0,<2.4.0'
- ANSIBLE='ansible>=2.4.0,<2.5.0'
install:
# Install ansible
- pip install ansible
# Check ansible version
- ansible --version
# Create ansible.cfg with correct roles_path
- printf '[defaults]\nroles_path=../' >ansible.cfg
- pip install ${ANSIBLE} 'ansible-lint>=3.4.15' 'molecule==1.25.0' docker git-semver 'testinfra>=1.7.0,<=1.10.1'
before_script:
- ansible-lint tests/playbook.yml
script:
# Basic role syntax check
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
- molecule test
branches:
only:
- master
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

@ -0,0 +1,7 @@
#!/bin/bash
for i in ubuntu-molecule:16.04 debian-molecule:9 debian-molecule:8 centos-molecule:7 fedora-molecule:27
do
docker pull paulfantom/$i &
done
wait

@ -56,6 +56,9 @@ So in order to upgrade Docker on managed systems, take the following steps:
host/group vars.
1. Run your playbook with `-e upgrade_docker=True`
### `docker_proxy`, `docker_http_proxy`, `docker_https_proxy`, `docker_no_proxy`
`docker_proxy` specifies if proxy need to be applied. Default value of `docker_proxy` is no. If you need proxy set it to yes and updated other three variables as needed.
Dependencies
------------

32
Vagrantfile vendored

@ -1,32 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.provider "virtualbox" do |vb|
vb.memory = "512"
end
config.vm.define "centos-7" do |machine|
machine.vm.box = "minimal/centos7"
machine.vm.provision "shell", inline: "yum update -y"
machine.vm.provision "ansible" do |ansible|
ansible.playbook = "tests/vagrant.yml"
end
end
config.vm.define "debian-jessie" do |machine|
machine.vm.box = "minimal/jessie64"
machine.vm.provision "shell", inline: "apt-get update && apt-get install -y python"
machine.vm.provision "ansible" do |ansible|
ansible.playbook = "tests/vagrant.yml"
end
end
config.vm.define "ubuntu-xenial" do |machine|
machine.vm.box = "ubuntu/xenial64"
machine.vm.provision "shell", inline: "apt-get update && apt-get install -y python"
machine.vm.provision "ansible" do |ansible|
ansible.playbook = "tests/vagrant.yml"
end
end
end

@ -3,6 +3,10 @@ consul_ip: 127.0.0.1
docker_clusterstore: no
dockerpy: no
vagrant: no
docker_proxy: no
docker_http_proxy: ""
docker_https_proxy: ""
docker_no_proxy: ""
upgrade_docker: false
default_docker_config:
storage-driver: devicemapper
@ -15,4 +19,4 @@ setup_script_url: "https://releases.rancher.com/install-docker/{{ docker_version
# DO NOT MODIFY THIS UNLESS YOU HAVE SPECIFIED A DIFFERENT "docker_version" or "setup_script_url"
# IF YOU HAVE GENERATED AN MD5 CHECKSUM FOR YOUR DESIRED SETUP SCRIPT, STORE IT IN THIS VARIABLE
# IF YOU REALLY DON'T WANT TO VERIFY CHECKSUM, SET THIS VALUE TO "false" or "no"
setup_script_md5_sum: "6be324016277879d49bd0e7f9f91e546"
setup_script_md5_sum: "6be324016277879d49bd0e7f9f91e546"

@ -1,11 +1,7 @@
---
- name: reload unit
become: true
command: systemctl daemon-reload
when:
- ansible_service_mgr == "systemd"
- name: restart docker
service:
become: yes
systemd:
name: docker
state: restarted
daemon_reload: yes

@ -0,0 +1,43 @@
---
ansible:
playbook: tests/playbook.yml
driver:
name: docker
verifier:
name: testinfra
dependency:
name: shell
command: ./.travis/images.sh
docker:
build_image: False
containers:
- name: xenial
image: paulfantom/ubuntu-molecule
image_version: 16.04
privileged: true
volume_mounts:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
# - name: stretch
# image: paulfantom/debian-molecule
# image_version: 9
# privileged: true
# volume_mounts:
# - /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: jessie
image: paulfantom/debian-molecule
image_version: 8
privileged: true
volume_mounts:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
# - name: centos7
# image: paulfantom/centos-molecule
# image_version: 7
# privileged: true
# volume_mounts:
# - /sys/fs/cgroup:/sys/fs/cgroup:ro
# - name: fedora
# image: paulfantom/fedora-molecule
# image_version: 27
# privileged: true
# volume_mounts:
# - /sys/fs/cgroup:/sys/fs/cgroup:ro

@ -1,6 +1,7 @@
---
- set_fact:
- name: Compose md5 checksum
set_fact:
setup_script_checksum: "md5:{{ setup_script_md5_sum }}"
when: setup_script_md5_sum is defined and setup_script_md5_sum
@ -12,4 +13,6 @@
mode: 0755
- name: Execute docker setup script
shell: "/tmp/docker-setup.sh"
shell: "/tmp/docker-setup.sh"
tags:
- skip_ansible_lint

@ -31,6 +31,21 @@
docker_json: '{{ docker_json | combine({"cluster-store": "consul://{{ consul_ip }}:8500"})}}'
when: docker_clusterstore
- name: create directory for proxy file
file:
path: /etc/systemd/system/docker.service.d
state: directory
when: docker_proxy
- name: create http-proxy.conf
template:
src: http-proxy.j2.conf
dest: /etc/systemd/system/docker.service.d/http-proxy.conf
notify:
- reload unit
- restart docker
when: docker_proxy
- name: ensure daemon config file is present
template:
src: daemon.j2.json
@ -48,19 +63,11 @@
src: docker.j2.service
dest: /usr/lib/systemd/system/docker.service
notify:
- reload unit
- restart docker
- meta: flush_handlers
- name: ensure starts on system boot
service:
systemd:
name: docker
enabled: yes
- name: ensure vagrant user can run docker commands
user:
name: vagrant
groups: docker
append: yes
when: vagrant

@ -8,7 +8,7 @@ Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/docker daemon -H unix:///var/run/docker.sock
ExecStart=/usr/bin/dockerd -H unix:///var/run/docker.sock
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=1048576

@ -0,0 +1,2 @@
[Service]
Environment="HTTP_PROXY={{ docker_http_proxy }}" "HTTPS_PROXY={{ docker_https_proxy }}" "NO_PROXY={{ docker_no_proxy }}"

@ -1 +0,0 @@
localhost

@ -0,0 +1,9 @@
---
- hosts: all
become: yes
roles:
- ansible-role-docker
vars:
default_docker_config:
storage-driver: vfs
log-level: info

@ -1,6 +0,0 @@
---
- hosts: localhost
become: yes
become_user: root
roles:
- .

@ -0,0 +1,54 @@
from testinfra.utils.ansible_runner import AnsibleRunner
testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all')
def test_directories(host):
present = [
"/etc/docker",
]
absent = []
if present:
for directory in present:
d = host.file(directory)
assert d.is_directory
assert d.exists
if absent:
for directory in absent:
d = host.file(directory)
assert not d.exists
def test_files(host):
present = [
"/etc/docker/daemon.json",
]
if present:
for file in present:
f = host.file(file)
assert f.exists
assert f.is_file
# def test_socket(host):
# assert host.socket("unix:///var/run/docker.sock").is_listening
def test_service(host):
present = [
"docker"
]
if present:
for service in present:
s = host.service(service)
assert s.is_running
assert s.is_enabled
def test_packages(host):
if host.system_info.distribution == 'ol':
DOCKER = 'docker-engine'
else:
DOCKER = 'docker-ce'
assert host.package(DOCKER).is_installed

@ -1,24 +0,0 @@
---
- hosts: all
become: yes
become_user: root
vars:
docker_clusterstore: yes
vagrant: yes
roles:
- ../docker
tasks:
- name: check consul state
command: docker ps -q -f name=consul
register: consulcheck
changed_when: no
- name: ensure consul is running
command: >
docker run \
-d \
--name consul \
-p "8500:8500" \
--restart always \
progrium/consul -server -bootstrap
when: consulcheck.stdout_lines | length == 0
Loading…
Cancel
Save