{"id":14062999,"url":"https://github.com/jonashackt/ansible-windows-springboot","last_synced_at":"2025-03-19T01:30:55.128Z","repository":{"id":147269184,"uuid":"75939832","full_name":"jonashackt/ansible-windows-springboot","owner":"jonashackt","description":"Example project showing how to provision, deploy and run a Spring Boot app as a Windows Service using Ansible, chocolatey \u0026 nssm","archived":false,"fork":false,"pushed_at":"2018-03-02T12:01:13.000Z","size":25,"stargazers_count":9,"open_issues_count":0,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-28T13:46:46.333Z","etag":null,"topics":["ansible","chocolatey","devops","java","nssm","spring-boot","vagrant","windows"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonashackt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-12-08T13:23:55.000Z","updated_at":"2025-02-03T17:11:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"2c26d372-97ed-4a8c-b44e-5f6ea119a23f","html_url":"https://github.com/jonashackt/ansible-windows-springboot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fansible-windows-springboot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fansible-windows-springboot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fansible-windows-springboot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fansible-windows-springboot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonashackt","download_url":"https://codeload.github.com/jonashackt/ansible-windows-springboot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243958073,"owners_count":20374789,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","chocolatey","devops","java","nssm","spring-boot","vagrant","windows"],"created_at":"2024-08-13T07:02:58.136Z","updated_at":"2025-03-19T01:30:54.884Z","avatar_url":"https://github.com/jonashackt.png","language":null,"readme":"ansible-windows-springboot\n======================================================================================\n[![Build Status](https://travis-ci.org/jonashackt/ansible-windows-springboot.svg?branch=master)](https://travis-ci.org/jonashackt/ansible-windows-springboot)\n[![Ansible Galaxy](https://img.shields.io/badge/galaxy-jonashackt-660198.svg)](https://galaxy.ansible.com/jonashackt)\n\n## Example ansible playbook - showing how to provision, deploy and run a Spring Boot app as a Windows Service using Ansible, chocolatey \u0026amp; nssm\n\nThere´s a blog post with more background information here: [Running Spring Boot Apps on Windows with Ansible (codecentric.de)](https://blog.codecentric.de/en/2017/01/ansible-windows-spring-boot/)\n\n\u003e Isn´t Ansible SSH-only?\n\nFrom Version 1.7 on, Ansible also supports managing Windows machines. This is done with native PowerShell remoting (and Windows Remote Management [WinRM](https://technet.microsoft.com/en-us/library/ff700227.aspx)) instead of SSH, as you can [read in the docs](http://docs.ansible.com/ansible/intro_windows.html).\n\n\n## Prerequisites\n\nGo to https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/#downloads and download an Vagrant image with Windows 10 (e.g. for VirtualBox - be sure to have the VM-Provider installed). You should get something like a MSEdge.Win10_RS1.Vagrant.zip - extract it (Mac: with the [Unarchiver](http://wakaba.c3.cx/s/apps/unarchiver.html)) and there you are: The Windows Vagrant box __dev-msedge.box__ is ready :)\n\nBecause Microsoft doesn´t seem to ship metadata for the box, add it to Vagrant via:\n\n```\nvagrant box add dev-msedge.box --name \"windows10\"\n```\n\nI added a Vagrantfile to this repository, so you can start right away by (if you have Vagrant installed ;) )\n```\nvagrant up\n```\n\nBecause we use Windows, SSH for example will not work and we need to tweak some Vagrant Configuration Options described here: https://www.vagrantup.com/docs/vagrantfile/winrm_settings.html\n\n\n## Prepare the Windows Box for Ansible Communication\n\nDoku: http://docs.ansible.com/ansible/intro_windows.html#windows-system-prep\n\n### prepare the Windows box\n\n\u003e If you have Windows \u003e= v10, just skip the follwing steps \u0026 proceed with [Configure remote access for ansible](https://github.com/jonashackt/ansible-windows-springboot#configure-remote-access-for-ansible)\n\n#### Allow execution of scripts on Powershell:\n```\nSet-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser\n```\n\n#### Upgrade to Powershell 3.0\n\nIf __get-host__ shows something \u003c 3.0, you should upgrade with https://github.com/cchurch/ansible/blob/devel/examples/scripts/upgrade_to_ps3.ps1 (this will [reboot your Windows box!](http://serverfault.com/questions/539229/possible-to-upgrade-powershell-2-0-to-3-0-without-a-reboot) )\n\n#### Configure remote access for ansible\n\nOn a Powershell with Admin rights, run:\n```\niwr https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 -UseBasicParsing | iex\n```\n\n(or if that doesn´t work (e.g., if your Powershell Version does not know __iwr__), download the Script https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 and run it manually from Powershell).\n\n\n#### Testdrive Ansible connectivity\n```\nansible restexample-windows-dev -i hostsfile -m win_ping\n```\n\nIf this brings you something like the following output, __your Windows Box is ready for Ansible!__:\n```\n127.0.0.1 | SUCCESS =\u003e {\n    \"changed\": false, \n    \"ping\": \"pong\"\n}\n```\n\nIf you have something like\n```\n127.0.0.1 | UNREACHABLE! =\u003e {\n    \"changed\": false, \n    \"msg\": \"ssl: the specified credentials were rejected by the server\", \n    \"unreachable\": true\n}\n```\nthen your UserName or Password is not correct - and trust me, double or tripple check this before moving to the next point :)\n\nIf you get a read time out, your Windows Box is most likely not configured correctly:\n```\n127.0.0.1 | UNREACHABLE! =\u003e {\n    \"changed\": false, \n    \"msg\": \"ssl: HTTPSConnectionPool(host='127.0.0.1', port=55986): Read timed out. (read timeout=30)\", \n    \"unreachable\": true\n}\n```\ncheck, if you already successfully ran [Configure remote access for ansible](https://github.com/jonashackt/ansible-windows-springboot#configure-remote-access-for-ansible)\n\n\n\n\n## Choose an Spring Boot app to deploy\n\nJust take the simple project here: https://github.com/jonashackt/restexamples\n\nEither way you choose: Be sure to have a working Build in Place, so that you have a runnable Spring Boot jar-File in place (e.g. restexamples-0.0.1-SNAPSHOT.jar). For the example project [restexamples](https://github.com/jonashackt/restexamples) you get this by running:\n```\nmvn clean package\n```\n\n\n## Craft a Windows-ready ansible playbook\n\nI did that step already for you :) So let´s run our the playbook restexample-windows.yml:\n\n```\nansible-playbook -i hostsfile restexample-windows.yml --extra-vars \"spring_boot_app_jar=../restexamples/target/restexamples-0.0.1-SNAPSHOT.jar spring_boot_app_name=restexample-springboot host=restexample-windows-dev\"\n```\n\n\n\n## Best practices\n\n* __ALWAYS__: escape \\ in paths with \"\\\" --\u003e e.g. C:\\\\\\temp\n* don´t assume that a path with C:\\ProgamFiles (x86)\\XYZ will work (e.g. for Java better use \"C:\\\\\\ProgramData\\\\\\Oracle\\\\\\Java\\\\\\javapath\\\\\\java.exe\")\n* if chocolatey doesn´t want to work, you have to install it once manually on your Windows box\n```\niwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex\n```","funding_links":[],"categories":["Others"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonashackt%2Fansible-windows-springboot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonashackt%2Fansible-windows-springboot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonashackt%2Fansible-windows-springboot/lists"}