-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This repos builds a machine topology as in diagram.
- Use an ssh keypair generator to create a keypair named ansible by performing "ssh-keygen -t rsa -f ansible".
- put public key that is created in the "env" directory so that it can be copied to all the created environments.
- ssh -i ~/../*/../env/ansible ansible@control
- create folder .ssh in ansible user directory
- edit .ssh/authorized_keys file paste the trusted.public key file into it. (vi .ssh/authorized_keys)
- ssh -i ansible/testkey ansible@control
- Copy the keypair you created in step SSH Key Information above into the env/ subdirectory.
(Evironment from Chris L. Master Ansible Course on Udemy.com) The environment used is built using docker and virtualbox. Docker is an application container technology for linux. It's not designed to run full "virtual machines," so even though we're able to hack together a setup to mimic virtual machines, I do not recommend that you use this type of pattern for deploying any real services to production. The reason I like docker for this is that the resulting machines are much more lightweight, and I can run 5 "machines" on my macbook air with 4 GB of RAM (along with a browser, editor, and terminal process). This would be harder to do with a full virtual machine solution such as vagrant. If you have more resources available and want a more standard setup, take a look at vagrant (it's free and open-source).
With that caveat, if you're still interested in getting a similar docker setup going, you can download these tools from their respective sites:
docker-toolbox virtualbox
-
Install docker-toolbox
-
Create "docker-machine" to get a docker host vm up and running on virtualbox by "docker-machine create dev -d virtualbox"
-
Perform "docker-machine up" to start the docker machine that was created.
-
Add the connection details to your shell by performing "eval "$(docker-machine env dev)"" or just "docker-machine env dev" to examine the environment required which will also indicate what do do for your machine.
-
Follow instructions above to create SSH Keys.
Docker.zip
The directory docker contains the contents of docker machine configuration from the "Mastering Ansible" course. The directory structure is wired to the actual machines that get created. The "env" directory will be mapped to the "/work" directory on the "control box.
A clean copy of the directory under docker is contained in the downloads/docker.zip file. Upack the archive to a directory on your machine.
Copy the keypair you created in step SSH Key Information above into the env/ subdirectory.
From the unpacked directory (docker) perform "docker-compose build && docker-compose up" or "docker-compose build && docker-compose up -d" if want the containers running detached.
In another terminal session (or using an ssh client), connect to the hosts using the ansible key you created, and IP and Port mapping for the instance. Use docker-machine ip dev to print the IP for your docker host; the port mappings are found in the docker-compose.yml. You can also use the provided config file, by moving it to ~/.ssh/config on your local machine and updating the IP to match your docker host. Then you can simply ssh control to access the control host.