Launching the stack and configuring Jenkins

In order to create our EC2 instance with Jenkins running on it, we will proceed as we did in Chapter 3, Treating Your Infrastructure As Code, using either the web interface or the command-line interface as follows:

$ aws cloudformation create-stack 
      --capabilities CAPABILITY_IAM 
      --stack-name jenkins 
      --template-body file://jenkins-cf.template 
      --parameters  ParameterKey=KeyPair,ParameterValue=EffectiveDevOpsAWS  

As before, we can then wait until the execution is complete:

$ aws cloudformation wait stack-create-complete 
      --stack-name jenkins  

Next, we can extract the host public IP:

$ aws cloudformation describe-stacks 
      --stack-name jenkins 
      --query 'Stacks[0].Outputs[0]'
    {
        "Description": "Public IP of our instance.",
        "OutputKey": "InstancePublicIp",
        "OutputValue": "54.175.97.69"
    }  

Because we kept the Ansible Jenkins role fairly simple, in order to complete the installation of Jenkins, we need to complete its configuration:

  1. Open the port 8080 of the instance public IP in your browser (that is, in my case http://54.175.97.69:8080).
  2. Using the following ssh command (adapt the IP address) and its ability to run commands remotely. We can extract the admin password and provide it to that first configuration screen with the following command:
$ ssh -i ~/.ssh/EffectiveDevOpsAWS.pem [email protected] 
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
  1. On the next screen, choose to install the suggested plugins.
  2. Create your first admin user on the next screen and click on Save and Finish.
  3. Finally, click on Start using Jenkins.

Our Jenkins instance is now ready to be used.

..................Content has been hidden....................

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