Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Chef training Day5

7,301 views

Published on

Presentation for Day5 training held by SmartMe
http://www.smartme.com.ua/courses/nachala-devops-konfiguriruem-server-s-pomoshchyu-opscode-chef

Published in: Technology, Self Improvement
  • Be the first to comment

Chef training Day5

  1. 1. Начала DevOps: Opscode Chef Day 5 Andriy Samilyak samilyak@gmail.com skype: samilyaka
  2. 2. Goals ● Knife plugins ● Chef with Windows ● Amazon OpsWorks ● Final practice – LARGE one
  3. 3. Plugins ● Custom set of knife commands ● Usually in CHEF_REPO/.chef/plugins/knife/
  4. 4. [Maybe] Useful knife plugins ● Knife-flip → moving nodes in environment ● Knife-spork → another workflow ● Knife-preflight → check nodes with cookbook ● Knife-ec2 → Amazon EC2 management ● Knife-sshx → easy ssh login
  5. 5. Chef on Windows ● /opt/chef/embedded/bin/gem install knife-windows > knife winrm > knife bootstrap windows http://community.opscode.com/cookbooks/iis http://community.opscode.com/cookbooks/sql_server
  6. 6. Windows ACL directory 'C:mordor' do rights :read, 'MORDORMinions' rights :full_control, 'MORDORSauron' end
  7. 7. Amazon OpsWorks
  8. 8. Final practice - Dokuwiki ● Ubuntu official package is toooo old (2012) ● We need to install it from source https://www.dokuwiki.org/install http://download.dokuwiki.org/ ● We'll create new role, new cookbook, new server
  9. 9. Dokuwiki - 1 ● Download tarball What resource should we use?
  10. 10. Downloading tarball cookbooks/dokuwiki/recipes/default.rb src_file= "http://download.dokuwiki.org/out/dokuwikide06047915ab0d0e8c04d093b4e15099.tgz" tgt_file = "#{Chef::Config[:file_cache_path]}/dokuwiki.tar.gz" remote_file tgt_file do source src_file mode 0644 action :create_if_missing backup false end
  11. 11. Dokuwiki - 2 ● Extract tarball tar -xf dokuwiki.tar.gz -C /var/www What resource should we use?
  12. 12. Extracting tarball cookbooks/dokuwiki/recipes/default.rb bash "extract_dokuwiki" do code <<-EOH tar -xf #{tgt_file} -C /var/www EOH end
  13. 13. Notifications remote_file "somefile" do source "http://somelink.tgz" mode "0644" action :create_if_missing backup false notifies :run, "bash[extract_dokuwiki]", :immediately end bash "extract_dokuwiki" do action :nothing code "tar -xf dokuwiki.tar.gz -C /var/www" end
  14. 14. Dokuwiki - 3 ● Enable Apache default site through attributes/default.rb
  15. 15. Enable default Apache site dokuwiki/attributes/default.rb default['apache']['default_site_enabled'] = true default['apache']['docroot_dir'] = “/var/www/dokuwiki”
  16. 16. Dokuwiki - 4 ● Install PHP ● Install package libapache2-mod-php
  17. 17. Install PHP cookbooks/dokuwiki/recipes/default.rb include_recipe "apache2" include_recipe "php" include_recipe "apache2::mod_php5" NB! Use Community cookbook 'PHP' (metadata.rb)
  18. 18. File permissions ● Try running http://yoursite/install.php We have file permissions problem ● We need to set up: chmod -R 775 /var/www/dokuwiki/data chown -R www-data /var/www/dokuwiki/data chmod -R 775 /var/www/dokuwiki/conf chown -R www-data /var/www/dokuwiki/conf copy/paste from http://goo.gl/6sEYT5
  19. 19. File permissions cookbooks/dokuwiki/recipes/default.rb bash "set_permissions" do code <<-EOH chmod -R 775 #{node['apache']['docroot_dir']}/data chown -R www-data #{node['apache']['docroot_dir']}/data chmod -R 775 #{node['apache']['docroot_dir']}/conf chown -R www-data #{node['apache']['docroot_dir']}/conf EOH end Now you can run install.php!
  20. 20. Dokuwiki - 5 ● Save installer-created files in cookbook /var/www/dokuwiki/conf/acl.auth.php /var/www/dokuwiki/conf/local.php /var/www/dokuwiki/conf/plugins.local.php /var/www/dokuwiki/conf/users.auth.php What resource should we use?
  21. 21. Copy files in bulk cookbooks/dokuwiki/recipes/default.rb remote_directory "#{node['apache']['docroot_dir']}/dokuwiki/conf" do files_mode 0422 files_backup false end
  22. 22. Dokuwiki - 6 ● Remove install.php What resource should we use?
  23. 23. Removing file cookbooks/dokuwiki/recipes/default.rb file "#{node['apache']['docroot_dir']}/dokuwiki/install.php" do action :delete end
  24. 24. Dokuwiki – 7 ● Security measures, apply virtualhost as described in https://www.dokuwiki.org/security
  25. 25. Party time?

×