Openstack & Ansible

Opennstack
  • Open source software for creating private and public clouds

  • Manages the servers at these sites so you can create Virtual Machines (VMs) for your apps / services to run on

  • Can create VMs using the UI or through scripts

  • Once created, can click on the instance name in the UI to find the IP

  • nslookup on the IP to find the hostname (hostname can be worked out from the Openstack account and the instance name as well)

  • SSH onto the IP / host as root, using the appropriate private key

  • Check instance has correct resources by running lscpu / free -h / df -h

  • Heat
  • Heat is the main project in the OpenStack Orchestration program (Orchestration: Coordinate servers to work together). It implements an orchestration engine to launch multiple composite cloud applications based on templates in the form of text files that can be treated like code.

  • A heat template can create multiple volumes & VMs

  • heat stack-create
    -f openstack/templates/demo-template.yaml
    cr-demo

  • Openstack vs  AWS vs Raw tin
  • Openstack is mainly for creating private cloud and is open source while AWS is mainly a public cloud.

  • Network speed in AWS would be slower than that in Openstack, as the AWS machines are in Ireland.

  • Network speed in Openstack would be slower than that in raw tin servers, as the openstack servers have an virtualization layer.

  • Ansible
  • After created blan VM in openstack, could use Ansible to create non-root users, copy ssh keys, install java, install/delete cronjobs

  • “[Ansible] can configure systems, deploy software, and orchestrate more advanced IT tasks such as continuous deployments or zero downtime rolling updates”

  • Why not Puppet / Chef / x?

    • No need for a ‘master’ node (just run from your laptop!)

  • Inventory Files

    • Specify which servers to configure

    • Group servers together (eg. ‘Dash Servers’)

    • Can be Static or Dynamic

      • Static = hard-coded IPs or hostnames

      • Dynamic = query a provider like AWS… Or Openstack!

  • Roles

    • Define a set of tasks to apply to a group of servers

    • Eg. group together tasks for a standard Java app server, and apply those tasks to all Java app servers

  • Tasks

    • Define specific actions to carry out on a server

    • Eg. Install Java 8

    • Eg. Copy file x from my Ansible repo to the server

    • Eg. Copy template y from my Ansible repo to the server

    • Eg. Restart service z on the server

  • Variables

    • Tasks and templates may reference variables

    • Variables can be set against:

      • Specific servers (in inventory files / inventory folders)

      • Groups of servers (in group_vars)

    Conclusion
    • Statically create VMs in Openstack

    • Use Ansible to manage VMs

      • Installing software (Java, sqlite, filebeat, etc)

      • Managing app scripts (deploy / stop / start)

      • Managing cronjobs (log deletion scripts)

      • Managing SSH Keys

      • Managing config (New Relic, filebeat)

    相关内容推荐