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. 

How Do You Troubleshoot the Ansible Playbook Error “fatal: FAILED! => {“msg”: “The conditional check “?

Problem scenario
You run an Ansible playbook that uses a variable, but you get the message “fatal: FAILED! ={“msg”: “The conditional check …The error was: error while evaluating conditional (ansible_hostname == ):”.  What should you do?

Solution
When testing a variable’s value to another fixed string, put quotes around the string.  

Here is an incorrect example of a playbook using such a comparison:

     

How Do You Troubleshoot the Ansible Error “this task includes an undefined variable”?

Problem scenario
You are running an Ansible playbook, but you get the error “this task includes an undefined variable.”  Every variable seems to be defined.  What is wrong?

Possible solution #1
Do one of the variables rely on an index of server names?  If the playbook orchestrates something that responds to Ansible values on other servers and one server is not reachable,

How Do You Troubleshoot the Ansible Problem “IOError: [Errno 13] Permission denied…”?

Problem scenario
You are running an Ansible playbook, but you get an error like this:  “IOError: [Errno 13] Permission denied…”

How do you get the playbook to work?

Solution
If the playbook has a destination for a file and that file is already there on the managed node, this error may occur. 

1.  Go to the managed node. 

How Do You Troubleshoot the Ansible Message “AnsibleOptionsError…ansible.cfg…File contains no section headers”?

Problem scenario
You try to run an Ansible playbook but you get this error “AnsibleOptionsError…ansible.cfg…File contains no section headers”

Your ansible.cfg file has headers. What should you do?

Solution
Eliminate indentations.  The [header] should be on the far left of the screen with no leading spaces.