Find the AWS AMI that a RightScale server template is using

When you use RightScale to launch servers in the cloud, you want to use the same base image to test your Chef cookbooks in Test Kitchen.

Packer by Hashicorp is a utility to create custom server images based on cloud images. You supply the image ID and other configuration parameters to create a new custom image.

To find the AMI ID of the base image of the RightScale Server Template

  1. Open the RightScale user interface in your browser,
  2. Select the RightScale account where the server template was created,
  3. In RightScale Cloud Management select  Design / ServerTemplates,
  4. Select the server template,
  5. Select Images,
  6. Select the MultiCloud image,
  7. Select Clouds,
  8. Select the image in the region you are working in,
  9. The Resource UID is the AMI ID of the image.

Mailbox unavailable. The server response was: No such user here

When you send email from an application, most SMTP servers require authentication. Your application needs to supply a valid username and password to be able to connect to the server. This prevents strangers to use your SMTP server and send millions of spam emails.

When your application does not supply the correct credentials to connect to the SMTP server, instead of a descriptive message you can get this:

Mailbox unavailable. The server response was: <SEND_TO@SEND_TO.com> No such user here

The error message complains about the addressee, the email address you are sending the email to, instead of the username and password you try to use to access your SMTP server.

Make sure you are using the correct username and password to connect to the SMTP server.

Unable to read data from the transport connection: net_io_connectionclosed.

When your application tries to send an email using a Gmail account you may get the error message:

Unable to read data from the transport connection: net_io_connectionclosed.

One of the causes can be, when “Less secure apps” are not allowed to use the Gmail account.

To enable “Less secure apps” to use the Gmail account

  1. Log into Gmail and navigate to
    https://www.google.com/settings/security/lesssecureapps
  2. Select the Turn on radio button

 

The .NET MVC model has to have a parameterless constructor

When you create a class to be used as the model in a .NET MVC application, the class has to have a parameterless constructor. It is called during the POST when the user clicks the submit button of the form. If the class does not have a parameterless constructor, we will get the following generic error message. None of the breakpoints can help you to find the cause, and there is no entry in the event log.

The website cannot display the page
HTTP 500

Most likely causes:
•The website is under maintenance.
•The website has a programming error.

What you can try:
Refresh the page.
Go back to the previous page.
More information

Turn off the built in touchpad when a mouse is attached

All laptops today feature a touchpad, that enables you to move the pointer on the screen. It can be very annoying when your thumb accidentally moves the cursor when you type, even if an external mouse is connected to the computer.

Windows 10 provides a checkbox to automatically disable the internal pointing device when you connect a mouse.

  • Open the Control Panel,
  • Select Mouse,
  • On the Device Settings tab check the Disable internal pointing device when external USB pointing device is attached checkbox.

How to verify or generate file checksums

You can verify the checksum of a file with the built-in features of the operating systems

On Macintosh and Linux

Open the terminal window and execute the commands

SHA-256

shasum -a 256 FILE_NAME

On Windows

CRC32, CRC64, SHA256, SHA1, BLAKE2sp

Right-click the file in Windows Explorer and select CRC SHA > * (star)

The popup window will show the values, but unfortunately, there is no way to copy them to the clipboard. To be able to copy the hash value to the clipboard open a Bash window on the Windows computer and execute the Macintosh/Linux commands above.

To install Bash on a Windows workstation see the Git section of Install the DevOps development tools on Windows.

Upgrade TeamCity to version 10

Upgrade TeamCity to version 10

Create a backup of the database and the server before the upgrade

  1. Disable the Chef-Client scheduled task and Chef-Client service to make sure Chef does not alter the server during the upgrade.
  2. Disable the authorized agents to stop them picking new jobs.
  3. Stop the TeamCity process on the server,
    1. If TeamCity is started by a scheduled task at startup
      1. Disable the “teamcityserver” scheduled task in the Task Scheduler,
      2. Stop the “Java(TM) Platform SE binary” process in Task Manager.
    2. If TeamCity is running as a Windows Service
      1. Stop and disable the “TeamCity” service.
  4. Save a copy of the TeamCity configuration directories to the data drive and an outside location
    1. D:\TeamCity\conf
    2. D:\ProgramData\JetBrains\TeamCity\config
      Some file names in the D:\ProgramData\JetBrains\TeamCity\config\projects directory can be very long, so save the backup first in the root of the data drive
  5. Create a backup image of your server,
  6. Create a backup snapshot of your database,
  7. If the image creation did not restart the server, restart the box to make sure no processes hold files in the TeamCity install folder.

