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.

DevOpsDaysRiga 2017: Dmitry Buzdin - Delivery Pipeline for Windows Machines

105 views

Published on

Have you ever wondered how to set-up a working continuous delivery pipeline for applications on Windows and open source tools only? Lets see how tools like Jenkins, Artifactory, PowerShell, Ansible, NSSS and Installer Generators could be used to do that.

Continuous Delivery Pipeline creation for Linux is boring because it is so simple. All tools and approaches are well-known. However, if you are in Windows-land and do not want to pay for licensing cost of enterprise tools, achieving pipeline automation for Windows might be tricky. This talk will give an explanation of a sample CD pipeline using Windows/Cloud/Ansible and other tools. All examples will be shown on Google Cloud-based Windows VMs.

Published in: Internet
  • Be the first to comment

  • Be the first to like this

DevOpsDaysRiga 2017: Dmitry Buzdin - Delivery Pipeline for Windows Machines

  1. 1. Delivery Pipeline for Windows Machines 18.09.2017 @buzdin for fun and profit
  2. 2. Working as a consultant • DevOps • Test Automation • Software Architecture (aka Microservices) • Java Development • Web Development (not JavaScript)
  3. 3. Continuous Delivery Getting a code change to production in a most efficient way (preferably automated)
  4. 4. Lets build a delivery pipeline!
  5. 5. https://xebialabs.com/periodic-table-of-devops-tools/
  6. 6. Jenkins Pipeline Git checkout Gradle build Run Integ Tests Publish to Nexus Deploy to Dev Run Func Tests Push to Release Deploy to Staging
  7. 7. Steps to Deploy • Generate SSH Certificate • Provision Linux via Ansible • Install dependencies via apt-get • Download artefact from Artifactory via curl • Start app as a service using systemd • Think about switching to Docker later
  8. 8. Things to Consider • Clustering – round-robin or hash-based? • Blue-green deployment strategy? • Should we take Kubernetes or simply Docker Swarm? VS
  9. 9. Mission Impossible 1. Don’t spend any money on licenses 2. Automate using familiar tools 3. You have a Mac 4. Don’t think about Docker all the time
  10. 10. Step #1 Where to get a Windows VM?
  11. 11. Create Compute Instance
  12. 12. Create Account
  13. 13. Connect with RDP
  14. 14. Linux Windows ansible ? ssh ? apt-get ? systemd ? docker ?
  15. 15. Ansible Core Concepts • Works on SSH and Python • Tasks (what to do) • Playbook (aggregations of tasks) • Inventory files (where to connect) • Lots of configs, modules and plugins • All written in YAML https://www.ansible.com/
  16. 16. http://docs.ansible.com/ansible/list_of_windows_modules.html
  17. 17. Ansible Win Tasks win_file win_copy win_service win_uri win_get tasks: - name: Create a directory win_file: path: “C:Applogs“ state: directory Useful commands:
  18. 18. Getting There From MacOS $ pip install ansible $ pip install "pywinrm>=0.2.2"
  19. 19. Windows Remote Management Protocol https://msdn.microsoft.com/en-us/library/aa384426(v=vs.85).aspx “Windows Remote Management (WinRM) is the Microsoft implementation of WS-Management Protocol, a standard Simple Object Access Protocol (SOAP)-based, firewall-friendly protocol that allows hardware and operating systems, from different vendors, to interoperate.”
  20. 20. Linux Windows ansible ansible ssh ? apt-get ? systemd ? docker ?
  21. 21. PowerShell https://msdn.microsoft.com/powershell
  22. 22. PowerShell
  23. 23. PowerShell Curl https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Utility/Invoke-RestMethod?view=powershell-5.1 > Invoke-WebRequest -Uri http://my.artifactory/repo/artifact -OutFile app.jar $ curl http://my.artifactory/repo/artifact --output app.jar
  24. 24. PowerShell Remoting > Enable-PSRemoting –force > Enter-PSSession -ComputerName 127.0.0.1 -Credential User $ ssh user@127.0.0.1
  25. 25. Enable Ansible Remoting
  26. 26. Add Firewall Rule
  27. 27. Success!
  28. 28. PowerShell on MacOS https://github.com/PowerShell/PowerShell/ Works on MacOS 10.12 Sierra built on .NET Core
  29. 29. Linux Windows ansible ansible ssh PowerShell apt-get ? systemd ? docker ?
  30. 30. $ sudo apt-get install java VS
  31. 31. Chocolatey https://chocolatey.org/
  32. 32. Install Package with Chocolatey > Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser > choco install jdk8 -y -params 'installdir=c:java8' > Set-ExecutionPolicy AllSigned; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/ install.ps1'))
  33. 33. Ansible Support tasks: - name: Install Java win_chocolatey: name: jdk8 state: present params: "installdir=c:java8"
  34. 34. Linux Windows ansible ansible ssh PowerShell apt-get Chocolatey systemd ? docker ?
  35. 35. $ sudo systemctl restart apache2.service VS
  36. 36. Non-Sucking Service Manager https://nssm.cc/ “nssm is a service helper which doesn't suck.”
  37. 37. NSSM Usage
  38. 38. Ansible Support tasks: win_nssm: name: “my_service" application: “c:java8binjavaw.exe” start_mode: manual state: started stdout_file: "{{logs_path}}stdout.log" stderr_file: "{{logs_path}}stderr.log" app_parameters_free_form: “{{java_opts}}"
  39. 39. DEMO TIME
  40. 40. Linux Windows ansible ansible ssh PowerShell apt-get Chocolatey systemd NSSM docker ?
  41. 41. https://www.brianchristner.io/docker-image-base-os-size-comparison/ ??? windowsservercore:latest 9426 mb Layers: ??? ~2000x
  42. 42. Nice to Know • Possible to install Docker on Windows • Not possible to run Windows containers and Linux containers at the same time
  43. 43. Linux Windows ansible ansible ssh PowerShell apt-get Chocolatey systemd NSSM docker WAT?
  44. 44. What have we learned today?
  45. 45. Same Tools, Patterns & Practices Apply
  46. 46. https://octoverse.github.com/
  47. 47. Microsoft DevOps sort of…
  48. 48. https://github.com/buzdin/ansible-winows-gcloud

×