Starting with Terraform version 0.7.3 you can only define a variable once within a directory or a module. Before that release you could copy variable definition files from other modules and did not throw an error if you had the same variable defined in multiple files within the module.
In the new version of Terraform if you define the same variable name multiple times within the module you will get the following error message,
Variable '...': duplicate found. Variable names must be unique.
Make sure a variable is only defined once in the module or directory.
I am not sure who uses the Caps Lock button anymore. It was important in the age of typewriters to be able to type all uppercase titles without holding the shift key, but these days I don’t remember the last time I needed it. In fact I frequently press it accidentally and prevents me to log into my computer.
I have summarized the steps below to create a free Virtual Box Windows Server 2012R2 image on your workstation, so Test Kitchen can use Vagrant and Virtual Box to launch Windows instances and test cookbooks locally fast and free.
Install the Vagrant WinRm plugin
vagrant plugin install vagrant-winrm
Get BoxCutter
Create the Windows image with BoxCutter. This process will take 30 minutes or more to fully configure the Windows image. The download step may time out on slower VPN connections. In that case disconnect the VPN connection and try it again without it. In case of any error, just execute the last command again and if it can, the process will continue from the point of error.
cd ~/
mkdir boxcutter
cd boxcutter
git clone https://github.com/boxcutter/windows.git
cd windows
Modify the BoxCutter JSON file
Change the ~/boxcutter/windows/eval-win2012r2-standard.json file to avoid the error message:
virtualbox-iso: Removing floppy drive… ==> virtualbox-iso: Error removing floppy controller: VBoxManage error: VBoxManage: error: The machine ‘eval-win2012r2-standard’ is already locked for a session (or being unlocked) ==> virtualbox-iso: VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee nsISupports ==> virtualbox-iso: VBoxManage: error: Context: “LockMachine(a->session, LockType_Write)” at line 1038 of file VBoxManageStorageController.cpp
Change “headless”: “false”, to “headless”: “true”,
If you want to move Git repositories to your new workstation
Commit and push all repositories to GitHub on the old workstation,
Copy the folders from your old workstation to the new,
Execute the following command in all Git repositories on the new workstation.
git reset --hard
Terraform
Copying Terraform scripts from a Windows workstation
If the Terraform scripts reference modules, terraform creates symbolic links to those modules in the .terraform/modules directories. When you try to copy those symbolic links on a Windows machine the copy process stops. To copy the Terraform scripts
Start Windows explorer in the folder above the Terraform script folders,
Search for .terraform,
In the search result list delete the .terraform folders.
Test Kitchen
If you migrate between Windows and Macintosh you need to update a few paths, because the two operating systems store user specific files at different places.
The ssh_key location in the .kitchen.yml file should start with
Press the ‘Option/Alt’ key, right click on the Finder icon in the dock and click Relaunch
Show the battery charge percentage
Before Monterey ( macOS 12 )
Click the battery icon in the toolbar
Select Show Percentage
In Monterey or later
In System Preferences select Dock & Menubar
On the left side scroll down to Battery Menu Bar and select Show Percentage
Apple Id without credit card
If you don’t have an Apple Id, create one. To obtain one without a credit card, you need to create the account in an older version of iTunes. In version 12.7 Apple removed the access to the App Store.
If you don’t have ownership of Homebrew, before installation execute sudo chown -R $(whoami) /usr/local/var/homebrew sudo chown -R $(whoami) /usr/local/Homebrew/
The installation steps are currently brew tap zackelia/formulae brew install bclm sudo bclm write 77 sudo bclm persist
Check the set value with bclm read
Turn off Optimized battery charging in System Preferences to give full control to the tool.
You may need to reboot the computer for the process to start monitoring the battery.
The charging will stop around 80%. It may goes above 80% with a few percents, but at least the battery is not fully charged.
After software update
The system software update usually resets the upper charging limit to 100%. After system update execute in a terminal
sudo bclm write 77
sudo bclm persist
bclm read
UTC Clock in the menu bar
xBar is a plugin manager that can display plugins in the menu bar. One of them is World Clock that can display multiple clocks in a drop down of the menu.
If you use a Macintosh computer you use the Command key all the time. Unfortunately, on the Windows keyboard you will always hit the Windows key. This can be very frustrating, as pressing the Windows key with any of the cursor keys will resize the window.
Install the 32 bit version, as the 64 bit version is fairly new and has compatibility issues. Download the latest Ruby installer. Pick the file that does not have the (x64) at the end.
Accept the default values but check Add Ruby executables to your PATH
Ruby Development Kit
The Ruby Development Kit is need for certain Ruby gems, so install it.
If you have installed the 32 bit version of Ruby make sure you install the 32 bit version of the DevKit. Select the Development kit that matches the Ruby version you installed. At the time of writing the latest development kit is under “For use with Ruby 2.0 and above (32bits version only)”
Run the installer to extract it to a permanent location (C:\RubyDevKit)
Open a command window in the C:\RubyDevKit folder
Run these commands in the command prompt to install it.
You may need to add the location to the Path environment variable. Make sure you use the actual folder name, as it contains the version of the application.
;C:\Program Files (x86)\GraphvizX.XX\bin
AWS CLI
The Amazon Web Services command line interface installation will set up your workstation to launch instances in AWS from Test Kitchen. If you know you will work with AWS, see DevOps Engineering part 3. – Working with AWS for the AWS CLI installation.
Packer
We use Packer to create custom AWS AMIs that contain the fundamental configuration and applications that are common in every instance we launch.
To download apps from the Apple Store you need an Apple Id. If the app is free, you may not want to enter credit card information during the registration. If you try to create the Apple Id without the credit card in the App Store application, you may get the following error message:
Your session has timed out. Please try again. Code 5107
To create the Apple Id without a credit card
Start iTunes on your Macintosh,
Click the drop down menu in the upper left corner,
If Apps is visible, select it, otherwise click Edit Menu… in the same drop down,
To display Apps in the drop down, select the check box next to it.
On the top of the screen click the App Store button,
In the upper right corner search for a free app in the App Store and start to download it,
Create a new Apple Id and select None for credit card type.
When you try to execute any of the “kitchen” commands in Chef Test Kitchen you may get the following error message.
lib/kitchen/config.rb:182:in `block in filter_instances': undefined method `empty?' for nil:NilClass (NoMethodError)
This happened in my cookbook, when I have removed the value from the “excludes:” option in the .kitchen.yml file, but left the “excludes:” option there alone.
To make your cookbook work in Chef Test Kitchen again, remove the empty “excludes:” option form the .kitchen.yml file
Place the database backup file in the root directory of your C: drive (trust me, this will make your life easier)
Open the Command Prompt
Start the MySQL command prompt
mysql -u root -p
This command will prompt you for the MySQL root password
Switch to the new database
use db;
Import the database
source C:/BACKUP_FILE_NAME.sql
To avoid the Failed to open file ‘…’ , error 2 and error 22 error message
You can have spaces in the name of the backup file, but not in the directory names in the path
Do not use quotes around the file path
Use forward slashes
Do not end the command with semicolon (;)