Skip to content

Instantly share code, notes, and snippets.

@bdwyertech
Last active April 21, 2022 09:52
Show Gist options
  • Save bdwyertech/b065086f721fbe89d73a9b89a2fc0af2 to your computer and use it in GitHub Desktop.
Save bdwyertech/b065086f721fbe89d73a9b89a2fc0af2 to your computer and use it in GitHub Desktop.
Windows Subsystem for Linux - ChefDK
# Update to Latest Windows 10 Spring Refresh
# Install WSL
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
# Get Ubuntu installed - https://docs.microsoft.com/en-us/windows/wsl/install-on-server
wsl.exe
# Install ChefDK deb package
# Symlink Relevant Home Folders
cd ~
ln -s /mnt/c/Users/DwyerB/.aws/ .
ln -s /mnt/c/Users/DwyerB/.chef/ .
ln -s /mnt/c/Users/DwyerB/.ssh/ .
# Enable Regular Permissions
# /etc/wsl.conf
[automount]
enabled = true
options = "metadata,umask=77" # fmask=111 ? Not sure what fmask does yet
# Make it take effect Immediately
sudo umount /mnt/c
sudo mount -t drvfs C: /mnt/c -o metadata,uid=1000,gid=1000,umask=77
# Create Relevant PowerShell Functions
function kitchen
{
wsl kitchen $args
}
function knife
{
wsl knife $args
}
@bdwyertech
Copy link
Author

Probably want something like this in /etc/sudoers.d too

%myyusername ALL=NOPASSWD:ALL
Defaults env_keep += "http_proxy https_proxy no_proxy"

@bdwyertech
Copy link
Author

bdwyertech commented Nov 18, 2018

You can use Chocolatey's Shimgen to create links to Linux tools...

This can come in handy for getting linters and such to work correctly in Atom

# Shellcheck
C:\ProgramData\chocolatey\tools\shimgen.exe -p $(which wsl).Source -c 'shellcheck' -o 'C:\ProgramData\chocolatey\bin\shellcheck.exe'

# Rubocop
C:\ProgramData\chocolatey\tools\shimgen.exe -p 'C:\opscode\chefdk\embedded\bin\rubocop.bat' -o C:\ProgramData\chocolatey\bin\rubocop.exe

C:\ProgramData\chocolatey\tools\shimgen.exe -p $(which wsl).Source -c 'chef exec rubocop' -o C:\ProgramData\chocolatey\bin\rubocop.exe

@bdwyertech
Copy link
Author

For GPG behind a proxy

RVM Installation

sudo apt-key adv --keyserver keyserver.ubuntu.com --keyserver-options http-proxy=$http_proxy --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

@mcascone
Copy link

mcascone commented May 7, 2019

@bschmoll that was basically my experience as well, although i first tried the Debian install. I eventually found this article that just led me to execute bash in a cmd window, and it worked.
The symlinks in the OP's gist are very helpful; now I'm trying to figure out how to get knife and kitchen to work. The error i get is:
bash: /mnt/c/opscode/chefdk/bin/kitchen: C:/opscode/chefdk/embedded/bin/ruby.exe: bad interpreter: No such file or directory
So i think i have to set a new ruby PATH? I'm not very good at this kind of thing - i get it, but i tend to not know where to look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment