Docker+ansible

Hi

Is it possible to run more than one docker compose files from ansible?

Hi,

Is it possible to run more than one docker compose files from ansible?

what makes you think it is not possible?

Cheers,
Felix

Hi Felix

Thanks, I am struggling to find the syntax

Hi Felix

Thanks, I am struggling to find the syntax

Hello Sunitha,

search for "Ansible docker compose", this should provide enough examples to build upon.

For specific help, post your playbook and the output and explain why you did it that way.

Regards
        Racke

Hi stefan, below is the playbook,

One way is to find a master playbook and include the other playbooks whichever is required. suppose if i have 10 microservices and I will have 10 compose files and as a part of a bug fix I don’t need to deploy all of them may be 2 or 3 based on the defects. so I thought having 10 different play books for 10 compse files and run the required ones. If you have any better idea do suggest me please.

  • name: Run a docker compose file
    hosts: dockerVM
    become: yes
    become_method: su

tasks:

  • set_fact: compose_dir=/root/DockercomposeFile

  • name: create a directory
    file:
    path: “{{compose_dir}}”
    state: directory

  • name: copy docker compose file
    file:
    src: /root/DockerComposeFile
    dest: /root/DockerComposeFile
    mode: “0755”

  • name: Run a docker compose file
    docker_service:
    project_src: “{{ compose_dir }}”
    state: present
    build: no
    register:output

Hi stefan, below is the playbook,

One way is to find a master playbook and include the other playbooks whichever is required. suppose if i have 10
microservices and I will have 10 compose files and as a part of a bug fix I don't need to deploy all of them may be 2 or
3 based on the defects. so I thought having 10 different play books for 10 compse files and run the required ones. If
you have any better idea do suggest me please.

Hello Sunitha,

I strongly suggest to setup an Ansible role which includes the tasks below and apply it in a loop in the playbook.

Different playbooks complicate your setup and are harder to maintain. Settings which vary between your micro services
can be kept in variables / inventory.

Regards
        Racke

thank you so much and I really appreciate it.

Hi all,

I am not able to set this.
Can you please guide.

(attachments)