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

Using ansible to manage cloud stack

Embed Size (px)

Citation preview

Page 1: Using ansible to manage cloud stack

September 2016

Using Ansible to manage instances on CloudPlatform

By Kiran Manohar Chavala

@[email protected]

Page 2: Using ansible to manage cloud stack

© 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

Page 3: Using ansible to manage cloud stack

© 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

Page 4: Using ansible to manage cloud stack

© 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

Page 5: Using ansible to manage cloud stack

© 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 linessed -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

Page 6: Using ansible to manage cloud stack

© 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

Page 7: Using ansible to manage cloud stack

© 2016 Accelerite. All Rights Reserved.7

Basic Terminologies

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

Page 8: Using ansible to manage cloud stack

© 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

Page 9: Using ansible to manage cloud stack

© 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 hostsansibleremote ansible_ssh_host=10.104.49.233 ansible_ssh_port=22

[root@anscont3 playbooks1]# cat ansible.cfg [defaults]hostfile = hostsremote_user = rootprivate_key_file=/root/.ssh/id_rsahost_key_checking = False

Page 10: Using ansible to manage cloud stack

© 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

Page 11: Using ansible to manage cloud stack

© 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

Page 12: Using ansible to manage cloud stack

Thank You!