devops:vagrant
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| devops:vagrant [2020/02/11 15:47] – skipidar | devops:vagrant [2024/06/22 16:41] (current) – [Error: Authentication failure. Retrying...] skipidar | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| By Hashicorp. | By Hashicorp. | ||
| - | == WOrkflow | + | == Workflow |
| {{http:// | {{http:// | ||
| Line 237: | Line 237: | ||
| vagrant install plugin vagrant-proxy | vagrant install plugin vagrant-proxy | ||
| </ | </ | ||
| + | |||
| + | |||
| + | |||
| + | ===== SSH Tunneling from Vagrant to host ====== | ||
| + | |||
| + | |||
| + | you can create a tunnel exposing it on the host machine | ||
| + | |||
| + | First forward the ports on Vagrant to Host. | ||
| + | This makes the guest-port of vm 4440 | ||
| + | available on host port 4440 | ||
| + | < | ||
| + | |||
| + | # forwarding ports | ||
| + | config.vm.network " | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | Then establish a tunnel. | ||
| + | Establishing a tunnel from port 4440 on guest vm | ||
| + | to remote machine i-012412412ASF2. | ||
| + | |||
| + | <color # | ||
| + | so that the ssh tunnel gets exposed on all network adapters, not only localhost | ||
| + | and so can be reached from host</ | ||
| + | |||
| + | < | ||
| + | ssh ec2-user@i-012412412ASF2 -i ~/ | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | {{https:// | ||
| + | |||
| + | Now you can reach your rundeck application on host under: | ||
| + | **localhost: | ||
| + | |||
| + | which redirects to guest-vm port: | ||
| + | **localhost: | ||
| + | |||
| + | which redirects, via the ssh-tunnel to remote server i-012412412ASF2: | ||
| + | **i-012412412ASF2: | ||
| + | |||
| + | |||
| + | |||
| + | In this example the session-manager is involved to create the tunnel, this part is optional | ||
| + | see https:// | ||
| + | |||
| + | |||
| + | |||
| + | ===== Setting up Rsync folder-synch on Windows ===== | ||
| + | |||
| + | === Why === | ||
| + | When **developing code** in an **IDE on Windows-Host** \\ | ||
| + | I would like to have the possibility | ||
| + | of running code in the Guest-VM. In an environment as close to the deployment as possible: \\ | ||
| + | e.g. on Kubernetes, integrated with other containers. | ||
| + | |||
| + | **File-system watcher:** | ||
| + | |||
| + | Requirement: | ||
| + | |||
| + | On the Guest - the changes of " | ||
| + | and the code-project rebuilt. \\ | ||
| + | |||
| + | Also changes in the **IDE on Windows-Host** \\ | ||
| + | must trigger changes on the file-system in " | ||
| + | |||
| + | Problem: | ||
| + | |||
| + | When sharing a code-project via **Oracle-Virtualbox shared-folders** \\ | ||
| + | and files where changed on **IDE on Windows-Host** \\ | ||
| + | unfortunately, | ||
| + | |||
| + | When sharing a code-project via **Rsync** | ||
| + | |||
| + | |||
| + | === How === | ||
| + | An example of setting up the environment | ||
| + | |||
| + | * On Guest. Install Cygwin, to get Rsync on Windows | ||
| + | * On Guest. Add the " | ||
| + | * | ||
| + | * On Guest. Run automatic sync command in one cmd-shell | ||
| + | * Ssh into Vagrant. Run continuos build in one shell | ||
| + | * | ||
| + | * Ssh into Vagrant. Run application like Spring Boot application | ||
| + | |||
| + | |||
| + | == On Guest. Install Cygwin, to get Rsync on Windows == | ||
| + | |||
| + | < | ||
| + | winget install -e --id Cygwin.Cygwin | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==On Guest. Add the " | ||
| + | |||
| + | < | ||
| + | cd " | ||
| + | mkdir " | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==Configure Vagrantfile to sync " | ||
| + | Sync folder `spring-boot-code-project-folder`. | ||
| + | Based on `checksum`, not timestamp. | ||
| + | |||
| + | Vagrantfile | ||
| + | <sxh ruby> | ||
| + | ... | ||
| + | config.vm.synced_folder " | ||
| + | type: " | ||
| + | rsync__auto: | ||
| + | rsync__args: | ||
| + | id: " | ||
| + | |||
| + | .. | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==On Guest. Run automatic sync command in one cmd-shell== | ||
| + | |||
| + | Open a new [[https:// | ||
| + | <sxh shell> | ||
| + | vagrant rsync-auto | ||
| + | </ | ||
| + | |||
| + | {{https:// | ||
| + | |||
| + | |||
| + | ==Ssh into Vagrant. Run continuos build in one shell== | ||
| + | |||
| + | See https:// | ||
| + | |||
| + | Skip the tests.\\ | ||
| + | Dont use the daemon. | ||
| + | |||
| + | <sxh shell> | ||
| + | vagrant ssh | ||
| + | cd "/ | ||
| + | ./gradlew build -xtest --no-daemon --continuous | ||
| + | </ | ||
| + | |||
| + | |||
| + | == Configure the Spring Boot application to hot-deploy changes == | ||
| + | |||
| + | The Spring boot applications needs to be advised, \\ | ||
| + | to take up any rebuilt app and hot-deploy it. | ||
| + | |||
| + | Add dependency to " | ||
| + | |||
| + | build.gradle | ||
| + | <sxh> | ||
| + | dependencies { | ||
| + | |||
| + | // makes Spring boot hot swap rebuilt jar to tomcat | ||
| + | developmentOnly ' | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==Ssh into Vagrant. Run application like Spring Boot application== | ||
| + | |||
| + | |||
| + | <sxh shell> | ||
| + | vagrant ssh | ||
| + | cd "/ | ||
| + | ./gradlew bootRun --args=' | ||
| + | </ | ||
| + | |||
| + | {{https:// | ||
| + | |||
| + | |||
| + | ===== Error: Authentication failure. Retrying... ===== | ||
| + | |||
| + | Thats also the reason for disk /mnt/d not being mounted correctly | ||
| + | |||
| + | <sxh shell> | ||
| + | |||
| + | # give the home permissions back to vagrant | ||
| + | # without that - / | ||
| + | # and also / | ||
| + | # so that no ssh connection works and | ||
| + | # vagrant ssh - failes with " | ||
| + | sudo chown -R vagrant: | ||
| + | </ | ||
| + | |||
devops/vagrant.1581436036.txt.gz · Last modified: (external edit)