Download the TeamCity installer

  1. Enable file download on your server. Set the Internet Explorer security level to Medium-high
  2. Download the TeamCity server installer
    1. To download the latest TeamCity version navigate to
      http://www.jetbrains.com/teamcity/download/
    2. For earlier versions go to https://confluence.jetbrains.com/display/TW/Previous+Releases+Downloads

Install the new version of TeamCity server

  1. Execute the downloaded installer from the Downloads folder,
  2. If the current version of TeamCity is not on the C drive, make sure you select the correct drive,
  3. It is not recommended to run agents on the server box. Uncheck the Windows Services and Core for the Build Agent,
  4. If you get Folder is not empty… messages, delete the files from the indicated locations and click the Retry button,
  5. Set the correct port TeamCity should to use 
  6. Even if you haven’t enabled the agent functionality on the TeamCity server, you will see the Configure Build Agent Properties page. Click the Save button to continue.
  7. Select the SYSTEM account to run the TeamCity service
  8. Click the Next button to start the TeamCity service

Warning:

If you have specified larger memory setting than 32 bit Java is capable of handling, the TeamCity service will not start. You will get the following error message in D:\TeamCity\logs\teamcity-winservice.log

ProcessCommand [Info] Process exited with code: 1
console [Info] Error occurred during initialization of VM
console [Info] Could not reserve enough space for 2097152KB object heap
ServiceExecuteProcessTask [Error] Service process exited without service stop request

To switch to 64 bit Java, follow the steps below.

TeamCity on 64-bit Java

The TeamCity installer also installs the 32-bit version of the Java Runtime Environment (JRE) in the “D:\TeamCity\jre” folder. To use the 64 bit Java, test if your server has  64-bit Java installed:

  1. Open a command window and execute,
    java.exe -d64 -version
  2. The installed Java is 32 bit if you get the error message:
    Error: This Java instance does not support a 64-bit JVM.
    Please install the desired version.

Switch to 64-bit Java

  1. Stop the TeamCity Windows Service,
  2. Rename the D:\TeamCity\jre to OLD_jre, so TeamCity will not find it anymore,
  3. If you have not specified the memory settings in the Set the TEAMCITY_SERVER_MEM_OPTS environment variable based on the physical memory size of your server and the estimated usage
    1. Start Windows Explorer
    2. Right-click This PC and select Properties
    3. Select Advanced system settings
    4. Click the Envirnment Variables… button
    5. In the System Variables section select TEAMCITY_SERVER_MEM_OPTS
    6. Set the value based on the expected server load:
      1. minimum setting for 32-bit and 64-bit java:
        -Xmx750m
      2. recommended setting for medium 64-bit server and maximum for 32-bit server:
        -Xmx1024m
      3. recommended setting for large server (64-bit java only):
        -Xmx4g -XX:ReservedCodeCacheSize=350m
      4. maximum settings for large-scale server use (64-bit java only):
        -Xmx10g -XX:ReservedCodeCacheSize=512m

Source: https://confluence.jetbrains.com/display/TCD10/Installing+and+Configuring+the+TeamCity+Server#InstallingandConfiguringtheTeamCityServer-SettingUpMemorysettingsforTeamCityServer

Remove unsupported memory settings

TeamCity version 10 does not use -XX:MaxPermSize anymore. If you get

[Info] Java HotSpot(TM) Server VM warning: ignoring option MaxPermSize=2048m; support was removed in 8.0

remove “MaxPermSize” from theTEAMCITY_SERVER_MEM_OPTS environment variable.

Start the server

  1. Open Services and start the TeamCity Server Windows service
  2. Open a web browser and navigate to http://localhost:8111
  3. On the TeamCity Maintenance page select the I’m a server administrator, show me the details link
  4. Open the D:\TeamCity\logs\teamcity-server.log file and find the Administrator can login from web UI using authentication token line and copy the token number to the clipboard
  5. Paste the token to the textbox and click the Confirm button
  6. On the TeamCity Upgrade page click the Upgrade button
  7. TeamCity will make a backup of the current projects to D:\ProgramData\JetBrains\TeamCity\backup

Disaster recovery

If for some reason the server does not work after the upgrade, you can restore the database and the server from the backups you made before the upgrade.

Rebuild the environment

  1. Terminate the failed TeamCity server
  2. Restore the database from the backup snapshot
  3. Launch a new server instance from the backup server image

Make sure that the TeamCity process is not running on the restored server

When the server has started, remote into it.

  1. Check if the TeamCity process has ben stopped:
    1. If TeamCity is started by a scheduled task at startup
      1. Disable the “teamcityserver” scheduled task in the Task Scheduler,
      2. Stop the “Java(TM) Platform SE binary” process in Task Manager.
    2. If TeamCity is running as a Windows Service
      1. Stop and disable the “TeamCity” service.

