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 (;)
To send RSA private keys to instances, store them in encrypted data bags. The data bag item is a JSON file that contains keys and values inline.
Use base64 encoding
Base64 encoding converts binary data to ASCII format to represent special characters, like line breaks as ASCII text. The result will be larger, 8 / 6th of the original size, as every 8 bit ASCII character only represents 6 bits of data.
To convert a file to base 64 and save it as another file
cat test.pem | base64 > test.pem.base64
If we need the result on the computer’s clipboard to paste it into a field on the screen
cat test.pem | base64 | pbcopy
To use the encoded string we need to decode it in the Chef cookbook.
Replace the newline characters with \n
To place the multi-line RSA key into the value part of the JSON file, we need to replace the new line characters with the “\n” text.
In Atom
on Mac and Windows
Open the RSA key file in Atom,
Press Command-F on Mac, Ctrl-F on Windows to open the Find and Replace window,
On the right side click the Use Regex button,
In the search field enter
\r\n
In the replace with field enter
\\n
Press the Replace All button
In Visual Studio Code
on Mac and Windows
Press Command-F on Mac, Ctrl-F on Windows to open the Find dialog
Select the Use Regular Expression button
Enter \n into the find, \\n into the replace field
In Notepad++
on Windows
Open the RSA key file in Notepad++,
In the Search menu select Replace…,
Select Extended mode in the Search Mode section,
Enter \r\n to the Find what text box ( if the key was generated on a Windows computer using GitBash, search for \n )
Enter \\n to the Replace with text box
Press the Replace All button
You can place the single line key into any encrypted Data Bag file. See Data Bags on Data Bag encryption.