Obfuscated passwords in TeamCity

Obfuscate the password in the TeamCity UI

When a TeamCity build step needs to use a password, there is a way to obfuscate it.

  1. In the TeamCity web interface navigate to the project,
  2. On the project page open the Parameters page,
  3. Click the Add new parameter button,
  4. Enter the name of the parameter, the password value, and click the Edit button to set the special settings,
  5. Set the Display to Hidden, and the Type to Password to hide the value from the user interface. Click the Save button on this window and the on the parent window to save the parameter.
  6. To use the parameter in a build step, surround it with % signs.

Display the obfuscated password in the TeamCity UI.

To display the value of the password in the TeamCity UI again

  1. Select the attribute in the list
  2. Click the Edit button
  3. Set the type to Text and click the Save button
  4. On the Edit Parameter window click the Save button
  5. The password will be displayed in the parameter list.

Manage Windows Backups

To manage the Microsoft Windows Backups you can use a command line tool.

Open a command prompt as administrator

Show the existing backup versions

Wbadmin get versions

Clean up the backup disk

To keep a number of latest backups and delete the rest

Wbadmin delete backup -keepversions:NUMBER_OF_BACKUPS_TO_KEEP

To keep the latest backup only

Wbadmin delete backup -keepversions:1

To delete all existing backups

Wbadmin delete backup -keepversions:0

 

Chef custom resource is using the same property name as the called resource

When you create a Chef custom resource, you can call other resources including custom resources you have created. For ease of use it can be convenient to use the same property name as the called resource use.

property :delay_mins,          Fixnum, default: 3

reboot 'Hostname was changed' do
 reason reboot_reason
 delay_mins delay_mins
 action :request_reboot
end

When you you execute the code, chef will display the following error message:

property delay_mins is declared in both reboot[Hostname was changed] and utils_reboot[hostname_reboot] action :request_reboot. Use new_resource.delay_mins instead.

To tell Chef that you want to use the property you have created in this custom resource, add new_resource. in front of your property:

property :delay_mins,          Fixnum, default: 3

reboot 'Hostname was changed' do
 reason reboot_reason
 delay_mins new_resource.delay_mins
 action :request_reboot
end

Bluetooth: Not Available in Sierra on the Macintosh

After software update in Sierra on my Macintosh, my Bluetooth mouse usually stops working.

The toolbar displays the Bluetooth not available icon: 

When I click it, the “Bluetooth: Not Available” message is displayed.

There are two recommended actions we can take to bring Bluetooth back to life. If the first one does not help, try to execute them together during the same shutdown and restart cycle.

Delete the com.apple.Bluetooth.plist file from Library / Preferences

  1. Start Finder,
  2. In the Go menu select Go to Folder,
  3. Enter /Library/Preferences into the text box and click the Go button,
  4. Move the com.apple.Bluetooth.plist file to the trash,
  5. Shut down the Macintosh,
  6. Start the computer again.

Reset the SMC to reinitialize the Bluetooth module

  1. Shut down the Macintosh,
  2. Disconnect all peripherals (external display, drives, mouse, printer),
  3. Make sure the power adapter is connected to the computer,
  4. Press and hold the Shift, Control and Option buttons for 10 seconds,
  5. Start the computer with the power button, with the peripherals still disconnected,
  6. Re-connect the peripherals.

Second monitor does not work on Toshiba P-70A in Windows 10

Since I installed Windows 10 on my Toshiba P-70A laptop, the computer does not recognize the second monitor.

To make the second monitor work, I had to uninstall the display drivers and remove them from the computer:

  1. Open the File Explorer
  2. Right click This PC and select Properties
  3. In the upper left corner select Device Manager
  4. Expand the Display adapters section
  5. Right click each display adapter,
    1. Select Uninstall
    2. Check  Delete the driver software for this device
  6. The computer will reboot.

To keep your second monitor working do not update the display drivers, keep the drivers that Windows installs during the reboot.

How to secure Jenkins

When you install Jenkins, the default settings allow anyone to sign up and administer it. There are many ways to secure Jenkins, the simplest is to disable the user sign up and require login to administer the server.

  1. Click sign up in the upper right corner and create an account for yourself
  2. On the Jenkins Dashboard select Manage Jenkins
  3. On the Manage Jenkins page select Configure Global Security
  4. Make sure the circled items are set according to the picture below.

Minimum Windows workstation setup to work with Windows servers

If you work on a Mac or Linux workstation and need to script and administer Windows servers, you need a few Windows tools. You can create a Windows Virtual Machine hosted in the free Virtual Box from Oracle or in VMware Fusion. For installation instructions see Install the DevOps development tools on Windows

  • Notepad++
  • Chocolatey
  • Git
  • AWS CLI (Amazon Web Services Command Line Interface)

Disable the left Windows Key

