How Do You Troubleshoot an Ansible Error about a User Not Being Able to Authenticate when the Module is Supposed to Interact with a Database?

Problem scenario
You have an Ansible module that uses a database module.  When you run the playbook, you get an error about a user being unable to authenticate when this database module is run.  What could be wrong?

Solution
Is the user in the error message a user that is created via the playbook?  If it is, does that user get assigned a password? 

How Do You Get an Ansible Command to Issue a Long-Running Bash Command and Keep Processing?

Problem scenario
You have a playbook that runs a shell command.  But this command never completes.  If you cancel the playbook, you find the processes started from the playbook cancel from the cancellation of the playbook too.  You want the process to keep running while Ansible moves to the next command.  You want processes to run in a detached way that is independent of the playbook execution itself. 

How Do You Install Ansible on a Debian Linux Server Running in GCP?

Problem scenario
You are using Google Cloud Platform, and you have a Debian server.  You do not want to configure any PPAs for your system.*  How do you install and configure Ansible on a Debian Linux system?

Solution
Prerequisite

We strongly recommend having 2.5 GB of memory (either in RAM or with a combination of RAM and swap space).  

How Do You Troubleshoot the Ansible Error “Syntax Error while loading YAML expected <block end>, but found ‘-‘”?

Problem scenario
You are trying to run an Ansible playbook with the “become: yes” stanza.  You get this error after your ansible-playbook command:

“ERROR! Syntax Error while loading YAML.
  expected <block end>, but found ‘-‘

The error appears to have been in ‘/home/cooluser/good.yaml’: line 4, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

 

How Do You Troubleshoot “ERROR! ‘service’ is not a valid attribute for a Play”?

Problem scenario
You are trying to use the “service” Ansible playbook reserved word.  You want a service to be started.  But when you run the Ansible playbook, you get “ERROR! ‘service’ is not a valid attribute for a Play”.  How do you fix this?

Solution
Change the formatting of the playbook.  Eliminate spaces and make sure indentation aligns with other sections of the playbook.

How Do You Get an Ansible Playbook to Issue a Reboot of a Server and Wait for the Server to Come back?

Problem scenario
You know that the orchestrated installation of interconnected systems can have a significant benefit. Sometimes ordering the installation of packages on a single server can be useful. You do not want a “failed to connect to server” or “ansible ssh shared connection failed” message when you run a playbook.  You want the playbook run to wait for the server to boot up again.  The playbook reboots multiple servers at once. 

How Do You Troubleshoot the Error “rsync mkdir failed… rsync error in rsync protocol data stream (code 12)”?

Problem scenario
You try to use rsync or you use Ansible’s synchronize module.  It fails with this message: “rsync mkdir failed… rsync error in rsync protocol data stream (code 12)”

Solution
Is the destination directory writable?  Verify that the destination exists and has the correct permissions for being able to write to it with the user the Ansible playbook uses.

How Do You Address a Problem Message about a Directory Being Read-only when It Is Not Read-only?

Problem scenarios
One or both of the following applies to your situation:

#1  In Linux you try to move a directory that is not read only (e.g., its permissions are rwxrwxrwx or 777).  You get an error about it being read-only.  Your user is the owner of the directory.  

OR

#2  You are running an Ansible playbook and trying to change the attributes of the file. 

How Do You Solve an Ansible Problem about an SSL Certificate Error?

Problem scenario
You run an Ansible playbook.  You receive an error about the SSL certificate not being valid.  What should you do to get the playbook to transfer a file from a website using SSL or TLS to a managed node?

Possible Solution #1
If the problem pertains to retrieving a file from a website URL, this may apply. If the problem is between the managed node and the website and not between the control node and the website,

What Do You Do when an Ansible Playbook Is Not Removing a File or Directory or Unmounting a Directory when There Are No Errors?

Problem scenario
You run a playbook, and there are no errors.  But the playbook’s simple logic is not working.  The file or directory is not being eliminated.  Or the unmount of the directory is not working via the mount module.  What should you do about a silently failing playbook?

Solution
1.  Verify there are no [trailing] spaces in the directory path.