SlideShare una empresa de Scribd logo
1 de 29
Descargar para leer sin conexión
Deploy Drupal with
   Capistrano
      a year later
“A life without philosophy
Capistrano is not worth living”
            --Socrates
“A life without philosophy
Capistrano is not worth living”
            --Socrates


 “Drupal is worth the PHPain”
     --Anonymous from Bari
The Actors
Our friend
Our friend

 Kick Ass CMS
Our friend

     Kick Ass CMS




Isn’t very deploy friendly
Our friend

     Kick Ass CMS




Isn’t very deploy friendly
 and needs some help...
His friend

 Kick Ass CMS
His friend

 Kick Ass CMS




 The logo sucks
His friend

         Kick Ass CMS




           The logo sucks
but it will help your deployments!
The Target
$ cap intinig production deploy
capistrano


   $ cap intinig production deploy
capistrano


   $ cap intinig production deploy
             developer
capistrano               stage


   $ cap intinig production deploy
             developer
capistrano               stage


   $ cap intinig production deploy
             developer           command
The Code
Capfile
                   where the fun starts
load 'deploy' if respond_to?(:namespace) # cap2 differentiator

load   'includes/recipes/stages'
load   'includes/recipes/mikamai'
load   'includes/recipes/drupal'
load   'includes/recipes/overrides'
load   'includes/recipes/devs'

# SCM Stuff configure to taste, just remember the repository
set :repository, "git@github.com:mikamai/app.git"
set :scm, :git
set :branch, "master"
set :repository_cache, "git_master"
set :deploy_via, :remote_cache
set :scm_verbose, true
set :keep_releases, 3
includes/recipes
where we put the “Good Stuff”™
devs.rb
           let’s tell capistrano about ourselves

task :intinig do
 set :local_mysqldump, "/usr/local/mysql/bin/mysqldump"
 set :local_db_user, "root"
 set :local_db_password, "youwishItoldyou"
 set :local_db_name, "app_db"
end

task :paolo do
 set :local_mysqldump, "/Applications/MAMP/Library/bin/mysqldump"
 set :local_db_user, "root"
 set :local_db_password, "paolo"
 set :local_db_name, "stefano"
end
drupal.rb
change capistrano default behavior
 load File.dirname(__FILE__) + '/drupal/db'
 load File.dirname(__FILE__) + '/drupal/configure'

 after 'deploy:setup', 'drupal:setup'
 after 'deploy:symlink', 'drupal:symlink'
 before 'deploy:start', 'drupal:db:import:production'

 before 'deploy:restart', 'drupal:configure:stage'
 before 'deploy:start', 'drupal:configure:stage'

 namespace :drupal do
  task :setup, :except => { :no_release => true } do
   sudo "mkdir -p #{shared_path}/files"
   sudo "chmod a+w #{shared_path}/files"

   sudo "mkdir -p #{shared_path}/dumps"

   sudo "chown -R #{user}:#{user} #{deploy_to}"
  end

  task :symlink, :except => { :no_release => true } do
   sudo "ln -s #{shared_path}/files #{latest_release}"
  end
 end
drupal/configure.rb
                    a small hack for multiple stages
namespace :drupal do
 namespace :configure do
  task :stage do
    source = "#{latest_release}/sites/default/settings.#{stage_name}.php"
    dest = "#{latest_release}/sites/default/settings.php"
    sudo "cp #{source} #{dest}"
  end
 end
end
drupal/db.rb
                                       mysql grinding
namespace :local do
 desc "Dumps the local database"
 task :default, :roles => :db do
  raise RuntimeError.new("failed dump") unless system "#{local_mysqldump} -u #{local_db_user} --
password=#{local_db_password} #{local_db_name} > dump.local.sql"
 end

 namespace :upload do
  desc "Dumps and uploads the local database"
  task :default do
    drupal::db::dump::local::default
    put(File.read("dump.local.sql"), "#{shared_path}/dumps/dump.local.sql")
    run "mysql -u #{db_user} --password=#{db_password} #{db_name} < #{shared_path}/dumps/
dump.local.sql"
  end
 end
