Your SlideShare is downloading. ×
0
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Introducing Saltstack
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Introducing Saltstack

9,698

Published on

These are the slides I used in my local libre user group meetup to introduce Saltstack to my friends and users from varied backgrounds.

These are the slides I used in my local libre user group meetup to introduce Saltstack to my friends and users from varied backgrounds.

Published in: Technology
1 Comment
8 Likes
Statistics
Notes
  • Hi, great introdution into Salt.

    I have taken another approach at slide 18- creating the DB
    i used the state mysql:database.present which creates the db if it does not exist and added the dump via salt 'hostname' cmd.run mysql
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
9,698
On Slideshare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
118
Comments
1
Likes
8
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. SaltStack NOV 2013 www.anubhaskar.name Creative Commons Attribution-ShareAlike 3.0 Unported License.
  • 2. AGENDA 1.Introduction 2.Product Architecture 3.Components 4.Prototype Architecture 5.Prerequisites 6.Install & configure Salt server 7.Install and configure Salt clients 8.Configure LAMP Software repositories 9.Create web site template 10.Configure Apache web server 11.Configure PHP 12.Configure MySQL db server 13.Create sample database 14.Create script to import database 15.Configure sample database import 16.Apply states to target clients Creative Commons Attribution-ShareAlike 3.0 Unported License. 2
  • 3. Introduction Saltstack is a ● Configuration Management System  Keep the hosts configured the way we want them. Maintain hosts in a defined state  Manage packages, config files, services, users, groups etc in an easy to read syntax at central locations  Provision cloud computing instances ● Remote Execution System  Execute commands and query data on remote nodes  Receive results from remote nodes 3 asynchronously Creative Commons Attribution-ShareAlike 3.0 Unported License.
  • 4. Product Architecture Minion1 Salt Master Minion2 Halite (Web UI) MinionN 4 Creative Commons Attribution-ShareAlike 3.0 Unported License.
  • 5. Components ● ● ● ● ● Master - The central server from which Salt commands are run and States are applied Minions - The hosts you are managing, they maintain a connection to the master and await instructions States - Express the state of a host using small, easy to read, easy to understand configuration files. Directives used for configuration management Modules - Collections of functions which can be run from the Salt CLI (and are also run under the hood by States) Grains – Static information collected by minions about the system. The grains interface is made available to other components to make right commands are automatically available to them. 5 Creative Commons Attribution-ShareAlike 3.0 Unported License.
  • 6. Prototype Architecture repo (Centos6/10.10.10.2 Software Repository) salt (Centos6/10.10.10.3) Administration Admin minion (Centos6/10.10.10.4) 6 Creative Commons Attribution-ShareAlike 3.0 Unported License.
  • 7. Prerequisites For simplicity and ease of demonstration below changes are made in prototype. These options should be avoided or carefully considered in a production deployment 1. All the hosts are installed with Centos6.3 minimal install cd. 2. Disable SELinux on both server and client # vi /etc/selinux/config SELINUX=disabled 3. Disable firewall on both server and client # chkconfig iptables off 4. Add host entries on server, client and software repository 10.10.10.2 repo 10.10.10.3 salt 10.10.10.4 minion 5. Reboot server and client hosts Creative Commons Attribution-ShareAlike 3.0 Unported License. 7
  • 8. Install & configure Salt server 1. Install salt server and web-ui on 10.10.10.3 # yum install salt-master # yum install python-halite 2. Configure salt server # vi /etc/salt/master external_auth: pam: halite: - .* - '@runner' file_roots: base: - /srv/salt halite: level: 'debug' server: 'cherrypy' host: '0.0.0.0' port: '8080' cors: False tls: False Creative Commons Attribution-ShareAlike 3.0 Unported License. 8
  • 9. Install & configure Salt server 3. Create a user to login to web-ui # useradd halite # passwd halite 4. Create directory for configuration store # mkdir /srv/salt 5. Start salt server # service salt-master start # chkconfig salt-master on 9 Creative Commons Attribution-ShareAlike 3.0 Unported License.
  • 10. Install & configure Salt clients 1. Install salt client (called minion) on 10.10.10.4 # yum install salt-minion # service salt-minion start # chkconfig salt-minion on 2. Log into salt server and accept SSL key from minion for authorization # salt-key -L # salt-key -a minion 3. Try a test connect from salt server to salt client # salt minion test.ping 4. View details (called grains) of salt client from server # salt minion grains.items 10 Creative Commons Attribution-ShareAlike 3.0 Unported License.
  • 11. Now, let us deploy a simple LAMP using Saltstack LAMP – Linux/Apache/MySQL/PHP 11 Creative Commons Attribution-ShareAlike 3.0 Unported License.
  • 12. Configure LAMP Software Repositories 1. Create webserver yum repo file in salt server # mkdir /srv/salt/softdepo # vi /srv/salt/softdepo/httpd.repo [httpd] name=httpd baseurl=http://10.10.10.2/httpd gpgcheck=0 enabled=1 2. Crete dbserver yum repo file in salt server # vi /srv/salt/softdepo/mysql.repo [mysql] name=mysql baseurl=http://10.10.10.2/mysql gpgcheck=0 enabled=1 3. Create php yum repo file in salt server # vi /srv/salt/softdepo/php.repo [php] name=php baseurl=http://10.10.10.2/php gpgcheck=0 enabled=1 Creative Commons Attribution-ShareAlike 3.0 Unported License. 12
  • 13. Configure LAMP Software Repositories 4. Create software repository state files in salt server # vi /srv/salt/softdepo.sls /etc/yum.repos.d/httpd.repo: file: - managed - source: salt://softdepo/httpd.repo /etc/yum.repos.d/php.repo: file: - managed - source: salt://softdepo/php.repo /etc/yum.repos.d/mysql.repo: file: - managed - source: salt://softdepo/mysql.repo 13 Creative Commons Attribution-ShareAlike 3.0 Unported License.
  • 14. Create web site template 1. Create a php web page template in salt server to display some mysql database values. This web page will be ultimately hosted in our LAMP server # mkdir /srv/salt/webserver # vi /srv/salt/webserver/index.php <?php $con = mysql_connect( 'localhost', 'root' ); $db = mysql_select_db( 'solarsystem' ); $sql = "select * from planets"; $query = mysql_query( $sql ); echo "<table>"; while( $row = mysql_fetch_assoc($query) ) { echo "<tr><td>$row[id]</td>"; echo "<td>$row[name]</td></tr>"; } echo "</table>"; ?> Creative Commons Attribution-ShareAlike 3.0 Unported License. 14
  • 15. Configure Apache web server 2. Create state files in salt server for installing Apache web server # vi /srv/salt/webserver.sls httpd: pkg: - installed service: - running - require: - pkg: httpd /var/www/html/index.php: file: - managed - source: salt://webserver/index.php 15 Creative Commons Attribution-ShareAlike 3.0 Unported License.
  • 16. Configure PHP 1. Create state files in salt server for installing PHP # vi /srv/salt/php.sls php: pkg: - installed php-mysql: pkg: - installed 16 Creative Commons Attribution-ShareAlike 3.0 Unported License.
  • 17. Configure MySQL db server 1. Create state files in salt server for installing MySQL # vi /srv/salt/dbserver.sls mysql-server: pkg: - installed mysqld: service: - running - require: - pkg: mysql-server 17 Creative Commons Attribution-ShareAlike 3.0 Unported License.
  • 18. Create a sample database to import into db server 1. Create a database dump file in salt server to import data to mysql server # mkdir /srv/salt/dbcreate # vi /srv/salt/dbcreate/dbdump.sql CREATE DATABASE IF NOT EXISTS `solarsystem`; USE `solarsystem`; DROP TABLE IF EXISTS `planets`; CREATE TABLE `planets` ( `id` int(8) NOT NULL DEFAULT '0', `name` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; LOCK TABLES `planets` WRITE; INSERT INTO `planets` VALUES (1,'mercury'),(2,'venus'), (3,'earth'),(4,'mars'),(5,'jupiter'),(6,'saturn'),(7,'uranus'), (8,'neptune'),(9,'pluto'); UNLOCK TABLES; Creative Commons Attribution-ShareAlike 3.0 Unported License. 18
  • 19. Create a script to import sample database 2. Create a shell script in salt server to import sample database # vi /srv/salt/dbcreate/dbcreate.sh #! /bin/bash mysql -u root < /tmp/dbdump.sql 19 Creative Commons Attribution-ShareAlike 3.0 Unported License.
  • 20. Configure sample data base import to db server 1. Create saltstack state files in salt server for importing data to db server # vi /srv/salt/dbcreate.sls /tmp/dbdump.sql: file: - managed - source: salt://dbcreate/dbdump.sql /tmp/dbcreate.sh: file: - managed - source: salt://dbcreate/dbcreate.sh dbcreate.sh: cmd: - run - name: | chmod +x /tmp/dbcreate.sh /tmp/dbcreate.sh Creative Commons Attribution-ShareAlike 3.0 Unported License. 20
  • 21. Apply states to target client 1. Create a top.sls file in salt server to map state files to target hosts and specify execution order # vi /srv/salt/top.sls base: minion: - softdepo - php - dbserver - dbcreate - webserver 2. Apply states to target client from salt server # salt minion state.highstate 3. View hosted website at http://10.10.10.4/index.php 21 Creative Commons Attribution-ShareAlike 3.0 Unported License.
  • 22. THANK YOU 22 Creative Commons Attribution-ShareAlike 3.0 Unported License.

×