delimited by end-of-file (wanted `EOF’)

When you create a file in a script and use an end of file delimiter,

if ...
  cat <<EOF> $chef_dir/attrib.json
    $json
  EOF
fi

and you indent the word EOF to look nicer, you will get the error message

warning: here-document at line … delimited by end-of-file (wanted `EOF’)
STDERR> …: line …: syntax error: unexpected end of file

To correct the script, move the EOF to the beginning of the line

if ...
  cat <<EOF> $chef_dir/attrib.json
    $json
EOF
fi

could not find filename for attribute .DS_Store in cookbook

The Macintosh workstation saves application states in .DS_Store files. When you edit your Chef cookbooks the MacOS leaves these files in many folders.

When the Chef cookbook is executed, the Chef Client reads all files in the attributes folder and tries to extract values from them. If the .DS_Store file is uploaded with the rest of the cookbook to the Chef server, the Chef cookbook execution stops with the error message:

=============================================================
Recipe Compile Error in /var/chef/cache/cookbooks/…/attributes/.DS_Store
=============================================================

Chef::Exceptions::AttributeNotFound
———————————–
could not find filename for attribute .DS_Store in cookbook …

When you test your cookbook with Test Kitchen, there is no error, so you cannot detect the existence of the file until the Chef cookbook starts to run on the instance.

Even though the.DS_Store file cannot be seen in Finder, it still can be there. It is a hidden file, and even if you enable the display of hidden files, Finder does not show it.

$ cd attributes
$ ls -a
. .. .DS_Store default.rb

To remove the .DS_Store file from the cookbook

  1. Make sure the .DS_Store file is added to the chefignore file
  2. Delete the file from the folder on your workstation
    rm .DS_Store
  3. Increment the version of the cookbook in the metadata.rb file
  4. Upload the new version of the cookbook to the Chef server
    knife cookbook upload MY_COOKBOOK --freeze

 

TeamCity Agent Unmet Requirements

When a TeamCity configuration is created there are requirements the TeamCity Agent has to meet.

The creator of the build configuration can specify Explicit Requirements on the Agent Requirements page of the Build Configuration Settings.

When the build configuration is created, TeamCity automatically adds Build Step Requirements.

The bottom of the same page shows the list of compatible and incompatible agents.

If you visit the incompatible agent, most likely it will not contain the parameter, or the value will be different from the requirement. To see the expected value of the parameter, open the Agent ParametersConfiguration Parameters tab of an agent that satisfies the requirement.

Create a Splunk index

Splunk stores the events in separate databases based on index names. It is faster to search for events if the event types are separated into multiple indexes.

To create an index for the event type you want to send to Splunk

  1. In the Settings menu select Indexes
  2. Click the New Index button
  3. Enter the name of the index. You can leave the default settings, and click the Save button.

Enable the HTTP Event Collector in Splunk

To send events to Splunk via HTTP posts, enable the HTTP Event Collector functionality on the Splunk Enterprise server.

If you operate your own Splunk server

  1. Log into the Splunk web interface as an administrator
  2. In the Settings menu select Data inputs
  3. Select the HTTP Event Collector link
  4. In the upper right corner click the Global Settings button
  5. To enable the Splunk HTTP Event Collector, click the Enabled button
  6. To use HTTP instead of HTTPS uncheck the Enable SSL checkbox
  7. Click the Save button to save the changes

 

How to send an event to the Splunk HTTP Event Collector

The Splunk HTTP Event Collector is the preferred way to send events to Splunk.

The Splunk HTTP Event Collector closes the connection if you don’t use HTTPS when you are sending a POST message.

Recv failure: Connection reset by peer

To send the event from the Macintosh Bash terminal

curl -k https://MY_SPLUNK_SERVER_IP:8088/services/collector -H 'Authorization: Splunk MY_TOKEN' -d '{"sourcetype": "json", "event":"Hello, World!", "host":"MY_HOST_NAME"}'

To send the event from Postman

Turn off the SSL Certificate Validation.

If the Splunk server does not have a trusted SSL certificate, Postman will throw an error if you send the message with the mandatory HTTPS protocol. To tell Postman, you trust the SSL certificate generated by the Splunk server, turn off the SSL certificate validation in Postman.

This option is only available in the standalone version of Postman, not in the Chrome add-on

  1. In the upper right corner of Postman click the wrench
  2. Select Settings
  3. On the General tab turn off SSL certificate verification