end
drupal/db.rb
                                     mysql grinding / 2
namespace :remote do
 desc "Dumps the remote database"
 task :default, :roles => :db do
  filename = "#{Time.now.to_i.to_s}.dump.sql"
  run "cd #{shared_path}/dumps; #{remote_mysqldump} -u #{db_user} --password=#{db_password}
#{db_name} > #{filename}"
  run "cd #{shared_path}/dumps; bzip2 #{filename}"
 end

 namespace :download do
  desc "Dumps and downloads the remote database"
  task :default do
   drupal::db::dump::remote::default
   latest
  end

  desc "Downloads the latest database dump"
  task :latest, :roles => :db do
    dumps = capture("ls -xt #{shared_path}/dumps").split.reverse
    get("#{shared_path}/dumps/#{dumps.last}", "./#{dumps.last}")
  end
 end
end
mikamai.rb
             fix problems on our servers
before 'deploy:restart', 'mikamai:permissions:fix'
before 'deploy:start', 'mikamai:permissions:fix'

namespace :mikamai do

 namespace :production do
  task :symlink, :except => { :no_release => true } do
   sudo "rm -rf /var/www/#{application}"
   sudo "ln -s #{latest_release} /var/www/#{application}"
  end
 end

 namespace :permissions do
  task :fix, :except => { :no_release => true } do
   sudo "chown -R www-data:www-data #{latest_release}"
  end
 end

end
overrides.rb
                      do as we say not as we do
namespace :deploy do
 task :finalize_update, :except => { :no_release => true } do
  sudo "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
 end

 task :cold do
  update
  start
 end

 task :restart do
 end

 task :start do
 end
end
stages.rb
                    one for everyone
set :application, "cool_app"

desc "deploy to development environment"
task :development do
 set :stage_name, "development"

 role :web, "danton.mikamai.com:8888", :primary => true
 role :db, "danton.mikamai.com:8888", :primary => true
 set :user, "drupal"
 set :password, "secret"
 set :remote_mysqldump, "/usr/bin/mysqldump"
 set :deploy_to, "/var/apps/#{application}"
 set :db_user, "dbuser"
 set :db_password, "supersecret"
 set :db_name, "appname"
end
Questions?
Giovanni Intini <giovanni@mikamai.com>

Más contenido relacionado

Último

React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 

Último (20)

React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 

Destacado

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 

