Scrapbook: Setup Ansible and Google Cloud SDK on Windows
Ansible isn't supported on Windows so we need to have extra steps to install it, along with Google Cloud SDK.
My company laptop is Windows and lately I want to try Ansible. It took quite a long time for me to setup and ready for my experiment so I’m writing the steps here as a memo for the future.
WSL
WSL stands for “Windows Subsystem for Linux”. Even though Windows supports Git bash but it’s like bash emulator while WSL is a full Linux environment. And Ansible is not supported on Windows natively, so we need WSL for the case.

Ansible
Ansible is Infrastructure as a Code (IaaC) as well as Terraformtag: Terraform with great functionalities running on Python.
Ansible by design offers tasks configuration so I find it plays well on running sequential workflows. While Terraform is best at structure provisioning.1

Setup time
1. WSL
On Powershell or Terminal, install WSL via the command.
1
wsl --install
To uninstall, run this2.
1
wslconfig /u Ubuntu
2. Python
Open WSL and execute the following commands to install Python and family.
1
2
sudo apt update
sudo apt install -y python3 python3-venv python3-pip
Now we have Python and pip installed.
3. venv
On WSL, create venv.
1
2
python3 -m venv .venv
source .venv/bin/activate
If an error occurs when creating
.venv, for exampleensurepipis not available and/bin/activatedoesn’t appear like me, try creating.venvin Linux home path.
1 2 3 cd ~ # go to Linux home directory python3 -m venv .venv source .venv/bin/activate
4. Ansible and Google Cloud library
Next is to install our main tools, Ansible and Google Cloud Python library.
1
2
python -m pip install --upgrade pip
python -m pip install ansible google-auth google-cloud-<service>
We also need Google Cloud Ansible library via ansible-galaxy.
ansible-galaxy is a community to find third-party library for Ansible. ansible-galaxy is included and is ready out-of-the-box when we successfully installed Ansible.
1
ansible-galaxy collection install google.cloud
5. Google Cloud SDK
And install gcloud-sdk for Ubuntu for authentication in our machine.
1
2
gcloud auth login
gcloud auth application-default login
6. Verify
Last step is to ensure our environment is ready to go.
1
2
3
ansible --version
ansible-galaxy --version
gcloud -v
Finally we are supposed to develop Ansible workflow (on Windows) from now on.
