Using ansible to manage cloud platform by Accelerite

12
September 2016 Using Ansible to manage instances on CloudPlatform By Kiran Manohar Chavala @kiranchavala [email protected]

Transcript of Using ansible to manage cloud platform by Accelerite

September 2016

Using Ansible to manage instances on CloudPlatform By Kiran Manohar Chavala

@kiranchavala [email protected]

© 2016 Accelerite. All Rights Reserved. 2

Agenda

•  Configuration Management •  Why Ansible is required •  Installing Ansible •  Hands on session on a practicle example of Ansible •  Deploying Cloudstack Management server

© 2016 Accelerite. All Rights Reserved. 3

Why Configuration management is important

•  I need these services to be installed and running •  I need this configuration file to contain these lines •  I need this file to exist in this directory •  Centralization of configuration •  Creation of reusable template configurations i.e. web servers, database servers, DHCP servers,

Cloudstack management servers

© 2016 Accelerite. All Rights Reserved. 4

What is Configuration Management?

•  Configuration management is the philosophy of defining the state that a server should be in wrt it’s configuration and using tools that achieve that state

•  CM gives centralization of configuration data and actions •  Configuration Management tools should be idempotent

© 2016 Accelerite. All Rights Reserved. 5

What is Idempotent Operations in mathematics and computer science, that can be applied multiple times without changing the result beyond the initial application. •  You need to add the following lines to the default my.cnf: innodb_rollback_on_timeout=1 innodb_lock_wait_timeout=600 max_connections=350 •  A sed command would add the lines sed -i -e '/symbolic-links=0/ a\innodb_rollback_on_timeout=1' -e '/symbolic-links=0/ a\innodb_lock_wait_timeout=600' -e '/symbolic-links=0/ a\max_connections=350' /etc/my.cnf •  But if you needed to run your script to update/restore another setting then the addition of these lines would be repeated •  A configuration management tool would not add these lines aga

© 2016 Accelerite. All Rights Reserved. 6

How Ansible is different then Chef and Puppet

Technical: •  Client/Server architecture not required •  Only SSH connectivity required (password or public/private keys) making it easier to deploy in

environments •  Modules can be in any language capable of returning JSON or key=value text pairs •  Has an API User: Don’t need to learn a programming language (i.e. Ruby) Chef and puppet are pull-based by default. Agent installed on the servers periodically check in with a central service and pull down con

© 2016 Accelerite. All Rights Reserved. 7

Basic Terminologies

•  Host Inventories •  Roles •  Tasks •  Variables (hosts or groups) •  Modules •  Templates •  Playbooks

© 2016 Accelerite. All Rights Reserved. 8

Installing Ansible

•  Install a centos 6 .x machine •  yum install wget •  wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm •  wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm •  sudo rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm •  yum install -y ansible

© 2016 Accelerite. All Rights Reserved. 9

Configuring Ansible

•  yum install openssh-server openssh-clients •  Yum install git ssh-keygen -t rsa

ssh-copy-id root@remote machine you want to control [root@anscont3 playbooks1]# cat hosts ansibleremote ansible_ssh_host=10.104.49.233 ansible_ssh_port=22 [root@anscont3 playbooks1]# cat ansible.cfg [defaults] hostfile = hosts remote_user = root private_key_file=/root/.ssh/id_rsa host_key_checking = False

© 2016 Accelerite. All Rights Reserved. 10

Use Case Scenarios

•  The remote machine should have set of predefined packages installed https://github.com/fifthecho/CloudStack-Template git clone https://github.com/fifthecho/CloudStack-Template.git

© 2016 Accelerite. All Rights Reserved. 11

Deploying Cloudstack components using Anisble

•  http://docs.cloudstack.apache.org/en/latest/ansible.html •  http://docs.ansible.com/ansible/guide_cloudstack.html •  https://github.com/resmo/ansible-cloudstack

Thank You!