What Is the Syntax for Viewing ec2_instance_info Return Values in Ansible?

Problem scenario
You read about a supported data type (defined keys) in Ansible playbooks related to EC-2 servers in AWS. How do you view this data?

Solution

  1. Have a playbook (.yaml file) with the following syntax:

ec2_instance_info:
region: us-west-1
register: vara

  1. Refer to vara as a variable. Here is an example of how to see it:

debug:
msg: “{{ item.instance_id }}”
loop: “{{ vara.instances }}”

How Do You Get xargs to Execute Rather Than Print a Command?

Problem Scenario
You are writing a Bash command to craft AWS CLI commands. But the commands are not running with your xargs command. You created something like this:

aws s3 ls s3://bucketname/ | awk ‘{print “/usr/local/bin/aws s3 rm s3://bucketname/”$4}’ | xargs -L 1

But it merely displays the well-crafted AWS CLI commands. You want the commands to execute.

You tried a variation but received “xargs: awscli: No such file or directory.”

What should you do?

How Do You Unhighlight Text in Mac’s TextEdit program?

Problem scenario
You are using a Mac and modifying text with TextEdit. Some text you copied is highlighted. How do you unhighlight the text?

Solution
Highlight the text that is highlighted with the mouse. There should be two pallettes at the top of the TextEdit application. These are solid-color rectangular icons to the right of the font size and to the left of the BIU (bold,

How Do You Troubleshoot the CloudWatch Command Line Error “no outputs found, did you provide a valid config file”?

Problem scenario
You think your amazon-cloudwatch-agent.toml file has been misconfigured. You run “amazon-cloudwatch-agent-ctl” but you get an error about “no outputs found, did you provide a valid config file.” What should you do about this error?

Solution

  1. Use amazon-cloudwatch-agent-config-wizard to create the configuration file. From the command line it will walk you through step-by-step directions in text.
  2. Assuming the default configuration has been saved as “AmazonCloudWatch-linux” (based on how you responded above),

Does Automation Subsume DevOps or Does DevOps Subsume Automation?

Question
Is automation bigger than DevOps?

Answer
We think that the canonical answer is yes, automation subsumes DevOps. Some professionals think in terms of automation, and automation existed before DevOps was a word. It is well known that the Toyota Production System has influenced DevOps. Automation played a big role in the success of Sakichi Toyoda.

His “most famous invention was the automatic power loom [“a hand-operated or power-driven apparatus for weaving fabrics”,

How Do You Create a Class That Is an Iterator in Python?

Problem scenario
You want to implement an object that is an iterator in Python. What do you do to implement iterator behavior in the class?

Solution
Run this program as an example:

class Computation:

def __init__(self, max = 0):
self.max = max

def __iter__(self):
self.n = 0
return self

def __next__(self):
if self.n <= self.max:
product = 2 * self.n
self.n += 1
return product

objecta = Computation(4) # The number must be 3 or greater if you want to print something other than “None” with this program. …

How Do You Install the make Utility on Any Type of Linux?

Problem scenario
You want to install make on Linux. You want it to work on any type of Linux (e.g., Red Hat, Debian and SUSE derivatives). What should you do?

Solution
Prerequisite

Install the C language compiler. If you need assistance, see this posting: How Do You Install a C Compiler on Linux?

Procedures
Run this script:

a=$(which gcc)
echo $a” was found.”
echo “This will fail if no c compiler is installed.”
sleep 2
version=4.3
curl -L http://ftp.gnu.org/gnu/make/make-$version.tar.gz /tmp/make-$version.tar.gz
mv /tmp/make-4.3.tar.gz /usr/bin/
cd /usr/bin
tar xf make-$version.tar.gz
cd make-$version
./configure –prefix=/usr/local
rm make
bash build.sh
rm /usr/bin/make
echo “Ignore a message like this:”
echo “rm: cannot remove ‘/usr/bin/make’: No such file or directory”
echo “That message can be safely disregarded.”
ln -s /usr/bin/make-$version/make /usr/bin/make …

How Do You Hyperlink to Specific Paragraphs (Not the Top) of a WordPress Article?

Problem scenario
You are using WordPress. You have a posting that is long, and you want a link to a paragraph at about halfway down in it. How do you create a hyperlink to a specific paragraph of a WordPress article?

Solution

  1. In your web UI editor for WordPress, click on the three vertically-stacked dots in the upper right-hand corner.
  2. Click on “Code Editor”
  3. Go to the place in the posting where you want the hyperlink to be.

Why Does “aws ssm” Return False Messages about a Package Being Installed?

Problem scenario
You run an “aws ssm” command. It returns that a given package has been installed. You know the package is not really installed. What is the reason for the discrepancy?

Solution
A previous “aws ssm” command may have run successfully. But later someone may have deleted specific files without using “aws ssm”. This is a limitation of “aws ssm”. It can provide false positives or negatives if engineers/administrators bypass aws ssm for their tasks.