Troubleshooting¶
A checklist for the most common issues, working from the operator down to the runner pods.
Inspecting state¶
Start by reading the status conditions of the resource that isn't behaving:
kubectl get ansiblehost <name> -o jsonpath='{.status.conditions}' | jq
kubectl get ansiblegroup <name> -o jsonpath='{.status.conditions}' | jq
kubectl get ansiblereconcilejob <name> -o jsonpath='{.status.conditions}' | jq
The reason and message fields usually point straight at the problem. Also check the manager logs:
AnsibleHost never becomes Ready¶
Likely causes:
- Missing or malformed private key. The
sshKeySecretRefsecret must contain a valid SSH private key under the keyssh_key. Recreate it with: - Host-key scan failed. With
ssh.ignoreHostKey: falsethe operator connects toconnection.hostonconnection.portto capture the host key. Ensure the address is reachable from inside the cluster (a*.svc.cluster.localname, a routable IP, etc.), not just from your workstation. - Passphrase-protected key. Keys must be usable non-interactively. Provide a key without a passphrase.
AnsibleGroup shows Healthy=False or ReferencesValid=False¶
ReferencesValid=False— one of the referenced hosts or subgroups doesn't exist in the namespace. Check the names inspec.hostsandspec.groups.Healthy=False— the references exist but at least one member isn'tReady. Fix the underlyingAnsibleHostor subgroup first; group health propagates automatically.
AnsibleReconcileJob is Ready=False / the CronJob is suspended¶
On a reconcile error the controller suspends the generated CronJob and records the reason in the
Ready condition. Common causes:
- Invalid
schedule. The cron expression is rejected when theCronJobis created. Verify the expression. playbookRefpoints at a missing playbook. Confirm theAnsiblePlaybookexists in the same namespace.
After fixing the cause, the next reconcile un-suspends the CronJob.
A run fails (Successful=False)¶
Look at the pod logs for the most recent job:
There are two containers to inspect:
- The init container prepares the playbook (cloning from Git for Git-sourced playbooks and
installing requirements). Failures here usually mean an unreachable Git repo, a bad
ref, or a wrongplaybookPath/requirementsPath. - The runner container executes
ansible-playbook. Failures here are normal Ansible errors: unreachable hosts, host-key mismatches, failed tasks, or privilege-escalation problems.
SSH host-key verification errors at run time¶
The runner uses the aggregated known_hosts built from each host's trusted key. If a host was
re-provisioned its key changes and verification fails. Either:
- Clear the stored key so the operator re-pins it on the next reconcile (delete/empty the
sshHostKeySecretRefsecret), or - Set
ssh.ignoreHostKey: trueon the host if you accept the reduced security.
Manual run for debugging¶
You don't have to wait for the schedule:
kubectl create job --from=cronjob/<reconcile-job-name> debug-run
kubectl logs job/debug-run --all-containers --follow
Still stuck?¶
Open an issue at github.com/LightJack05/ansible-operator with the resource YAML, the relevant status conditions, and the failing pod logs.