2. Our Purpose
Make ourselves ‘Business partner’ from
‘factory’.
Points
Engineering knowledge <- * TODAY *
Logical Thinking
Co-operation work
— Study Group —
3. What’s DevOps?
Mindset of filling gap between Dev and Ops.
It’s not any technologies or solutions.
C.A.M.S
Culture
Bust silos. Don’t say “no”. Involve everyone.
Automation
XXX as Code. Ask machines to do same things.
Metrics
monitor, find failure, Improve, make a plan.
Share
Dev->Ops, Ops->Dev, share metrics.
Feedback of previous study
4. Feedback of previous study (2)
What’s Vagrant?
manager of Virtual Machines
Vagrant can manage …
Virtual Box
VMware (Fusion)
AWS EC2 ….
Trigger of automation engine.
Vagrant run …
Ansible
Chef
Puppet ….
5. Feedback of previous study (3)
What’s ansible?
A radically simple IT automation engine
for ‘infrastructure as Code’…
“Ask machines to do SAME things”
Trial
Simple usage (hosts and playbook)
Set in Vagrantfile
8. What’s Idempotence?
The property that can be applied
multiple times without changing
the result beyond the initial
application. (wikipedia)
Ansible is idempotence !?
9. What’s Idempotence?
The property that can be applied
multiple times without changing
the result beyond the initial
application. (wikipedia)
Ansible is idempotence !?
Ansible playbook should be idempotence.
10. Why do you learn Ansible here?
DevOps -> Automation (C.A.M.S.)
11. Why do you learn Ansible here?
DevOps -> Automation (C.A.M.S.)
Automation
Infrastructure as Code.
Clarify specification.
- playbook
Guarantee same result.
- Idempotence
12. Why do you learn Ansible here?
DevOps -> Automation (C.A.M.S.)
Automation
Infrastructure as Code.
Clarify specification.
- playbook
Guarantee same result.
- Idempotence
13. Why do you learn Ansible here?
DevOps -> Automation (C.A.M.S.)
Automation
Infrastructure as Code.
Clarify specification.
- playbook
Guarantee same result.
- Idempotence
You need to check results carefully for each
operation, if it is not guaranteed to get same
result when you do it repeatedly.
15. What’s Idempotence?
How to install version
specified application
How to build ‘tarball’?
How to create playbooks?
AGENDA
16. Application
Server applications is NOT gifts
from Buddha.
Server application is NOT
packages of YUM/Apt/RPM.
Almost server apps are
only C/C++ applications.
You can install Apps without Package manager.
17. How to make C/C++ apps?
#include "stdio.h"
int main(int argc, char *argv[])
{
printf("Hello, world!n");
return 0;
}
hello.c
$ gcc -o hello hello.c
$ ls
hello* hello.c
$ ./hello
Hello, world!
$
compile
execute
18. More complex C++ apps
Shared libraries (*.so files)
Objects which are built from
only classes/functions.
Header files (*.h)
Definition I/F of classes, functions…
+
Shared object file (*.so)
Built binary of classes, functions…
19. How to link to .so file?
application
Static link
include libs inside
the application
application
Dynamic link
Use libraries directly
from the application.
While compiling, header files are used to get
I/F of classes/functions of libraries.
20. Complex applications
PHP
Ex. php
…
It used many libs.
libxml2.so libkrb5.so
$ ldd `which php` | wc -l
43
$
In my case, 43 libs
are used.
$ otool -L `which php` (on OSX)
21. PHP
Ex. php
…
You need to check every libs(headers) are
exists for each extensions.
libxml2.so libkrb5.so
In my case, 43 libs
are used.
Too Heavy !!
$ ldd `which php` | wc -l
43
$
$ otool -L `which php` (on OSX)
It used many libs.
Complex applications
22. More complex C++ apps (4)
Make
Configure
Great task runner. Love it.
(BSD) make, GNU make (gmake)
$ make
$ make install
Check environment of the system.
- checking libs and its versions.
- create Makefile for your option.
GNU Autotools
Tools to create configure scripts for your
applications. It’s too troublesome to
create ‘configure’ by yourself.
25. Preparation (for Vagrant)
$ vagrant sandbox status
[default] Sandbox mode is on
$ vagrant sandbox rollback
[default] Rolling back the virtual machine...
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
$ vagrant sandbox status
[default] Sandbox mode is on
$
check ‘sandbox mode is ON’
Rollback your vagrant machine to
pure vagrant, if you’ve already
modified it.
26. Preparation (httpd, mysqld)
To test PHP build,
Install MySQL, httpd(apache2) by
package manager.
[vagrant@vagrant-centos65 ~]$ sudo yum install mysql
mysql-server httpd httpd-devel
Login: Vagrant machine
$ vagrant ssh
Last login: Thu Dec 10 01:57:16 2015 from 10.0.2.2
[vagrant@vagrant-centos65 ~]$
27. Build (get php tarball)
[vagrant@vagrant-centos65 ~]$ mkdir tmp
[vagrant@vagrant-centos65 ~]$ cd tmp
[vagrant@vagrant-centos65 tmp]$ sudo yum install wget
Loaded plugins: fastestmirror, versionlock
Determining fastest mirrors
epel/metalink | 4.9 kB 00:00
:
Installed size: 1.8 M
Is this ok [y/N]: y
:
Complete!
[vagrant@vagrant-centos65 tmp]$ wget http://sg2.php.net/
distributions/php-5.4.44.tar.gz
[vagrant@vagrant-centos65 tmp]$ ls -al php-5.4.44.tar.gz
-rw-rw-r-- 1 vagrant vagrant 15878182 Aug 6 23:00
php-5.4.44.tar.gz
[vagrant@vagrant-centos65 tmp]$
get tarball
29. Build (check configure options)
[vagrant@vagrant-centos65 php-5.4.44]$ ./configure --help > conf.list
[vagrant@vagrant-centos65 php-5.4.44]$ less conf.list
Get option list
`configure' configures this package to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
:
:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
:
:
PEAR:
--with-pear=DIR Install PEAR in DIR [PREFIX/lib/php]
--without-pear Do not install PEAR
:
:
CXXCPP C++ preprocessor
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to the package provider.
31. Build (configure-1 )
[vagrant@vagrant-centos65 php-5.4.44]$ ./configure --with-apxs2 --
with-mysql --enable-intl --enable-mbstring --enable-mbregex 2>&1 |
tee 00config.log
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
:
checking libxml2 install dir... no
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2
installation.
[vagrant@vagrant-centos65 php-5.4.44]$
You need “libxml2”.
Try configure with your option
32. [vagrant@vagrant-centos65 tmp]$ sudo yum install libxml2 libxml2-devel
Loaded plugins: fastestmirror, versionlock
:
Total download size: 8.6 M
Is this ok [y/N]: y
Downloading Packages:
:
Complete!
[vagrant@vagrant-centos65 tmp]$
Build (configure-2 )
Search “libxml2” in yum packages.
[vagrant@vagrant-centos65 tmp]$ sudo yum search libxml2
Loaded plugins: fastestmirror, versionlock
:
libxml2.x86_64 : Library providing XML and HTML support
libxml2.i686 : Library providing XML and HTML support
libxml2-devel.i686 : Libraries, includes, etc. to develop XML and HTML applications
libxml2-devel.x86_64 : Libraries, includes, etc. to develop XML and HTML applications
:
Name and summary matches only, use "search all" for everything.
[vagrant@vagrant-centos65 tmp]$
Install the lib and devel packages.
33. Build (configure-2 )
Try repeatedly until success.
[vagrant@vagrant-centos65 php-5.4.44]$ ./configure --with-apxs2 --
with-mysql --enable-intl --enable-mbstring --enable-mbregex 2>&1 |
tee 00config.log
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
:
Thank you for using PHP.
config.status: creating php5.spec
:
config.status: executing default commands
[vagrant@vagrant-centos65 php-5.4.44]$
libxml2
libxml2-devel
icu
libicu-devel
Required packages
34. Build (make )
Compile and link.
[vagrant@vagrant-centos65 php-5.4.44]$ make 2>&1 | tee 01make.log
/bin/sh /home/vagrant/tmp/php-5.4.44/libtool --silent --preserve-dup-
deps --mode=compile cc -Iext/date/lib -Iext/date/ -I/home/vagrant/tmp/
php-5.....
:
:
:
:
:
:
:
:
:
Build complete.
Don't forget to run 'make test'.
[vagrant@vagrant-centos65 php-5.4.44]$
It takes minutes.
Have a break.
35. Build (make install )
Install binaries and libraries.
[vagrant@vagrant-centos65 php-5.4.44]$ sudo make install 2>&1 | tee 02install.log
Installing PHP SAPI module: apache2handler
:
libtool: install: cp .libs/libphp5.so /usr/lib64/httpd/modules/libphp5.so
:
Installing PHP CLI binary: /usr/local/bin/
:
Installing PDO headers: /usr/local/include/php/ext/pdo/
[vagrant@vagrant-centos65 php-5.4.44]$
check
[vagrant@vagrant-centos65 php-5.4.44]$ ls -al /usr/lib64/httpd/modules/libphp5.so
-rwxr-xr-x 1 root root 253886 Dec 10 06:16 /usr/lib64/httpd/modules/libphp5.so
[vagrant@vagrant-centos65 php-5.4.44]$ php -v
PHP 5.4.44 (cli) (built: Dec 10 2015 06:03:36)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
[vagrant@vagrant-centos65 php-5.4.44]$
Note) please do ‘make test’ before install.
36. Now You know...
1. Required applications (packages)
- mysql, mysql-server
- httpd, httpd-devel
2. Required libraries (packages)
- libxml2, libxml2-devel
- icu, libicu-devel
3. Commands to install PHP.
37. What’s Idempotence?
How to install version
specified application
How to build ‘tarball’?
How to create playbooks?
AGENDA
38. Rollback
$ vagrant sandbox rollback
[default] Rolling back the virtual machine...
0%...10%...20%...30%...40%...50%...60%...70%...80%...
90%...100%
0%...10%...20%...30%...40%...50%...60%...70%...80%...
90%...100%
$ vagrant sandbox status
[default] Sandbox mode is on
$
Your vagrant is rollbacked.
- no httpd, mysqld, httpd.
40. Vagrantfile
:
:
# Ansible
config.vm.provision "ansible" do |ansible|
ansible.playbook = "./setup.yml"
ansible.inventory_path = "./hosts"
ansible.limit = "httpd-server"
end
:
:
./Vagrantfile
‘./setup.yml’, ‘./hosts’ will be loaded.
41. Create playbooks (preparation-1)
# setup httpd
- include: playbooks/httpd.yml
# setup mysql
- include: playbooks/mysqld.yml
# setup php
- include: playbooks/php.yml
./setup.yml
[httpd-server]
192.168.33.50
./hosts
IP address of your Vagrant machine
42. Create playbooks (preparation-2)
httpd.yml - hosts: httpd-server
become: yes
tasks:
- name: install httpd yum packages
yum: name={{ item }} state=latest
with_items:
- httpd
- httpd-devel
- name: be sure httpd is running and enabled
service: name=httpd state=started enabled=yes
mysqld.yml - hosts: httpd-server
become: yes
tasks:
- name: install mysql yum packages
yum: name={{ item }} state=latest
with_items:
- mysql
- mysql-server
- name: be sure httpd is running and enabled
service: name=mysqld state=started enabled=yes
43. Create playbooks (php)
1. install related packages
2. create work directory
3. get a tarball
4. unarchive tarball
5. configure source
6. make source
7. make install source
A
B
D
C
step by step !
49. Homework
B. put your own ‘php.ini’, ‘httpd.conf’ by
Ansible playbook.
- Note) Use ‘copy’ or ‘template’ modules.
- http://docs.ansible.com/ansible/copy_module.html
- http://docs.ansible.com/ansible/template_module.html
A. Learn UNIX(SystemV) commands.
- ldconfig
- ldd (on OSX, ‘otools -L’)
C. Restart httpd after php installation