Create the post

  1. Add your Splunk token to the header
  2. Add the raw, JSON type body

 

Send Alt-Control-Delete to a Windows server via Remote Desktop

When you log into a Windows server via the Remote Desktop Protocol (RDP) in some cases you need to send the Alt-Control-Delete ( in other notations Alt-Ctrl-Del, Control-Alt-Delete, Ctrl-Alt-Del ) key combination to the remote server.

From a Macintosh laptop

On a Macintosh laptop press the fn+control+option+delete keys to send Alt-Control-Delete to the server.

From a Windows workstation

If the Remote Desktop window is not in full-screen mode, Alt+Control+Delete will control your own Windows workstation.

On a Windows workstation press the Alt+Control+End keys to send Alt-Control-Delete to the remote server.

 

Splunk App for AWS

To collect data from AWS install the Splunk App for AWS plugin.

The app currently can collect information from

  • AWS Config,
  • Config Rules,
  • CloudTrail,
  • Inspector,
  • CloudWatch,
  • CloudWatch Logs,
  • Billing,
  • S3,
  • Kinesis,
  • Metadata.

New data source

To set up a new data source, click the Set up button

Already set up data source

To add a new input to the data source, click the New Input button

To view the list of existing inputs, click the link in the section

To view the settings of an existing input, click the name of the input, to add a new input, click the Add Input button. There is no way to edit the settings of existing inputs, to make changes, create a new input. There is also no method to disable an existing input, to stop the data collection, delete the input in the Action column.

S3

To read and process files from S3, select the S3 data source.

To select the Source Type click the Source Type field. If the source type is in the list, select it.

To add a source type, not in the list, enter the name into the text box, and click the generated link under the text box.

To collect the data more frequently than the default 30-minute interval, click the Advanced Settings link and enter the interval in seconds.

 

Skip steps in an InSpec integration test based on Chef attribute values

To speed up the test of some complex recipes, I use an attribute to skip certain long-running installations when I only need to test the rest of the recipe.

We will pass Chef Attribute values into an InSpec test using environment variables.

Declare an attribute in the atrributes.rb file with a safe default value, to allow the execution of all steps if the value is not overridden

# Set this to true in the .kitchen.yml file to skip long-running tasks during local test
default['quick_launch_for_test'] = false

Set the value in the suites: section of the kitchen.yml file to true to skip the long-running installations

  attributes:
    quick_launch_for_test: true

Save the attribute value in an environment variable in the recipe to pass it to InSpec

# Store the value in an environment variable for the integration test
env 'quick_launch_for_test' do
  value "#{node['quick_launch_for_test']}"
end

Make a decision in the recipe based on the value of the attribute

if ( node['quick_launch_for_test'] != true )
  #########################################
  #Microsoft Visual Studio Community 2017 #
  #########################################
  ...
end

Read the value of the environment variable into a local variable in the InSpec test file. If the environment variable does not exist, or the value is not “true”, the value of the local_execution variable will be “false”.

local_execution = ( os_env('quick_launch_for_test').content() == 'true')

Use the if statement to make the decision in your InSpec test file

if !local_execution
  describe package('Microsoft Visual Studio Community 2017') do
    it { should be_installed }
  end
end

 

Git Bash and Command Prompt cannot see the VirtualBox shared folder on Windows 10 guest

When you start a Windows 10 guest machine in VirtualBox on your workstation, you can set up shared folders to seamlessly copy files between your workstation and the Windows 10 guest machine.

The shared folder appears in Windows Explorer as a mapped network location.

For more on this see Configure the Windows virtual machine in VirtualBox

On a Windows 7 guest machine the Git Bash, Command Prompt, and PowerShell windows all can see the mapped E: network drive, so you can change the working directory with

cd E:

and execute commands in the shared folders.

On a Windows 10 guest machine, only the PowerShell window can see the shared folder as a mapped network drive, E:


Command prompt will display the error message

The system cannot find the drive specified

When you try to start the Git Bash window with Git Bash Here, nothing happens.

If you start Git Bash from the menu and try to change the working directory to the E: drive, you get the error message

bash: cd: /e: No such file or directory


If you need to use the Command prompt, you can temporarily map the shared folder

  1. Open the Command Prompt on the Windows 10 guest machine
  2. Execute the command
net use x: \\vboxsvr\Users