#!/usr/bin/env ansible-playbook
---
- name: DOCKER CONTAINERS PROVISIONING
  hosts: localhost
  connection: local
  tags: always
  tasks:
    - name: Create docker containers from inventory
      docker_container:
        name: "{{ item }}"
        image: registry.ubicast.net/docker/debian-systemd:buster
        privileged: true
        command: /lib/systemd/systemd
        state: started
        volumes:
          - /sys/fs/cgroup:/sys/fs/cgroup:ro
        tmpfs:
          - /tmp
          - /run
      with_inventory_hostnames:
        - all:!localhost

    - name: add host to inventory
      add_host:
        name: "{{ item }}"
        ansible_host: "{{ item }}"
        ansible_connection: docker
        ansible_python_interpreter: /usr/bin/python3
        in_docker: true
      with_inventory_hostnames:
        - all:!localhost

- import_playbook: site.yml

...
