Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
1
______________________________
/ DevOps 
 Ansible & GitLab CI (2nd)/
------------------------------

 ^__^
 (oo)_______
...
2
Today we use 95
Docker containers
in DigitalOcean.
3
Ready?
4
• (@chusiang_lai)
•
• DevOps Taiwan
• 5 IT
5
Outline
• DevOps
•
6
Outline
• DevOps
•
• Ansible
• Ansible
• Ansible
7
Outline
• GitLab
• Pipeline
• GitLab CI
8
Outline
• GitLab
• Pipeline
• GitLab CI
• Ansible GitLab CI
• Q&A
9
Ⅰ. DevOps
10
DevOps
11
DevOps
Infra
12
Dev Ops
ITSM※ Mark Smalley x DevOpsDays Taipei 2017 - https://youtu.be/qWbcujKw57c?t=9m39s
DevOps
Dev
Ops
On-call
Coding
13
Ops
On-call
14
DevOps
20
On-call
Coding
code
" "
15
Tools
Git, GitLab
GitLab CI
Ansible
Docker
16
License
LGPL
MIT
GPL
Apache
17
Tools
Ansible
Chef, Puppet, Slat
Docker
AWS, Vagrant
OpenStack
GitLab CI,
Jenkins CI,
Drone CI
Git, GitLab
GitHub
18
Ⅱ.
Continuous Delivery - https://goo.gl/r9vXFg
19
- Jez Humble & David Farley
Continuous Delivery - https://goo.gl/SK745B
20
21
22
23
24
25
26
Continuous Delivery
Continuous Deployment
auto auto manual
Build Deploy Test Release
auto auto auto
Build Deploy Test Rele...
Release Production
Continuous Delivery
Continuous Deployment
auto auto manual
Build Deploy Test Release
auto auto auto
Bui...
29
R&D CD
Code
Git server
R&D
( )
30
After
< 5 min
commit
↓
31
R&D CD
Code
Git server
32
The Phoenix Project
Amazon - https://goo.gl/visckK
33
Ⅲ. Ansible
34
Ansible 

Ender
- https://goo.gl/4xftZT
35
Ansible 2013
2015 Red Hat
iThome - http://goo.gl/yJbWtz
36
GitHub 26,606 3,090
37
Ansible Tower
Linuxpilot 2017
Linux & OSS 

Linuxpilot - https://goo.gl/mSxR4E
38
Ansible Tower
https://www.ansible.com/blog/red-hat-ansible-automation-engine-vs-tower
39
Ansible
1. Puppet SaltStack Chef
2. Python like 

(Infrastructure as Code)
40
Python
Ansible
SaltStack
Ruby
Chef
Puppet
vs
41
Ansible
3. Agent Python SSH
4.
5.
42
26 hr
(6 x 3) x 2 - (5 x 1) x 2 = 26 hr
43
0
350
700
1,050
1,400
Week Month Year
104 hr
26 hr
1,352 hr
44
0
125,000
250,000
375,000
500,000
Week Month Year
$35,360
$8,840
$459,680
45
DevOps Taiwan

( )
https://github.com/DevOpsTW/jobs/
46
Ⅳ. Ansible
47
Control Machine + Managed node × 2 (Ubuntu 16.04 × 3)
Ansible Jupyter Managed node
48
LAB1
Jupyer
Ansible
inventory Managed node SSH Python
49
Ansible
• Control Machine ( ) Ansible
Managed node Python 2.5+ SSH
$ sudo apt install ansible # Debian, Ubuntu.
$ sudo yum...
Jupyter Ansible
ansible.cfg inventory
51
Ansible
• ansible.cfg inventory (hostsfile)
Managed node ( ) SSH …
$ vim ansible.cfg
1 [defaults]
2 inventory = inventory #...
inventory
• Managed node ( ) 

ssh winrm
$ vim inventory
1 # LAB Host ssh Containers
2
3 [staging]
4 stg.demo.drx.tw ansib...
Ⅴ. Ansible
Ad-Hoc command, Playbook* (Module)
54
Ad-Hoc
commands
55
command line
• command line Linux Shell
ping echo
$ ping localhost
PING localhost (127.0.0.1): 56 data bytes
64 bytes from...
Ad-Hoc commands
ansible <host-pattern> [-m module_name] [-a args] [options]
• host-pattern: all, server1, server1:server2,...
58
Play