When you work on a Mac, you use the Command key for cut, copy, paste and other functions. If you press the same key in the Windows virtual machine, it acts as the Windows key. If you press it with an arrow key, it will move or resize your current window.

To disable the left Windows Key in your Windows virtual machine download SharpKeys from https://www.randyrants.com/category/sharpkeys/.

The application does not run in the background, it only updates the registry to remap the specified keys. Configure it to disable the left Windows Key:

Windows tools on the Mac

There are DevOps tools that you can install on your Mac to work with Windows servers and applications

Microsoft SQL Server tools

To connect to Microsoft SQL servers you can install Visual Studio Code and the MSSQL extension on your Mac.

Visual Studio Code

Install Visual Studio Code

  1. Install OpenSSL from the terminal window with
    brew update
    brew install openssl
    ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
    ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
  2. Download and install Visual Studio Code from https://code.visualstudio.com/Download
  3. In Visual Studio Code open the Code menu and select Preferences, Settings
  4. On the left side select the Extensions icon, and type mssql into the search field
  5. Click the Install button.

To connect to an MSSQL server from Visual Studio Code

  1. In Visual Studio Code press F1 ( or SHIFT+COMMAND+P ) to open the Command Palette
  2. Type sql into the search field to display the MSSQL commands and select MS SQL: Connect
  3. Select Yes, to switch to the SQL language
  4. Type sql into the search field and select SQL
  5. Click Create Connection Profile
  6. Enter the IP address or the name of the server, and press enter
  7. You may enter the database name
  8. Select the authentication type. If you want to connect to the database server with SQL credentials, select SQL Login, to connect with Windows credentials, select Integrated.
  9. Enter the username
  10. Enter the password
  11. To save the password in the connection profile select Yes
  12. Enter a name for the profile
  13. Visual Studio Code connects to the database server. the status bar at the bottom of the page shows the connected server information,
  14. Hover above the server name with the mouse to display the detailed server info.

To edit the SQL Server profile in Visual Studio Code

  1. In the Code menu select Preferences, Settings
  2. Edit the JSON file in the USER SETTINGS window

Execute an SQL script

  1. Enter the script into a Visual Studio Code tab
  2. Press COMMAND+SHIFT+E to execute the script
  3. Choose the profile to connect to the server
  4. The result is displayed on the Results tab

For more info on MSSQL in Visual Studio Code see https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-develop-use-vscode?view=sql-server-2017

NoMethodError: undefined method `exists?’ for Chef::Resource::File:Class

When you create a Chef custom resource and use the File class, you need to make slight a change in the syntax you use.

In a Chef recipe you can use

if File.exists?("#{FileName}")

to check for the existence of a file. If we use the same line in a Chef custom resource, we get the error message:

NoMethodError: undefined method `exists?’ for Chef::Resource::File:Class

In a Chef custom resource, you need to add :: in front of the File class to make it work

The leading :: tells Chef not to look for the “File” class in the Chef namespace.

if ::File.exists?("#{FileName}")

 

Migrate databases to and from AWS RDS instances

Amazon Web Services do not provide tools to migrate data to, from and between AWS RDS instances.

There is a free utility that can do the job.

SQL Server Management Studio (SSMS)

Install Microsoft SQL Server Management Studio (SSMS), because the utility uses libraries from it.

  1. Download the installer for free from https://msdn.microsoft.com/en-us/library/mt238290.aspx

SQL Azure Migration Wizard

Installation

  1. Download the SQL Azure Migration Wizard from http://sqlazuremw.codeplex.com/
  2. Unzip the downloaded ZIP file into a folder on your hard drive
  3. Create a shortcut in your Start Menu for SQLAzureMW.exe

Migrate a database

  1. Start the SQL Azure Migration Wizard by executing the SQLAzureMW.exe file
  2. Select Database in the Analyze / Migrate section and click Next

Connect to the source database

  1. On the Connect to Server page
    1. Enter the address of the database server
    2. Select SQL Server Authentication
    3. Enter the database owner login name and password
    4. If you keep Master DB selected, the next screen will show the list of databases to select from
    5. To save the username and password select Save Login Information
    6. Click Connect

  2. Select the database to connect to and click Next
  3. Leave Script all database objects selected and click Next
  4. On the Script Wizard Summary page click Next
  5. Click Yes to start the read process
  6. On the Results Summary page select Auto Scroll Display to see the scrolling results
  7. When the read is done click Next

Connect to the target database

  1. Enter the connection properties of the target database server
  2. Select the target database
    1. To migrate the data into a new database click the Create Database button
    2. On mirrored RDS instances we cannot drop and recreate databases. To migrate data into an existing database
      1. Use SQL Management Studio to drop the existing tables to avoid key conflicts
      2. Select the target database on this page
  3. Click Next
  4. Click Yes to start the write process
  5. When the write process is done click Exit