티스토리 뷰

Hello,


It's rain in out of the office. My office building elevator is not working. I walked up the stairs to the 14th floor. It's so hot. How is your day?


Anyway, 

In this blog, I would like to post about how to provision OpenStack Instance using Ansible. Before develop Ansible playbook, we need to prepare test environment like below.


  • Github repository : There are OpenStack provisioning Playbook.

  • Ansible Tower : It will makes Job Template using playbook of Github repository and It will plays.

  • OpenStack Director : I will install Shade OpenStack module for Ansible

  • OpenStack Controller Node : The Ansible playbook will call OpenStack API of this node.

  • OpenStack Compute Node : It will create OpenStack Instance in this node.


This Job flow is like below. If your test environment preparing is done, you need to develop playbook and upload it to the your github repository first. And then,  you need to configure github repository information and OpenStack director credential. And you make Job Template for provisioning OpenStack instance using your github playbook.



To develop ansible playbook, we need to design provisioning task process.

Before OpenStack instance create, OpenStack needs OS image, network, keypiar, flavor and security group. We can express these process like below.



Above each task process can make role process.


OSP-Image

When upload OS image to glance, we need to download OS image first. And then downloaded image can upload to glance.


OSP-Network

Openstack needs to create Public network and Tenant network for providing network ip to instance.

If you use Tenant network, you need to create Router for connecting each public and tenant network. 


OSP-Keypair

Keypair needs when we connect Instance more safely. First, it generate ssh key and register public key file.



OSP-Security Group

Security Group is firewall for instances. If your instance is for web service, you would create "web security group" and add http service port to the created web security group.


OSP-Flavor

Flavor is spec of instance like cpu, memory and hard disk.


Create Instance

After it makes all resources without instances, you can create instance. If creating instance is done, floating ip add to created instance. And you would wait for being available instance status.


Playbook Architecture

Right now, it's time to develop ansible playbook. You would make git directory for developing playbook like below.



When we develop playbook, we need sample playbook code. Below code is example codes for provisiong instance.


# Create a new instance with 4G of RAM on a 75G Ubuntu Trusty volume
- name: launch a compute instance
  hosts: localhost
  tasks:
    - name: launch an instance
      os_server:
        name: vm1
        state: present
        cloud: mordred
        region_name: ams01
        image: Ubuntu Server 14.04
        flavor_ram: 4096
        boot_from_volume: True
        volume_size: 75



Following urls are included example codes that you need for developing playbook. You can develop playbook as refer below url.



Actually this blog's contents is part of my ansible training lesson in China. After came back to Korea, I wanted to summarize about my training. Finally I am so happy cause I summarize this.

최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함