AX Semantics Developer Blog
  • Home
  • Categories
  • Tags
  • Archives

Updating docker states for the SaltStack upgrade from Helium to Lithium

If you are provisioning your docker hosts with SaltStack and upgrade from Helium (v2014.7.x) to Lithium (v2015.5.x) you will encounter some problems not mentioned in the release notes:

Port exposures and volumes will not be created properly. Also Lithium now creates the container in the docker.running state if it does not exist, so you will not need a docker.installed state anymore. In fact if you continue to set the volume and port bindings in the running state while keeping an installed state it will not work, as the container does not get updated if you have already created it with a installed state (probably you would have to specify volumes and ports there - didn't test that, getting rid of the installed state is nice).

Ports and volumes don't work because port_bindings is now called ports and binds is now called volumes.

So my state with backwards compatibility now looks like this:

include:
  - docker

nginx-image:
  docker.pulled:
    - name: aexea/nginx
    - tag: latest
    - require:
      - pkg: lxc-docker

{% if grains['saltversion'].startswith('2014') %}
nginx-installed:
  docker.installed:
    - name: nginx
    - image: aexea/nginx
    - watch:
      - docker: nginx-image

nginx-running:
{% elif grains['saltversion'].startswith('2015.5') %}
nginx-installed:
{% endif %}
  docker.running:
    - name: nginx
    - container: nginx
    - image: aexea/nginx
    {% if grains['saltversion'].startswith('2014') %}
    - binds:
    {% elif grains['saltversion'].startswith('2015.5') %}
    - volumes:
    {% endif %}
        /opt/nginx/sites-enabled:
            bind: /etc/nginx/sites-enabled
            ro: True
        /opt/nginx/data:
            bind: /etc/nginx/data
            ro: True
    - restart_policy: 
        MaximumRetryCount: 0,
        Name: always
    {% if grains['saltversion'].startswith('2014') %}
    - port_bindings:
    {% elif grains['saltversion'].startswith('2015.5') %}
    - ports:
    {% endif %}
        "80/tcp":
          HostIp: ""
          HostPort: "80"
        "443/tcp":
          HostIp: ""
          HostPort: "443"
        "9999/tcp":
          HostIp: ""
          HostPort: "9999"
    - watch:
    {% if grains['saltversion'].startswith('2014') %}
      - docker: nginx-installed
    {% elif grains['saltversion'].startswith('2015.5') %}
      - docker: nginx-image
    {% endif %}

Tell us what you think about this. Is something unclear? Do you have questions or ideas? Leave your comments below.

Comments
comments powered by Disqus

  • « How to fix autostart of docker on Ubuntu 15.04
  • testing content generation in docker »

Published

Jun 17, 2015

Category

SaltStack

Tags

  • docker 6
  • howto 9
  • saltstack 2
  • upgrade 1
  • AX Semantics Developer Blog - Technical stuff and learnings we had while developing the AX environment
  • Powered by Pelican. Theme: Elegant by Talha Mansoor