How Do You Troubleshoot the Ansible Message “ERROR! the field hosts is required but was not set”?

Problem scenario
You run an ansible-playbook command, but you get “ERROR! the field hosts is required but was not set”. What should you do?

Solution
Find the hyphens beneath the top “- name” stanza. Eliminate them. For example, if your playbook looks like this:

– name: Foobar
hosts: localhost
– vars:
goodone: “blahblah”
-tasks:

Make it look like this:

– name: Foobar
hosts: localhost
vars:
goodone: “blahblah”
tasks:

Now re-run it.

How Do You Add Multiple DNS A Records in Active Directory Using a File?

Problem scenario
You want to create multiple A records in DNS. But to do it manually using the MMC would take too long. What should you do?

Solution

  1. Open the MMC and browse Active Directory. On the left the name of the A.D. server should be fairly obvious (e.g., contint or foobarsrv).
  2. Open PowerShell as an administrator.

How Do You Troubleshoot the Python Problem “SyntaxError: EOL while scanning string literal”?

Problem scenario
You are running a Python program or trying to execute a line from the Python interpreter command line. You receive this message: “SyntaxError: EOL while scanning string literal”. What should you do?

Solution
Look for the double quotes and single quotes. Have they all be terminated? Are they in an even number? Was the code copied to a different workstation application and then pasted into vi or a terminal prompt?

How Do You Write a Python Program to Print All the VPCs in Your AWS Account?

Problem scenario
You want to list all the VPCs in your account. You are using Boto3 and Python 3. What do you do?

Solution
Run this four-line program:

import boto3
client boto3.client(‘ec2’)
response = client.describe_vpcs()
print(response)

Citation: The above was adapted from https://stackoverflow.com/questions/47329675/boto3-how-to-check-if-vpc-already-exists-before-creating-it

How Do You Troubleshoot the Ansible Error ‘”hadoop_env” is undefined’?

Problem scenario
You try to run a playbook. But you get a message like this: ‘fatal: … “AnsibleUndefinedVariable” ‘hadoop_env’ is undefined’. What should you do?

Root cause: a variable you defined (e.g., in a playbook or role) is not getting assigned when you run the playbook.

Possible solution #1
Find the vars directory or create it.

How Do You Use the AWS CLI to View the Targets of Routes in Route Tables in a VPC?

Problem scenario
You have a VPC with route tables. You want to search the targets to find a given value. What should you do?

Solution
As of early 2020, the output of aws describe-route-tables –filters –route-table-id abcd1234 –region us-west-2 will not include the word “target”. The value of the target in the JSON output will be the ID of the given target.