How Do You Generate 10,000 Random Numbers in a Tuple in Python?

Problem scenario
You want to generate 10,000 random numbers in a tuple. That is, you want a tuple with 10,000 numbers. The numbers can be chosen at random. How do you do this?

Solution
See this posting first and follow it: How Do You Generate 10,000 Random Numbers in a list in Python?
See this posting second and follow it: How Do You,

How Do You Install OpenLDAP on Debian Linux?

Problem scenario
You have a Debian Linux server. You want to install OpenLDAP on it. What do you do?

Solution
(These directions were tested to work on Debian 9 in Google Cloud Platform.)

1. Run this command:
sudo apt-get -y install slapd ldap-utils

2. Set a new password for the administrator.

3. Uncomment the “BASE” and “URI” stanzas in /etc/ldap/ldap.conf.

How Do You Troubleshoot This Ansible Message “module_stderr…Shared connection to server closed. [Errno 13] Permission denied…MODULE FAILURE”?

Problem scenario
You try to run an Ansible playbook, but you get this problem:

“module_stderr…Shared connection to server closed. [Errno 13] Permission denied…MODULE FAILURE”

How do you fix it?

Solution
Is the Ansible playbook configuring the mode settings to not allow other users to execute the file? It could be that lower in the Ansible playbook, after the file is protected from other users executing it,

How Do You Get Bitbucket to Render Text in a Regular Size when There Are Hashtag (or Hashmarks, “#”)?

Problem scenario
Bitbucket’s GUI renders Bash code with large text on lines with a “#” hash sign (aka tic-tac-toe sign, number sign, or hash symbol). How do you get the lines to be the same size in Bitbucket GUI rendering?

Solution
Usually the hash sign “#” is a comment (for many programming languages). If you have a space after the hash sign like this “# comments here” (instead of “#comments here”),

How Do You Troubleshoot This Error “error executing access token command /google/google-cloud-sdk/bin/gcloud”?

Problem scenario
You run a command like this to view your Google Kubernetes Engine (GKE) clusters:

kubectl get pods

You see this:
‘Unable to connect to the server: error executing access token command “/google/google-cloud-sdk/bin/gcloud config config-helper –format=json”: err=fork/exec /google/google-cloud-sdk/bin/gcloud: no such file or directory output= stderr=’

What should you do?

Solution
Check your config file in the .kube directory.

How Do You Troubleshoot This Error “org.apache.bsf.BSFManager or javax.script.ScriptEngineManager”?

Problem scenario
You are running Ant and you get this error:

“Unable to load a script engine manager (org.apache.bsf.BSFManager or javax.script.ScriptEngineManager”

What should you do?

Solution

Uninstall Ant (e.g., sudo apt-get -y remove ant). Install the latest version of Ant. If you need directions, see this posting as it works on any distribution of Linux.

How Do You Write an Ansible Playbook to Retrieve Files from a Directory Relative to where the .YAML File Is?

Problem scenario
You want to refer to files in a subdirectory of the parent directory that houses your Ansible playbook. You have Git repositories with .yaml files and subdirectories. You want the Git repo to be transferred to a variety of different servers. The absolute path to the directory where the files are will vary. How do you have a variable or relative path reference in the playbook so as long as the directory structure is in place,

Why Does a Python Variable Keep Getting Assigned to 0 When the Output of the Bash Command Is a Different Number?

Problem scenario
In a Python script a variable that receives the output of a Bash command. When you run the Bash command on Linux or in a script, it works fine. But in the Python script it keeps being assigned to 0. What is wrong?

Solution

subprocess.call(“bash command”, shell=True) is NOT the same as subprocess.check_output(“bash command”, shell=True).

The subprocess.call will return a 0 if the Bash command was successful.