Contributors20 minutes | Any computer that's managed by Chef is called a node. |
Now it's time to bring up an Ubuntu 14.04 instance and prepare it for the bootstrap process.
| Although Chef supports multiple versions of Ubuntu, for this module we recommend you use Ubuntu 14.04. Doing so helps ensure that the output you see matches the sample output that's shown. |
If you did the Learn the Chef basics module, you installed Chef Workstation on a server and configured it directly. Here you'll set up an Ubuntu server, called a node, and prepare your node to be configured by Chef remotely from your workstation.
1. Get an Ubuntu 14.04 node to bootstrap
We suggest that you work in a disposable environment such as an Ubuntu 14.04 virtual machine or cloud instance.
If you're comfortable with Docker, you can Dockerize an SSH service and bootstrap a Docker container. You'll need to also to expose additional network ports, as shown below.
Ensure that your system:
- provides
root or sudo access. - has a resolvable IP address.
- can access the Internet.
- provides network access on ports 22 (SSH), 80 (HTTP), and 443 (HTTPS).
| The easiest way to get started is to use a system that can access the Internet over ports 22, 80 and 443. If your firewall or network environment doesn't provide this access, check out this blog post and this video. |
If you still have the system that you used in the first module, Learn the Chef basics, you can continue to use that system for this module.
The system requirements for your node are the same as the ones you used in the first module. Use these links if you need a refresher on how to bring up a node in your preferred runtime environment.
2. Gather some details about your machine
| All you need is for your system to be running – don't connect to it just yet. |
Now, gather this information about your machine:
- Its hostname or public IP address.
- A user name that has root or
sudo access and its password. If you use key-based authentication to connect to your instance, note the location of your private key file.
If you're bootstrapping a local virtual machine, such as a Vagrant instance, you'll also need to know which forwarded port Vagrant chose for routing SSH traffic. Forwarded ports enable the host (your workstation) to receive and forward network traffic to the guest (the virtual machine.)
If you're using virtualization software other than Vagrant and VirtualBox, check the documentation for that software to learn how to get the SSH connection details to the virtual machine, including the SSH forwarded port. Here's how to get the connection details for Vagrant.
- Show details
The directory from where you ran vagrant init ubuntu-14.04 contains a file named Vagrantfile. From that directory, run the vagrant ssh-config command to get the connection details.
Terminal: ~
$ | vagrant ssh-configHost default HostName 127.0.0.1 User vagrant Port 2222 UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile /home/user/.vagrant/machines/default/virtualbox/private_key IdentitiesOnly yes LogLevel FATAL
|
In this example, any network traffic that's sent to port 2222 on your workstation will be forwarded to port 22 (the SSH port) on your virtual machine.
Write down the values of User, Port, and IdentityFile.
3. Create a test SSH connection to your node
The bootstrap process connects to your node over SSH. Now that you have the connection details, let's create a test SSH connection to your node.
You don't have to do this every time you bootstrap a node, but verifying that your node is connectable will help ensure that the bootstrap process succeeds.
Here are examples for the various ways you can connect.
Connect using key-based authentication
Terminal: ~
$ | ssh -i ~/.ssh/my.pem ubuntu@40.76.28.32The authenticity of host '40.76.28.32 (40.76.28.32)' can't be established.RSA key fingerprint is SHA256:YiT1n9QZ64GnXcCeRpYMOLxpJZ9IjCft1Fpf5tvAFuQ.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '40.76.28.32' (RSA) to the list of known hosts.
|
Connect using a username and password
Terminal: ~
$ | ssh ubuntu@40.76.28.32The authenticity of host '40.76.28.32 (40.76.28.32)' can't be established.RSA key fingerprint is SHA256:YiT1n9QZ64GnXcCeRpYMOLxpJZ9IjCft1Fpf5tvAFuQ.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '40.76.28.32' (RSA) to the list of known hosts.ubuntu@40.76.28.32's password:
|
Connect to a local virtual machine using a forwarded port
Here's an example for Vagrant. The -l option specifies the username vagrant. The -p option specifies the port on the host (2222) that will forward to port 22 on the guest.
Terminal: ~
$ | ssh -i /home/user/.vagrant/machines/default/virtualbox/private_key -l vagrant -p 2222 localhostThe authenticity of host '[localhost]:2222 ([127.0.0.1]:2222)' can't be established.RSA key fingerprint is c4:4d:f9:05:09:31:33:05:cd:99:52:5b:fc:e0:10:b5.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '[localhost]:2222' (RSA) to the list of known hosts.Last login: Thu Dec 3 15:32:08 2015 from 10.0.2.2
|
Now close the SSH connection to your Ubuntu node.
Terminal: ~
| [ubuntu@40.76.28.32 ~]$ exit logoutConnection to 40.76.28.32 closed.
|
To summarize, in this part you brought up a node that you'll configure using Chef.
You also created a test connection to your node over SSH. But once you get the hang of things, you'll see that the bootstrap process enables you to configure your servers without the need to connect to them directly.