Update the server configuration

TeamCity stores the address of the database and the IP address of the server in config files. To be able to use the restored server, make the following changes:

Update the database address

  1. Update the database address in the connectionUrl line of D:\ProgramData\JetBrains\TeamCity\config\database.properties

Update the IP address of the server

  1. Update the server IP address in the server rootURL element of D:\ProgramData\JetBrains\TeamCity\config\main-config.xml

Restart

  1. Restart the box for the changes to take effect.

Set up the Artifactory repository authentication

To secure Artifactory repositories follow the steps below

  1. Log into Artifactory as an administrator
  2. On the left select Admin

Add users

  1. In the Security menu select Users
  2. In the upper right select New

  3. Create users for admin, writer, and reader. Make sure the Can Update Profile checkbox is NOT checked, so if someone logs in with the service account credentials cannot change the account settings.

    1. REPOSITORY-NAME_admin,
    2. REPOSITORY-NAME_writer,
    3. REPOSITORY-NAME_reader.

Create security groups and add the new users to the groups

  1. In the Admin menu select Security and Groups
  2. On the Group Management page select New
  3. Create groups for admins, writers, and readers. Add “s” to the name of the group to differentiate it from the user.
    1. REPOSITORY-NAME_admins,
    2. REPOSITORY-NAME_writers,
    3. REPOSITORY-NAME_readers.
  4. In the Users section add the appropriate user to the group

Create permissions and add the groups to the permissions

  1. In the Security menu select Permissions
  2. In the upper right corner select New
  3. Create permissions to administer, write, and read the repository
    1. REPOSITORY-NAME_administer,
    2. REPOSITORY-NAME_write,
    3. REPOSITORY-NAME_read.
      1. Select the repository, click the green arrow to add the repository to the Selected Repositories list, and click Next
      2. Click the arrow next to the name of the group to add it to the list of groups
      3. Select the appropriate check boxes
        1. For writers select Delete/Overwrite, Deploy/Cache, Annotate, and Read
      4. Click the Save & Finish button.

To allow anonymous read access to the repository

To allow everyone to read the repository without authentication, add the anonymous user to the REPOSITORY-NAME_readers group.

The User Profile Service failed the sign-in. User profile cannot be loaded.

When you try to start a remote desktop connection to a Windows computer on the domain you may get the error message:

The User Profile Service failed the sign-in. User profile cannot be loaded.

To enable the User Profile update

  1. Remote into the computer with a local administrator account,
  2. In Windows Explorer open the C:\Users\Default\AppData folder,
  3. Right click the Roaming folder and select Properties,
  4. On the Security tab click the Advanced button,
  5. In the Permission entries list select System,
  6. Check the Replace all child object permissions… check box,
  7. Click the OK button,
  8. Click the Yes button on the Windows Security popup,
  9. Close the Properties window with the OK button.

Add SSH key to a Jenkins Git step

To access a Git repository Jenkins can use an SSH key.

To add the SSH key to the Jenkins server use the following Chef script

Store the SSH key in an encrypted data bag called “keys”.

{
 "id": "ci_private_keys",
 "ci_github_key": "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----",
}

 

Add the following to the Jenkins Chef recipe

  • Install Git
package 'git'
  • Install the Git and Credentials Jenkins plugins
jenkins_plugin 'git'
jenkins_plugin 'credentials'
  • Copy the SSH key to the Jenkins server
rsa_key = data_bag_item('keys', 'ci_private_keys')
file '/var/lib/jenkins/.ssh/id_rsa' do
  content "#{rsa_key['ci_github_key']}"
  owner 'jenkins'
  group 'jenkins'
  mode '0600'
end
  • Add github.com to the known hosts
bash 'provide github.com RSA fingerprint' do
  code <<-EOF
   ssh-keyscan github.com >> /var/lib/jenkins/.ssh/known_hosts
   chown jenkins.jenkins /var/lib/jenkins/.ssh/known_hosts
  EOF
  not_if{system('grep github.com /var/lib/jenkins/.ssh/known_hosts')}
end

 

To specify the SSH key in the Git step

  1. When the Jenkins server is operational, navigate to the Web interface
  2. Create a new Jenkins project
  3. In the Source Code Management section
    1. Select Git
    2. Enter the SSH URL of the repository
    3. When you are adding the first project, click the Add button to create the credential

      1. Click Jenkins to select the credentials provider
      2. Select SSH Username with private key as the Kind
      3. Enter the username you used when you created the SSH key for the Git repository
      4. Select From the Jenkins master ~/.ssh as the Private Key
      5. Click the Add button
    4. In the Credentials drop down select the credential you have created (the Git user name)