Added Kitchen tests and Travis
diff --git a/.kitchen.yml b/.kitchen.yml
new file mode 100644
index 0000000..e8660f3
--- /dev/null
+++ b/.kitchen.yml
@@ -0,0 +1,67 @@
+---
+driver:
+ name: docker
+ hostname: docker.ci.local
+ use_sudo: false
+
+provisioner:
+ name: salt_solo
+ salt_install: bootstrap
+ salt_bootstrap_url: https://bootstrap.saltstack.com
+ salt_version: latest
+ require_chef: false
+ log_level: error
+ formula: docker
+ grains:
+ noservices: True
+ state_top:
+ base:
+ "*":
+ - linux
+ - docker
+ pillars:
+ top.sls:
+ base:
+ "*":
+ - docker_debian_repo
+ - docker
+ docker.sls:
+ docker:
+ client:
+ compose:
+ source:
+ engine: pip
+ pillars-from-files:
+ docker_debian_repo.sls: tests/pillar/repo_docker.sls
+ dependencies:
+ - name: linux
+ repo: git
+ source: https://github.com/salt-formulas/salt-formula-linux.git
+
+verifier:
+ name: inspec
+ sudo: true
+
+platforms:
+ - name: <%=ENV['PLATFORM'] || 'ubuntu-xenial'%>
+ driver_config:
+ image: <%=ENV['PLATFORM'] || 'trevorj/salty-whales:xenial'%>
+ platform: ubuntu
+
+suites:
+
+ - name: client_compose
+ provisioner:
+ pillars-from-files:
+ docker.sls: tests/pillar/client_compose.sls
+
+ - name: client_container
+ provisioner:
+ pillars-from-files:
+ docker.sls: tests/pillar/client_container.sls
+
+ - name: host_single
+ provisioner:
+ pillars-from-files:
+ docker.sls: tests/pillar/host_single.sls
+# vim: ft=yaml sw=2 ts=2 sts=2 tw=125
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..b81b4e7
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,29 @@
+sudo: required
+services:
+ - docker
+
+install:
+ - pip install PyYAML
+ - pip install virtualenv
+ - |
+ test -e Gemfile || cat <<EOF > Gemfile
+ source 'https://rubygems.org'
+ gem 'rake'
+ gem 'test-kitchen'
+ gem 'kitchen-docker'
+ gem 'kitchen-inspec'
+ gem 'inspec'
+ gem 'kitchen-salt', :git => 'https://github.com/epcim/kitchen-salt.git', :branch => 'dependencis-pkg-repo2'
+ #Waiting for PR#78
+ #gem 'kitchen-salt', '>=0.2.25'
+ - bundle install
+
+env:
+ - PLATFORM=trevorj/salty-whales:xenial
+
+before_script:
+ - make test | tail
+
+script:
+ - test ! -e .kitchen.yml || bundle exec kitchen converge || true
+ - test ! -e .kitchen.yml || bundle exec kitchen verify
diff --git a/docker/client/compose.sls b/docker/client/compose.sls
index d6e2fd9..5567b36 100644
--- a/docker/client/compose.sls
+++ b/docker/client/compose.sls
@@ -19,6 +19,7 @@
docker_compose_python_pip:
pkg.installed:
- name: python-pip
+ - reload_modules: true
docker_compose:
pip.installed:
@@ -103,12 +104,15 @@
- watch:
- file: docker_{{ app }}_env
- file: docker_{{ app }}_compose
+ {%- if not grains.get('noservices', False)%}
{%- if compose.status is defined %}
- watch_in:
- cmd: docker_{{ app }}_{{ compose.status }}
{%- endif %}
+ {%- endif %}
{%- endif %}
+{%- if not grains.get('noservices', False)%}
{%- if compose.status is defined %}
docker_{{ app }}_{{ compose.status }}:
cmd.run:
@@ -128,6 +132,6 @@
- file: docker_{{ app }}_env
- file: docker_{{ app }}_compose
{%- endif %}
-
+{%- endif %}
{%- endif %}
{%- endfor %}
diff --git a/docker/client/container.sls b/docker/client/container.sls
index 53758f3..22b817e 100644
--- a/docker/client/container.sls
+++ b/docker/client/container.sls
@@ -6,13 +6,13 @@
{%- for name, container in client.get('container', {}).iteritems() %}
{%- set id = name %}
{%- set required_containers = [] %}
-
+{%- if not grains.get('noservices', True)%}
{{id}}_image:
dockerng.image_present:
- name: {{ container.image }}
- require:
- pkg: docker_python
-
+{%- endif %}
{%- set binds = {} %}
{%- set volumes = {} %}
{%- for volume in container.get('volumes', []) %}
@@ -35,7 +35,7 @@
{%- endif %}
{%- endfor %}
-
+{%- if not grains.get('noservices', True)%}
{{id}}_container:
dockerng.running:
- name: {{id}}
@@ -94,4 +94,5 @@
- dockerng: {{containerid}}
{%- endfor %}
{%- endif %}
+{%- endif %}
{% endfor %}
diff --git a/docker/host.sls b/docker/host.sls
index 81b3b98..a8bc815 100644
--- a/docker/host.sls
+++ b/docker/host.sls
@@ -1,15 +1,20 @@
{% from "docker/map.jinja" import host with context %}
+
{%- if host.enabled %}
docker_packages:
pkg.installed:
- pkgs: {{ host.pkgs }}
+{%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
+
network.ipv4.ip_forward:
sysctl.present:
- name: net.ipv4.ip_forward
- value: 1
+{%- endif %}
+
{%- if grains.os == 'Ubuntu' %}
/etc/default/docker:
@@ -18,8 +23,10 @@
- template: jinja
- require:
- pkg: docker_packages
+ {%- if not grains.get('noservices', False)%}
- watch_in:
- service: docker_service
+ {%- endif %}
{%- endif %}
@@ -27,10 +34,15 @@
file.managed:
- source: salt://docker/files/daemon.json
- template: jinja
+ - makedirs: True
- require:
- pkg: docker_packages
+ {%- if not grains.get('noservices', False)%}
- watch_in:
- service: docker_service
+ {%- endif %}
+
+{%- if not grains.get('noservices', False)%}
docker_service:
service.running:
@@ -39,6 +51,9 @@
- require:
- pkg: docker_packages
+{%- endif %}
+
+
{%- if host.registry is defined %}
{%- for name,registry in host.registry.iteritems() %}
diff --git a/metadata.yml b/metadata.yml
index 515eb02..ac47bec 100644
--- a/metadata.yml
+++ b/metadata.yml
@@ -1,3 +1,6 @@
name: "docker"
version: "0.2"
-source: "https://github.com/tcpcloud/salt-formula-docker"
+source: "https://github.com/salt-formulas/salt-formula-docker"
+dependencies:
+- name: linux
+ source: "https://github.com/salt-formulas/salt-formula-linux"
\ No newline at end of file
diff --git a/tests/pillar/client_container.sls b/tests/pillar/client_container.sls
index 3565b52..917ed2b 100644
--- a/tests/pillar/client_container.sls
+++ b/tests/pillar/client_container.sls
@@ -14,3 +14,6 @@
JAVA_OPTS: "-Dhudson.footerURL=https://www.example.com"
volumes:
- /srv/volumes/jenkins:/var/jenkins_home
+ compose:
+ source:
+ engine: pip
\ No newline at end of file
diff --git a/tests/pillar/repo_docker.sls b/tests/pillar/repo_docker.sls
new file mode 100644
index 0000000..25bbdf1
--- /dev/null
+++ b/tests/pillar/repo_docker.sls
@@ -0,0 +1,8 @@
+linux:
+ system:
+ enabled: true
+ repo:
+ docker:
+ source: 'deb https://apt.dockerproject.org/repo/ ubuntu-{{ grains.get('oscodename') }} main'
+ key_id: 58118E89F3A912897C070ADBF76221572C52609D
+ key_server: hkp://p80.pool.sks-keyservers.net:80