Getting ready to use puppetlabs/aws

In the following sections, we'll see how to generate an SSH key pair to connect to your EC2 instances, and also install the puppetlabs/aws module with its dependencies.

Creating a key pair

You'll need an SSH key pair in order to connect to any EC2 instances you create. We will generate and download your key pair in this section.

  1. In the AWS console, go to the EC2 section and select Key pairs under Network & Security in the left pane.
  2. Click the Create Key Pair button.
    Creating a key pair
  3. You will be prompted for the name of your key pair. Enter pbg for this example.
  4. A file named pbg.pem will be automatically downloaded by your browser. Move this file to your ~/.ssh directory on your own computer (or copy it to the ubuntu user's ~/.ssh directory on the Vagrant VM, if you'd rather access your AWS instances from there).
  5. Set the correct permissions on the key file with the following command:
    chmod 600 ~/.ssh/pbg.pem
    

Installing the puppetlabs/aws module

Follow these steps to install the puppetlabs/aws module:

If you've already set up the r10k module management tool, as shown in Chapter 7, Mastering modules, the required module will already be installed. If not, run the following commands to install it:

cd /etc/puppetlabs/code/environments/pbg
sudo r10k puppetfile install

Installing the AWS SDK gem

The puppetlabs/aws module requires a couple of gems, which we can install easily using Puppet, with the following manifest (aws_sdk.pp):

ensure_packages([
  'aws-sdk-core',
  'retries'
],
  { provider => puppet_gem })

Tip

Notice the provider => puppet_gem in that example? You might remember from Chapter 4, Understanding Puppet resources, that puppet_gem installs a Ruby gem in Puppet's context (as opposed to the system Ruby context, which is completely separate). Gems which are required by Puppet modules need to be installed in this way or Puppet won't be able to load them.

  1. Apply the manifest with the following command:
    sudo puppet apply --environment pbg /examples/aws_sdk.pp
    
  2. Create the /home/ubuntu/.aws/config file with the following contents:
    [default]
    region=us-east-1
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.110.105