mattstruble / infra

Infrastructure as code for all my cloud and self-hosted applications
MIT License
1 stars 0 forks source link

Ansible: Manage Docker Swarm #2

Open mattstruble opened 10 months ago

mattstruble commented 10 months ago

Add docker support for managing stacks within my swarm containers.

- hosts: my-swarm-manager-nodes[0]
  tasks:
    - name: deploy services to swarm
      community.general.docker_stack:
        name: "{{ item.name }}"
        state: present
        compose:
          - "{{ item.compose }}"
      with_items: "{{ my_services }}"
      when: my_services is defined
  vars:
    my_services:
      - name: some_stack:
        compose: "{{ lookup('file', '../../docker/some_stack.yml') | from_yaml }}"

Ref: https://old.reddit.com/r/ansible/comments/lb1qvq/ansible_and_docker_stacks/glsisqq/