Destacado (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

Deploy Drupal With Capistrano A Year Later

  • 1. Deploy Drupal with Capistrano a year later
  • 2. “A life without philosophy Capistrano is not worth living” --Socrates
  • 3. “A life without philosophy Capistrano is not worth living” --Socrates “Drupal is worth the PHPain” --Anonymous from Bari
  • 6. Our friend Kick Ass CMS
  • 7. Our friend Kick Ass CMS Isn’t very deploy friendly
  • 8. Our friend Kick Ass CMS Isn’t very deploy friendly and needs some help...
  • 9. His friend Kick Ass CMS
  • 10. His friend Kick Ass CMS The logo sucks
  • 11. His friend Kick Ass CMS The logo sucks but it will help your deployments!
  • 13. $ cap intinig production deploy
  • 14. capistrano $ cap intinig production deploy
  • 15. capistrano $ cap intinig production deploy developer
  • 16. capistrano stage $ cap intinig production deploy developer
  • 17. capistrano stage $ cap intinig production deploy developer command
  • 19. Capfile where the fun starts load 'deploy' if respond_to?(:namespace) # cap2 differentiator load 'includes/recipes/stages' load 'includes/recipes/mikamai' load 'includes/recipes/drupal' load 'includes/recipes/overrides' load 'includes/recipes/devs' # SCM Stuff configure to taste, just remember the repository set :repository, "git@github.com:mikamai/app.git" set :scm, :git set :branch, "master" set :repository_cache, "git_master" set :deploy_via, :remote_cache set :scm_verbose, true set :keep_releases, 3
  • 20. includes/recipes where we put the “Good Stuff”™
  • 21. devs.rb let’s tell capistrano about ourselves task :intinig do set :local_mysqldump, "/usr/local/mysql/bin/mysqldump" set :local_db_user, "root" set :local_db_password, "youwishItoldyou" set :local_db_name, "app_db" end task :paolo do set :local_mysqldump, "/Applications/MAMP/Library/bin/mysqldump" set :local_db_user, "root" set :local_db_password, "paolo" set :local_db_name, "stefano" end
  • 22. drupal.rb change capistrano default behavior load File.dirname(__FILE__) + '/drupal/db' load File.dirname(__FILE__) + '/drupal/configure' after 'deploy:setup', 'drupal:setup' after 'deploy:symlink', 'drupal:symlink' before 'deploy:start', 'drupal:db:import:production' before 'deploy:restart', 'drupal:configure:stage' before 'deploy:start', 'drupal:configure:stage' namespace :drupal do task :setup, :except => { :no_release => true } do sudo "mkdir -p #{shared_path}/files" sudo "chmod a+w #{shared_path}/files" sudo "mkdir -p #{shared_path}/dumps" sudo "chown -R #{user}:#{user} #{deploy_to}" end task :symlink, :except => { :no_release => true } do sudo "ln -s #{shared_path}/files #{latest_release}" end end
  • 23. drupal/configure.rb a small hack for multiple stages namespace :drupal do namespace :configure do task :stage do source = "#{latest_release}/sites/default/settings.#{stage_name}.php" dest = "#{latest_release}/sites/default/settings.php" sudo "cp #{source} #{dest}" end end end
  • 24. drupal/db.rb mysql grinding namespace :local do desc "Dumps the local database" task :default, :roles => :db do raise RuntimeError.new("failed dump") unless system "#{local_mysqldump} -u #{local_db_user} -- password=#{local_db_password} #{local_db_name} > dump.local.sql" end namespace :upload do desc "Dumps and uploads the local database" task :default do drupal::db::dump::local::default put(File.read("dump.local.sql"), "#{shared_path}/dumps/dump.local.sql") run "mysql -u #{db_user} --password=#{db_password} #{db_name} < #{shared_path}/dumps/ dump.local.sql" end end end
  • 25. drupal/db.rb mysql grinding / 2 namespace :remote do desc "Dumps the remote database" task :default, :roles => :db do filename = "#{Time.now.to_i.to_s}.dump.sql" run "cd #{shared_path}/dumps; #{remote_mysqldump} -u #{db_user} --password=#{db_password} #{db_name} > #{filename}" run "cd #{shared_path}/dumps; bzip2 #{filename}" end namespace :download do desc "Dumps and downloads the remote database" task :default do drupal::db::dump::remote::default latest end desc "Downloads the latest database dump" task :latest, :roles => :db do dumps = capture("ls -xt #{shared_path}/dumps").split.reverse get("#{shared_path}/dumps/#{dumps.last}", "./#{dumps.last}") end end end
  • 26. mikamai.rb fix problems on our servers before 'deploy:restart', 'mikamai:permissions:fix' before 'deploy:start', 'mikamai:permissions:fix' namespace :mikamai do namespace :production do task :symlink, :except => { :no_release => true } do sudo "rm -rf /var/www/#{application}" sudo "ln -s #{latest_release} /var/www/#{application}" end end namespace :permissions do task :fix, :except => { :no_release => true } do sudo "chown -R www-data:www-data #{latest_release}" end end end
  • 27. overrides.rb do as we say not as we do namespace :deploy do task :finalize_update, :except => { :no_release => true } do sudo "chmod -R g+w #{latest_release}" if fetch(:group_writable, true) end task :cold do update start end task :restart do end task :start do end end
  • 28. stages.rb one for everyone set :application, "cool_app" desc "deploy to development environment" task :development do set :stage_name, "development" role :web, "danton.mikamai.com:8888", :primary => true role :db, "danton.mikamai.com:8888", :primary => true set :user, "drupal" set :password, "secret" set :remote_mysqldump, "/usr/bin/mysqldump" set :deploy_to, "/var/apps/#{application}" set :db_user, "dbuser" set :db_password, "supersecret" set :db_name, "appname" end