Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Ansible 2 Cloud Automation Cookbook

You're reading from   Ansible 2 Cloud Automation Cookbook Write Ansible playbooks for AWS, Google Cloud, Microsoft Azure, and OpenStack

Arrow left icon
Product type Paperback
Published in Feb 2018
Publisher Packt
ISBN-13 9781788295826
Length 200 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
 Patawari Patawari
Author Profile Icon Patawari
Patawari
 Aggarwal Aggarwal
Author Profile Icon Aggarwal
Aggarwal
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Title Page
Packt Upsell
Contributors
Preface
1. Getting Started with Ansible and Cloud Management FREE CHAPTER 2. Using Ansible to Manage AWS EC2 3. Managing Amazon Web Services with Ansible 4. Exploring Google Cloud Platform with Ansible 5. Building Infrastructure with Microsoft Azure and Ansible 6. Working with DigitalOcean and Ansible 7. Running Containers with Docker and Ansible 8. Diving into OpenStack with Ansible 9. Ansible Tower 1. Other Books You May Enjoy Index

Adding a keypair


A keypair is used to log into a virtual machine through SSH created by OpenStack. Once we have a key, or several of them, then we can choose a public key while creating a virtual machine, and this key will be added to the default user of the operating system.

How to do it…

  1. For this, we need to have a key added to OpenStack before we boot the virtual machine. The name of the key has to be unique. This is what we will specify while booting an instance. So let's add our public key as follows:
- name: adding public key
  os_keypair:
    name: aditya
    public_key: {{ aditya_pub_key }}
  1. We have used the variable for improving the readability of the code. It also helps if we need to change the keys quickly. We will add the value of the aditya_pub_key variable to the vars/main.yml file, as follows:
---
aditya_pub_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCbg83WYIxUfXWJ4bQiYfZYHceDwMJxnGfJqgYtHL/DAtegVY+Nm8MX3CRZYisfskt0m9CQ6y/Ux1OITTz+O11fgxLJcroZmKJbWW0K39gfHvFqR7FIe0zuJaxqUQUuyc0i6RCBRiZPiQQOPes2yDtfHgDWx3q9knS3ZXIAXcGLZrgfC1XnIK8CLAnZDved9Rue2bhsCnO9Mleh9g...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images