Ad-hoc commands
Playbooks
59
60
Playbooks
• Shell Script
• YAML
Baby Playbook Onesie - http://goo.gl/GKJvXn
61
Playbooks
• Play, Task,
Module handler
• Jinja2 template
Baby Playbook Onesie - http://goo.gl/GKJvXn
62
Playbooks
• Playbook Play Task Module
• Play × 1, Task × 2 Module × 2 (command, apt) 

























$ vim ex...
63
Playbooks
• playbook
$ ansible-playbook example2.yml
PLAY [a sample playbook.] ****************************************...
64
• playbook
Playbooks
$ ansible-playbook example2.yml
PLAY [a sample playbook.] ****************************************...
65
• (Play) Managed node Task Module
• Play × 1, Task × 2 Module × 2 (command, apt) 

























Plays
$ vim ...
66
• (Module) (Task)
• Play × 1, Task × 2 Module × 2 (command, apt) 

























Tasks
$ vim example.yml
1 --...
67
• (Method) Python
• Play × 1, Task × 2 Module × 2 (command, apt) 

























Modules
$ vim example.yml
1 ...
http://s.drx.tw/auto-with-ansible-12
69
apt
• Debian Ubuntu apt (Packaging Modules)
• Linux apt, apt-get, aptitude dpkg 























# ( ) apt-get u...
70
lineinfile
• (Files Modules)
• Linux sed 























# Before 2.3, option 'dest', 'destfile' or 'name' was u...
71
shell
• /bin/sh shell (Commands Modules)
(variables) < , > , | , ; & 























# ls wc
- name: check file...
72
Play Playbooks
Playbooks Samples
• Ansible Role: Install Vim and use vi-mode in everyway 

- https://github.com/chusiang/vim-and-vi-mode....
Ⅵ. GitLab
74
Git Repository Docker Registry Issue tracking Code Review CI/CD
75
Ansible Inc. Ecosystems
https://www.ansible.com/blog/red-hat-ansible-automation-engine-vs-tower
76
GitLab
https://www.ansible.com/blog/red-hat-ansible-automation-engine-vs-tower
GITLAB
77
CONTROL KNOWLEDGE
GitLab
https://www.ansible.com/blog/red-hat-ansible-automation-engine-vs-tower
GITLAB
78
CONTROL KNOWLEDGE
GitLab CI, Pipe...
GitLab
https://www.ansible.com/blog/red-hat-ansible-automation-engine-vs-tower
GITLAB
79
CONTROL KNOWLEDGE
GitLab
Web, Iss...
Ⅶ. Pipeline
( )
80
Ch 5.
Ch 6.
Ch 7.
Ch 8.
Ch 9.
Ch 10.
Pipeline
Continuous Delivery - https://goo.gl/r9vXFg
81
binaries
binaries
UAT
binaries
binaries
binaries
Binary
binaries
metadata
binaries metadata binaries
binaries
metadata met...
binaries
binaries
UAT
binaries
binaries
binaries
Binary
binaries
metadata
binaries metadata binaries
binaries
metadata met...
– Chu-Siang Lai
Pipeline
84
GitLab Pipelines
85
Ⅷ. GitLab CI
.gitlab-ci.yml GitLab GitLab CI
86
• YAML
• stage × 1 job × 1 





















.gitlab-ci.yml
$ vim .gitlab-ci.yml
1 stages:
2 - build
3
4 build_binary:...
GitLab CI
$ git push --> GitLab
88
All Pipelines
89
Pipelines #13803169
90
Job #39892610
91
Ⅸ. Ansible GitLab CI
GitLab CI Ansible (Docker Containers) Playbooks
92
Control Machine (Alpine 3.6) + Managed node × 2 (Ubuntu 16.04)
GitLab CI Ansible Managed node
93
LAB2
GitLab CI




