Professional Documents
Culture Documents
Continuous Deployment With Jenkins and Salt PDF
Continuous Deployment With Jenkins and Salt PDF
• Simple
• Stable
• Fast (good to have…)
• Reliable
• One click
Problems faced
• Code distribution
• Additional tasks (commands, migrations)
• Latency
• Parallel execution
• Batch deployments
• Ensuring uptime
Methods available
Deployment
Packages:
Code storage:
• GIT repositories:
• Usually centrally located, latency when deployed from GIT
• Package repositories (RPM/DEB):
• Problems in simultaneously updating repo metadata
Rollback:
• Version manipulation is a problem with most configuration
management and remote execution tools
Salt
Provides…
• By hostname
• ‘myappweb*’
• By specific grains
• -G ‘node_type:webserver’
• By nodegroups
• -N webgroup
Salt features
Task dependencies :
get_archive:
module.run:
.
.
deploy_app:
module.run:
.
.
- require:
- module: get_archive
Salt features
Orchestration :
webgrp2_deploy:
salt.state:
- tgt: ' webgrp2'
- tgt_type: nodegroup
- sls:
- webserver.deploy
- require:
- salt: webgrp1_deploy
webgrp1_deploy:
salt.state:
- tgt: 'webgrp1'
- tgt_type: nodegroup
- sls:
- webserver.deploy
Salt features
Batch Execution :
• By number of hosts
• --batch-size 5
• Executes on 5 hosts at a time
• By percentage of hosts
• --batch-size 25%
• Executes on 25% of total target
hosts at a time
Salt features
Salt API:
# curl -H "Accept: application/json"
-d secretkey= "mysupersecretkey"
-k https://10.0.0.2:8080/hook/deploy
{"success": true}
Tools
To be used…
• The node is registered and deregistered from the load balancer with the
following module definition,
register:
module.run:
- name: boto_elb.register_instances
- m_name: mywebapp
- instances:
- {{ grains['ec2']['instance_id'] }}
fetch_app_archive:
module.run:
- name: s3.get
- bucket: mywebapp-us
- path: mywebapp-{{ app_version }}.tar
- local_file: /tmp/mywebapp-{{ app_version }}.tar
Steps explained
Setting App version grain:
app_version:
grains.present:
- value: {{ app_version }}
- require:
- cmd: deploy_app
Steps explained
Deployment based on App version:
{% if grains['app_version'] != app_version %}
deregister:
fetch_app_archive:
deploy_app:
register:
{% endif %}
Lets do it then !!!
Demo repository
Get the demo repository at the
following location,
https://github.com/rosesnthornz/
cloudopen-na-2015
Questions ?
Contact
Email :
sahaanirban1988@gmail.com
Twitter : @rosesnthornz
Thank You !!!