Skip to content

amtega/ansible_role_docker_provisioner

Repository files navigation

Ansible docker_provisioner role

This is an Ansible role to provisione docker images and containers.

Requirements

Docker. You can use amtega.docker_engine role to setup it.

Role Variables

A list of all the default variables for this role is available in defaults/main.yml.

The role setups the following facts:

  • docker_provisioner_containers_facts: list of dicts with the facts about discovered containers.

Example Playbook

This is an example playbook:

---
- hosts: localhost
  roles:
    # Load some presets for images and containers

    - role: amtega.docker_presets

    # Provisione images and non ssh based containers

    - role: amtega.docker_provisioner
      vars:
        docker_provisioner_images: "{{ docker_presets_images }}"
        docker_provisioner_image_state: present
        docker_provisioner_image_force: true
        docker_provisioner_containers: "{{ docker_presets_containers }}"
        docker_provisioner_container_restart: true
        docker_provisioner_container_tty: false
        docker_provisioner_container_state: started

    # Cleanup provisioned containers

    - role: amtega.docker_provisioner
      vars:
        docker_provisioner_images: []
        docker_provisioner_image_force: true
        docker_provisioner_container_state: absent
        docker_provisioner_containers: "{{ docker_presets_containers }}"
        docker_provisioner_container_restart: true

Testing

Tests are based on vagrant virtual machines. You can setup vagrant engine quickly using the playbook files/setup.yml available in the role amtega.vagrant_engine.

Once you have vagrant, you can run the tests with the following commands:

$ cd amtega.docker_provisioner/tests
$ ansible-playbook main.yml

License

Copyright (C) 2022 AMTEGA - Xunta de Galicia

This role is free software: you can redistribute it and/or modify it under the terms of:

GNU General Public License version 3, or (at your option) any later version; or the European Union Public License, either Version 1.2 or – as soon they will be approved by the European Commission ­subsequent versions of the EUPL.

This role is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details or European Union Public License for more details.

Author Information

  • Juan Antonio Valiño García.