94
Git server GitLab
CI server Build Deploy Test
Engineer
95
Develop
Customer
Git server GitLab
CI server Build Deploy Test Release
Engineer
96
Master
AnsibleGitLab CIDocker
97
https://hub.docker.com/r/chusiang/ansible/
0
98
http://s.drx.tw/cd.lab
1
99
Build stage
2
TestDeploy ReleaseBuild
100
Deploy, Test,
Release stages
3
DeployBuild Test Release
101
Customer
Git server GitLab
CI server Build Deploy Test Release
Engineer
Coding & Git Commit
102
Customer
Git server GitLab
CI server Build Deploy Test Release
Engineer
Git Push
Coding & Git Commit
103
Customer
Git server GitLab
CI server Build Deploy Test Release
Engineer
.gitlab-ci.yml
104
$ vim .gitlab-ci.yml
1 stages:
2 - build
3 - deploy
4 - test
5 - release
6
7 build_binary:
8 image: ubuntu:16.04
9 stage: ...
22
23 deploy_to_dev:
24 image: chusiang/ansible:alpine-3.6
25 stage: deploy
26 script:
27 - ls
28 - cd ansible-playbooks/
...
38
39 test_dev:
40 image: chusiang/ansible:alpine-3.6
41 stage: test
42 script:
43 - cd ansible-playbooks/
44 - echo "${VA...
53
54 release_to_prd:
55 image: chusiang/ansible:alpine-3.6
56 stage: release
57 script:
58 - cd ansible-playbooks/
59 - e...
Customer
Git server GitLab
CI server Build Deploy Test Release
Engineer
.gitlab-ci.yml
109
Customer
Git server GitLab
CI server Build Deploy Test Release
Engineer
Package deb file
110
Customer
Git server GitLab
CI server Build Deploy Test Release
Engineer
Play deploy.yml
111
Customer
Git server GitLab
CI server Build Deploy Test Release
Engineer
Play test.yml
112
Customer
Git server GitLab
CI server Build Deploy Test Release
Engineer
Play deploy.yml
113
Customer
Git server GitLab
CI server Build Deploy Test Release
Engineer
Feedback
114
Customer
Git server GitLab
CI server Build Deploy Test Release
Engineer
115
LAB2
https://gitlab.com Fork http://s.drx.tw/cd.lab 



$ git clone git@gitlab.com:<USERNAME>/continuous-
delivery-worksho...
Pipelines
8
117
118
Control Machine + Managed node × 2 (Ubuntu 16.04 × 3)
Ansible Jupyter Managed node
119
LAB1
Jupyer
$ docker pull 

chusiang/ansible-jupyter:ubuntu-16.04
120
LAB1
Control Machine 

$ docker run -Pd chusiang/ansible-jupyter:ubuntu-16.04

Managed node × 2 

$ docker run -Pd 

chusi...
LAB1
inventory 

Ad-hoc commands 

Playbooks
122
123
Ansible on Jupyter
Control Machine (Alpine 3.6) + Managed node × 2 (Ubuntu 16.04)
GitLab CI Ansible Managed node
124
LAB2
GitLab CI
LAB2 x AWS - https://youtu.be/QHim_JxB4ZY
125
– Chu-Siang Lai
126
Pipeline
Unit Test Integration Test Delivery DeploymentBuildSyntax Check
Unit Test Delivery DeploymentBuildSyntax Check
Un...
DevOps
128
※ Chen Cheng-Wei Effective DevOps (https://www.slideshare.net/warfan/effective-devops-78979993)
• DevOps by Chen Cheng-Wei - https://goo.gl/7YTeKD
• Continuous Delivery - by Miles - https://goo.gl/UhpAfG
• Ansible Docu...
• Continuous Delivery | Amazon.com - https://www.amazon.com/dp/0321601912
• Continuous Delivery | - https://goo.gl/SK745B
...
https://www.facebook.com/groups/DevOpsTaiwan/
https://devopstw.club/
DevOps Taiwan
https://gitter.im/DevOpsTW/
132
Ansible Taiwan
https://telegram.me/ansible_tw
https://github.com/ansible-tw
http://ansible.tw
133
http:// .tw
134
Q & A
135
END
136
Prochain SlideShare
Chargement dans…5
×

Continuous Delivery Workshop with Ansible x GitLab CI (2nd+)

1 760 vues

Publié le

# DevOps 人一定要知道的持續交付技巧 - Ansible & GitLab CI 實戰演練 (2nd+)

> https://speakerdeck.com/chusiang/continuous-delivery-workshop-with-ansible-x-gitlab-ci-2nd-plus

Ansible 是個與 Puppet, Salt, Chef 並列其四的 Infrastructure as Code 組態設定工具,其簡單易用的特性讓人愛不釋手;GitLab 是業界常見的 Git 私有版本控制服務,搭配其 GitLab CI 更能建立屬於自己的發佈流程。

本次凍仁將藉由工作坊的形式,帶領大家一探持續交付的世界和自動化的威力!

* 活動網址: https://studyarea.kktix.cc/events/54eabc9a
* Wiki: https://gitlab.com/chusiang/continuous-delivery-workshop/wikis/home

#Ansible #GitLab #DevOps #Workshop

註:此為 2017/11/12 的修訂版。

Publié dans : Technologie
  • I have always found it hard to meet the requirements of being a student. Ever since my years of high school, I really have no idea what professors are looking for to give good grades. After some google searching, I found this service ⇒ www.HelpWriting.net ⇐ who helped me write my research paper.
       Répondre 
    Voulez-vous vraiment ?  Oui  Non
    Votre message apparaîtra ici
  • Have you ever used the help of ⇒ www.WritePaper.info ⇐? They can help you with any type of writing - from personal statement to research paper. Due to this service you'll save your time and get an essay without plagiarism.
       Répondre 
    Voulez-vous vraiment ?  Oui  Non
    Votre message apparaîtra ici
  • Get the best essay, research papers or dissertations. from ⇒ www.HelpWriting.net ⇐ A team of professional authors with huge experience will give u a result that will overcome your expectations.
       Répondre 
    Voulez-vous vraiment ?  Oui  Non
    Votre message apparaîtra ici

Continuous Delivery Workshop with Ansible x GitLab CI (2nd+)

  1. 1. 1 ______________________________ / DevOps Ansible & GitLab CI (2nd)/ ------------------------------ ^__^ (oo)_______ (__) )/ ||----w | || || [ chusiang@study-area-tainan ~ ] $ cat .profile # Author: / chusiang@drx.tw # Blog: http://note.drx.tw # Modified: 2017-11-11 11:11
  2. 2. 2
  3. 3. Today we use 95 Docker containers in DigitalOcean. 3
  4. 4. Ready? 4
  5. 5. • (@chusiang_lai) • • DevOps Taiwan • 5 IT 5
  6. 6. Outline • DevOps • 6
  7. 7. Outline • DevOps • • Ansible • Ansible • Ansible 7
  8. 8. Outline • GitLab • Pipeline • GitLab CI 8
  9. 9. Outline • GitLab • Pipeline • GitLab CI • Ansible GitLab CI • Q&A 9
  10. 10. Ⅰ. DevOps 10
  11. 11. DevOps 11
  12. 12. DevOps Infra 12 Dev Ops ITSM※ Mark Smalley x DevOpsDays Taipei 2017 - https://youtu.be/qWbcujKw57c?t=9m39s DevOps
  13. 13. Dev Ops On-call Coding 13
  14. 14. Ops On-call 14
  15. 15. DevOps 20 On-call Coding code " " 15
  16. 16. Tools Git, GitLab GitLab CI Ansible Docker 16
  17. 17. License LGPL MIT GPL Apache 17
  18. 18. Tools Ansible Chef, Puppet, Slat Docker AWS, Vagrant OpenStack GitLab CI, Jenkins CI, Drone CI Git, GitLab GitHub 18
  19. 19. Ⅱ. Continuous Delivery - https://goo.gl/r9vXFg 19
  20. 20. - Jez Humble & David Farley Continuous Delivery - https://goo.gl/SK745B 20
  21. 21. 21
  22. 22. 22
  23. 23. 23
  24. 24. 24
  25. 25. 25
  26. 26. 26
  27. 27. Continuous Delivery Continuous Deployment auto auto manual Build Deploy Test Release auto auto auto Build Deploy Test Release 27
  28. 28. Release Production Continuous Delivery Continuous Deployment auto auto manual Build Deploy Test Release auto auto auto Build Deploy Test Release 28
  29. 29. 29
  30. 30. R&D CD Code Git server R&D ( ) 30
  31. 31. After < 5 min commit ↓ 31
  32. 32. R&D CD Code Git server 32
  33. 33. The Phoenix Project Amazon - https://goo.gl/visckK 33
  34. 34. Ⅲ. Ansible 34
  35. 35. Ansible 
 Ender - https://goo.gl/4xftZT 35
  36. 36. Ansible 2013 2015 Red Hat iThome - http://goo.gl/yJbWtz 36
  37. 37. GitHub 26,606 3,090 37
  38. 38. Ansible Tower Linuxpilot 2017 Linux & OSS 
 Linuxpilot - https://goo.gl/mSxR4E 38
  39. 39. Ansible Tower https://www.ansible.com/blog/red-hat-ansible-automation-engine-vs-tower 39
  40. 40. Ansible 1. Puppet SaltStack Chef 2. Python like 
 (Infrastructure as Code) 40
  41. 41. Python Ansible SaltStack Ruby Chef Puppet vs 41
  42. 42. Ansible 3. Agent Python SSH 4. 5. 42
  43. 43. 26 hr (6 x 3) x 2 - (5 x 1) x 2 = 26 hr 43
  44. 44. 0 350 700 1,050 1,400 Week Month Year 104 hr 26 hr 1,352 hr 44
  45. 45. 0 125,000 250,000 375,000 500,000 Week Month Year $35,360 $8,840 $459,680 45
  46. 46. DevOps Taiwan
 ( ) https://github.com/DevOpsTW/jobs/ 46
  47. 47. Ⅳ. Ansible 47
  48. 48. Control Machine + Managed node × 2 (Ubuntu 16.04 × 3) Ansible Jupyter Managed node 48 LAB1 Jupyer
  49. 49. Ansible inventory Managed node SSH Python 49
  50. 50. Ansible • Control Machine ( ) Ansible Managed node Python 2.5+ SSH $ sudo apt install ansible # Debian, Ubuntu. $ sudo yum install ansible # RHEL, CentOS. $ sudo pip install ansible # Python (pip). $ brew install ansible # macOS (homebrew). 50
  51. 51. Jupyter Ansible ansible.cfg inventory 51
  52. 52. Ansible • ansible.cfg inventory (hostsfile) Managed node ( ) SSH … $ vim ansible.cfg 1 [defaults] 2 inventory = inventory # inventory 3 4 remote_user = docker # 5 6 #private_key_file = ~/.ssh/id_rsa 7 8 host_key_checking = False # ssh 52
  53. 53. inventory • Managed node ( ) 
 ssh winrm $ vim inventory 1 # LAB Host ssh Containers 2 3 [staging] 4 stg.demo.drx.tw ansible_ssh_host=demo.drx.tw ansible_ssh_port=10022 5 6 [production] 7 prd.demo.drx.tw ansible_ssh_host=demo.drx.tw ansible_ssh_port=20022 53
  54. 54. Ⅴ. Ansible Ad-Hoc command, Playbook* (Module) 54
  55. 55. Ad-Hoc commands 55
  56. 56. command line • command line Linux Shell ping echo $ ping localhost PING localhost (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.037 ms --- localhost ping statistics --- 1 packets transmitted, 1 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 0.037/0.037/0.037/0.000 ms $ echo Hello World Hello World 56
  57. 57. Ad-Hoc commands ansible <host-pattern> [-m module_name] [-a args] [options] • host-pattern: all, server1, server1:server2, server_group. $ ansible all -m ping localhost | SUCCESS => { "changed": false, "ping": "pong" } $ ansible all -m command -a "echo Hello World" localhost | SUCCESS | rc=0 >> Hello World # Module All Modules 57
  58. 58. 58 Play
 Ad-hoc commands
  59. 59. Playbooks 59
  60. 60. 60 Playbooks • Shell Script • YAML Baby Playbook Onesie - http://goo.gl/GKJvXn
  61. 61. 61 Playbooks • Play, Task, Module handler • Jinja2 template Baby Playbook Onesie - http://goo.gl/GKJvXn
  62. 62. 62 Playbooks • Playbook Play Task Module • Play × 1, Task × 2 Module × 2 (command, apt) 
 
 
 
 
 
 
 
 
 
 
 
 
 $ vim example.yml 1 --- 2 - name: a sample playbook 3 hosts: all 4 tasks: 5 - name: Hello World 6 command: echo "Hello World" 7 - name: Install Vim 8 become: true 9 apt: 10 name: vim
  63. 63. 63 Playbooks • playbook $ ansible-playbook example2.yml PLAY [a sample playbook.] ******************************************* TASK [setup]********************************************************* ok: [stg.demo.drx.tw] TASK [Hello World] ************************************************** changed: [stg.demo.drx.tw] TASK [Install Vim] ************************************************** changed: [stg.demo.drx.tw] => (item=[u'vim']) PLAY RECAP ********************************************************** stg.demo.drx.tw : ok=1 changed=2 unreachable=0 failed=0
  64. 64. 64 • playbook Playbooks $ ansible-playbook example2.yml PLAY [a sample playbook.] ******************************************* TASK [setup]********************************************************* ok: [stg.demo.drx.tw] TASK [Hello World] ************************************************** changed: [stg.demo.drx.tw] TASK [Install Vim] ************************************************** changed: [stg.demo.drx.tw] => (item=[u'vim']) PLAY RECAP ********************************************************** stg.demo.drx.tw : ok=1 changed=2 unreachable=0 failed=0 TASK [setup] managed node PLAY RECAP (ok / changed / failed )
  65. 65. 65 • (Play) Managed node Task Module • Play × 1, Task × 2 Module × 2 (command, apt) 
 
 
 
 
 
 
 
 
 
 
 
 
 Plays $ vim example.yml 1 --- 2 - name: a sample playbook 3 hosts: all 4 tasks: 5 - name: Hello World 6 command: echo "Hello World" 7 - name: Install Vim 8 become: true 9 apt: 10 name: vim Play
  66. 66. 66 • (Module) (Task) • Play × 1, Task × 2 Module × 2 (command, apt) 
 
 
 
 
 
 
 
 
 
 
 
 
 Tasks $ vim example.yml 1 --- 2 - name: a sample playbook 3 hosts: all 4 tasks: 5 - name: Hello World 6 command: echo "Hello World" 7 - name: Install Vim 8 become: true 9 apt: 10 name: vim Task 1 Task 2
  67. 67. 67 • (Method) Python • Play × 1, Task × 2 Module × 2 (command, apt) 
 
 
 
 
 
 
 
 
 
 
 
 
 Modules $ vim example.yml 1 --- 2 - name: a sample playbook 3 hosts: all 4 tasks: 5 - name: Hello World 6 command: echo "Hello World" 7 - name: Install Vim 8 become: true 9 apt: 10 name: vim Module
  68. 68. http://s.drx.tw/auto-with-ansible-12
  69. 69. 69 apt • Debian Ubuntu apt (Packaging Modules) • Linux apt, apt-get, aptitude dpkg 
 
 
 
 
 
 
 
 
 
 
 
 # ( ) apt-get update - name: Update repositories cache become: true apt: update_cache: yes # vim - name: Install the package "vim" become: true apt: name: vim state: present
  70. 70. 70 lineinfile • (Files Modules) • Linux sed 
 
 
 
 
 
 
 
 
 
 
 
 # Before 2.3, option 'dest', 'destfile' or 'name' was used instead of ‘path'. # SELinux - name: disable selinux lineinfile: path: /etc/selinux/config regexp: '^SELINUX=' line: 'SELINUX=enforcing' # docker sudo - name: remove sudo permission of docker lineinfile: path: /etc/sudoers state: absent regexp: '^docker'
  71. 71. 71 shell • /bin/sh shell (Commands Modules) (variables) < , > , | , ; & 
 
 
 
 
 
 
 
 
 
 
 
 # ls wc - name: check files number shell: ls /home/docker/ | wc -l # Python - name: show all python process shell: ps aux | grep python # shell script /tmp/result.log - name: execute run.sh shell: ./run.sh > /tmp/result.log
  72. 72. 72 Play Playbooks
  73. 73. Playbooks Samples • Ansible Role: Install Vim and use vi-mode in everyway 
 - https://github.com/chusiang/vim-and-vi-mode.ansible.role • Ansible Role: PHP 7 (php-fpm) for Nginx on Ubuntu and CentOS
 - https://github.com/chusiang/php7.ansible.role • Ansible Galaxy
 - https://galaxy.ansible.com/ • Code samples from Ansible: Up and Running 
 - https://github.com/ansiblebook/ansiblebook 73
  74. 74. Ⅵ. GitLab 74
  75. 75. Git Repository Docker Registry Issue tracking Code Review CI/CD 75
  76. 76. Ansible Inc. Ecosystems https://www.ansible.com/blog/red-hat-ansible-automation-engine-vs-tower 76
  77. 77. GitLab https://www.ansible.com/blog/red-hat-ansible-automation-engine-vs-tower GITLAB 77 CONTROL KNOWLEDGE
  78. 78. GitLab https://www.ansible.com/blog/red-hat-ansible-automation-engine-vs-tower GITLAB 78 CONTROL KNOWLEDGE GitLab CI, Pipeline
  79. 79. GitLab https://www.ansible.com/blog/red-hat-ansible-automation-engine-vs-tower GITLAB 79 CONTROL KNOWLEDGE GitLab Web, Issue, Wiki
  80. 80. Ⅶ. Pipeline ( ) 80
  81. 81. Ch 5. Ch 6. Ch 7. Ch 8. Ch 9. Ch 10. Pipeline Continuous Delivery - https://goo.gl/r9vXFg 81
  82. 82. binaries binaries UAT binaries binaries binaries Binary binaries metadata binaries metadata binaries binaries metadata metadata Adapted from “Continuous Delivery” © Dave Farley and Jez Humble 2010 Translated by Chu-Siang Lai 2017 82
  83. 83. binaries binaries UAT binaries binaries binaries Binary binaries metadata binaries metadata binaries binaries metadata metadata Adapted from “Continuous Delivery” © Dave Farley and Jez Humble 2010 Translated by Chu-Siang Lai 2017 83
  84. 84. – Chu-Siang Lai Pipeline 84
  85. 85. GitLab Pipelines 85
  86. 86. Ⅷ. GitLab CI .gitlab-ci.yml GitLab GitLab CI 86
  87. 87. • YAML • stage × 1 job × 1 
 
 
 
 
 
 
 
 
 
 
 .gitlab-ci.yml $ vim .gitlab-ci.yml 1 stages: 2 - build 3 4 build_binary: 5 image: ubuntu:16.04 6 stage: build 7 script: 8 - chmod 755 penguin-htdocs/DEBIAN 9 - dpkg -b penguin-htdocs 10 tags: 11 - docker 87
  88. 88. GitLab CI $ git push --> GitLab 88
  89. 89. All Pipelines 89
  90. 90. Pipelines #13803169 90
  91. 91. Job #39892610 91
  92. 92. Ⅸ. Ansible GitLab CI GitLab CI Ansible (Docker Containers) Playbooks 92
  93. 93. Control Machine (Alpine 3.6) + Managed node × 2 (Ubuntu 16.04) GitLab CI Ansible Managed node 93 LAB2 GitLab CI
  94. 94. 
 
 94
  95. 95. Git server GitLab CI server Build Deploy Test Engineer 95 Develop
  96. 96. Customer Git server GitLab CI server Build Deploy Test Release Engineer 96 Master
  97. 97. AnsibleGitLab CIDocker 97
  98. 98. https://hub.docker.com/r/chusiang/ansible/ 0 98
  99. 99. http://s.drx.tw/cd.lab 1 99
  100. 100. Build stage 2 TestDeploy ReleaseBuild 100
  101. 101. Deploy, Test, Release stages 3 DeployBuild Test Release 101
  102. 102. Customer Git server GitLab CI server Build Deploy Test Release Engineer Coding & Git Commit 102
  103. 103. Customer Git server GitLab CI server Build Deploy Test Release Engineer Git Push Coding & Git Commit 103
  104. 104. Customer Git server GitLab CI server Build Deploy Test Release Engineer .gitlab-ci.yml 104
  105. 105. $ vim .gitlab-ci.yml 1 stages: 2 - build 3 - deploy 4 - test 5 - release 6 7 build_binary: 8 image: ubuntu:16.04 9 stage: build 10 script: 11 # For fix bad permissions of control directory on GitLab CI. 12 - chmod 755 penguin-htdocs/DEBIAN 13 14 # build deb. 15 - dpkg -b penguin-htdocs 16 artifacts: 17 expire_in: 1 week 18 paths: 19 - penguin-htdocs.deb 20 tags: 21 - docker 22 4 TestDeploy ReleaseBuild 105
  106. 106. 22 23 deploy_to_dev: 24 image: chusiang/ansible:alpine-3.6 25 stage: deploy 26 script: 27 - ls 28 - cd ansible-playbooks/ 29 - echo "${VAULT_KEY}" > secret.txt 30 - ansible-playbook deploy.yml 31 - rm -f secret.txt 32 only: 33 - master@chusiang/continuous-delivery-workshop 34 - develop@chusiang/continuous-delivery-workshop 35 - tags@chusiang/continuous-delivery-workshop 36 tags: 37 - docker 38 5 TestDeploy ReleaseBuild 106
  107. 107. 38 39 test_dev: 40 image: chusiang/ansible:alpine-3.6 41 stage: test 42 script: 43 - cd ansible-playbooks/ 44 - echo "${VAULT_KEY}" > secret.txt 45 - ansible-playbook test.yml 46 - rm -f secret.txt 47 only: 48 - master@chusiang/continuous-delivery-workshop 49 - develop@chusiang/continuous-delivery-workshop 50 - tags@chusiang/continuous-delivery-workshop 51 tags: 52 - docker 53 6 TestDeploy ReleaseBuild 107
  108. 108. 53 54 release_to_prd: 55 image: chusiang/ansible:alpine-3.6 56 stage: release 57 script: 58 - cd ansible-playbooks/ 59 - echo "${VAULT_KEY}" > secret.txt 60 - ansible-playbook -i production deploy.yml 61 - rm -f secret.txt 62 only: 63 - master@chusiang/continuous-delivery-workshop 64 - tags@chusiang/continuous-delivery-workshop 65 tags: 66 - docker 67 7 TestDeploy ReleaseBuild 108
  109. 109. Customer Git server GitLab CI server Build Deploy Test Release Engineer .gitlab-ci.yml 109
  110. 110. Customer Git server GitLab CI server Build Deploy Test Release Engineer Package deb file 110
  111. 111. Customer Git server GitLab CI server Build Deploy Test Release Engineer Play deploy.yml 111
  112. 112. Customer Git server GitLab CI server Build Deploy Test Release Engineer Play test.yml 112
  113. 113. Customer Git server GitLab CI server Build Deploy Test Release Engineer Play deploy.yml 113
  114. 114. Customer Git server GitLab CI server Build Deploy Test Release Engineer Feedback 114
  115. 115. Customer Git server GitLab CI server Build Deploy Test Release Engineer 115
  116. 116. LAB2 https://gitlab.com Fork http://s.drx.tw/cd.lab 
 $ git clone git@gitlab.com:<USERNAME>/continuous- delivery-workshop.git `penguin-htdocs/var/www/html/index.html` repo MR `chusiang/continuous-delivery-workshop` GitLab Pipeline http://stg.demo.drx.tw:10080 
 http://prd.demo.drx.tw:20080 116
  117. 117. Pipelines 8 117
  118. 118. 118
  119. 119. Control Machine + Managed node × 2 (Ubuntu 16.04 × 3) Ansible Jupyter Managed node 119 LAB1 Jupyer
  120. 120. $ docker pull 
 chusiang/ansible-jupyter:ubuntu-16.04 120
  121. 121. LAB1 Control Machine 
 $ docker run -Pd chusiang/ansible-jupyter:ubuntu-16.04 Managed node × 2 
 $ docker run -Pd 
 chusiang/ansible-managed-node:ubuntu-16.04
 $ docker run -Pd 
 chusiang/ansible-managed-node:ubuntu-16.04 Managed node ssh port 
 $ docker ps
 CONTAINER ID IMAGE ...... STATUS PORTS NAMES 121
  122. 122. LAB1 inventory Ad-hoc commands Playbooks 122
  123. 123. 123 Ansible on Jupyter
  124. 124. Control Machine (Alpine 3.6) + Managed node × 2 (Ubuntu 16.04) GitLab CI Ansible Managed node 124 LAB2 GitLab CI
  125. 125. LAB2 x AWS - https://youtu.be/QHim_JxB4ZY 125
  126. 126. – Chu-Siang Lai 126
  127. 127. Pipeline Unit Test Integration Test Delivery DeploymentBuildSyntax Check Unit Test Delivery DeploymentBuildSyntax Check Unit TestDelivery DeploymentBuildSyntax Check Delivery DeploymentBuildSyntax Check BuildSyntax Check Build 127
  128. 128. DevOps 128
  129. 129. ※ Chen Cheng-Wei Effective DevOps (https://www.slideshare.net/warfan/effective-devops-78979993)
  130. 130. • DevOps by Chen Cheng-Wei - https://goo.gl/7YTeKD • Continuous Delivery - by Miles - https://goo.gl/UhpAfG • Ansible Documentation - http://docs.ansible.com/ansible/intro_installation.html • Ansible: Up and Running - https://www.ansible.com/ansible-book • IT Ansible / 3e - https://goo.gl/vHyVDt • IT Ansible - https://goo.gl/EOjs4I • Getting started with GitLab CI | GitLab Documentation - https://goo.gl/NctsCk • My CD Demo project - http://s.drx.tw/cd.lab 130
  131. 131. • Continuous Delivery | Amazon.com - https://www.amazon.com/dp/0321601912 • Continuous Delivery | - https://goo.gl/SK745B • DevOps Services & Continuous Delivery - https://goo.gl/jswxch • The Phoenix Project | Amazon.com - https://goo.gl/visckK • Resenha: Harry Potter e a Pedra Filosofal, de J.K. Rowling | Acrobata das Letras
 - https://goo.gl/R34tSA • Brown Book Icon | SoftIcons.com - https://goo.gl/U9U2am • Always Agile Consulting · Introducing Continuous Delivery - https://goo.gl/2Nhtcr • 5 CI/CD Strategies for Faster Software Deployments and Better Automation | snap
 - https://goo.gl/UZPf5e 131
  132. 132. https://www.facebook.com/groups/DevOpsTaiwan/ https://devopstw.club/ DevOps Taiwan https://gitter.im/DevOpsTW/ 132
  133. 133. Ansible Taiwan https://telegram.me/ansible_tw https://github.com/ansible-tw http://ansible.tw 133
  134. 134. http:// .tw 134
  135. 135. Q & A 135
  136. 136. END 136

×