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

Assigning static IP to containers #350

Open djfang opened 7 years ago

djfang commented 7 years ago

Is there a way to assign static IPs to containers?

The distributed application I deployed needs an IP but since the IP changes when ansible container builds and runs, I therefore need a way to make it static. I've tried using links directive but since it's only one-way mapping, I'm looking for something that's bidirectional. It seems the networks directives should solve this but this is currently not supported yet.

Any thoughts on this will be much appreciated. Cheers and Happy New Year all!

chouseknecht commented 7 years ago

@djfang, can you describe your use case a little bit more? Specifically:

djfang commented 7 years ago

@chouseknecht Thanks for your reply. Please see my response to your questions below:

What platform are you deploying to (Swarm, Kubernetes, OpenShift, etc.)?

What is the expectation for networks when you run ansible-container run --production?

What is the expectation for networks when you run shipit?

chouseknecht commented 7 years ago

@j00bar, thoughts on this?

I'm not sure we want to go down the networking road, simply because none of it translates to K8s. Or, maybe we should allow all the network things to function under Docker, and then just ignore them during shipit?

pheer commented 7 years ago

I was also evaluating ansible containers and looking for network functionality. In my use case - there is a master and slave nodes that all need to be able to talk to eachother. Before I've used docker compose containers with 'networks' (e.g. set each to a common name). It would be nice to extend this and allow ansible to also provision the container vs simply a dockerfile. Is there another way I can provision the container using existing ansible roles (without ansible-container for example). Mainly I feel it is valuable to have isolated ansible roles that can be run on bare metal machines and/or the same roles be deployed locally for testing. Hopefully that makes sense...

chouseknecht commented 7 years ago

@pheer, for the moment you may be better off using Ansible's docker modules.

pheer commented 7 years ago

Yep, that is what I'm thinking. So using those I can setup the cluster and then connect to each container as needed to provision? You know of a good example showing this use case?

More info on setup: A vagrant VM with docker/ansible/other tools needed in vm installed via vagrant/ansible provision. once docker is on vm - 'build' and call 'up' on docker-compose files. This is where I'm currently at, and now need to further provision these nodes and looking for the best way to accomplish this.