ansible / ansible-container

DEPRECATED -- Ansible Container was a tool to build Docker images and orchestrate containers using only Ansible playbooks.
GNU Lesser General Public License v3.0
2.19k stars 394 forks source link

How to make container join a network #927

Open nibzy26 opened 6 years ago

nibzy26 commented 6 years ago
ISSUE TYPE
container.yml
version: "2"
settings:

  conductor:
    # The Conductor container does the heavy lifting, and provides a portable
    # Python runtime for building your target containers. It should be derived
    # from the same distribution as you're building your target containers with.
    base: ubuntu:16.04
    # roles_path:   # Specify a local path containing Ansible roles
    #volumes: mydb:/home/otp/db      # Provide a list of volumes to mount
    # environment:  # List or mapping of environment variables

  # Set the name of the project. Defaults to basename of the project directory.
  # For built services, concatenated with service name to form the built image name.
  project_name: node5may

  # The deployment_output_path is mounted to the Conductor container, and the
  # `run` and `deployment` commands then write generated Ansible playbooks to it.
  # deployment_output_path: ./ansible-deployment

  # When using the k8s or openshift engines, use the following to authorize with the API.
  # Values set here will be passed to the Ansible modules. Any file paths will be mounted
  # to the conductor container, allowing the `run` command to access the API.

services:
  # Add your containers here, specifying the base image you want to build from.
  # To use this example, uncomment it and delete the curly braces after services key.
  # You may need to run `docker pull ubuntu:trusty` for this to work.

   ocs5may_service:
     containers:
       - container_name: ocs_server
         from: "ubuntu:16.04"
         roles:
            - base
         ports:
            - "8080:8080"
            - "1812:1812/udp"
            - "1813:1813/udp"
            - "3868:3868"
         expose:
            - "1812/udp"
            - "1813/udp"
            - "3868/tcp"
            - "8080/tcp"
         volumes:
            - mydb:/home/otp/db/
         user: root
         working_dir: /home/otp
         docker_network:
           name: macvlan70
           appends: yes
         environment:
           ROOTDIR: /usr/lib/erlang
           RELDIR: /usr/lib/erlang/releases
           OTPHOME: /usr/lib/erlang
         entrypoint: ["/bin/sh", "-c", "tail -f /var/log/dmesg"]
     #entrypoint: ["/bin/sh","-c","bash"]
     #command: [bin/bash]
     #command: [ "/bin/bash", "-c", "--" ]
     #args: [ "while true; do sleep 30; done;" ]
volumes:
  mydb:
    docker: {}
networks:
  macvlan70:
    driver: macvlan
registries: {}
  # Add optional registries used for deployment. For example:
  #  google:
  #    url: https://gcr.io
  #    namespace: my-cool-project-xxxxxx
OS / ENVIRONMENT
Ansible Container, version 0.9.3rc0
Linux, mypc, 4.10.0-28-generic, #32~16.04.2-Ubuntu SMP Thu Jul 20 10:19:48 UTC 2017, x86_64
2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] /usr/bin/python
ERROR   No Ansible Container project data found - do you need to run "ansible-container init"?  
root@mypc:/home/nabeel# 
SUMMARY

I have created a container using ansible-container run command.How can I specify a particular network to join for this container.

  1. I have created a network using docker network create command it is of macvlan type

Now I want this container to be in that network At the moment it just makes its own default network and adds an interface to the host as well. I know there is an docker_network module in ansible but how can i do it using ansible-container???

STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS