Ansible – Dump all variables

Published on Author gryzli1 Comment

Sometimes you need all ansible variables for a debugging purpose or just to choose some from it. Here is an easy way to do this: 1. Add the DUMP task in your main.yml

2. Create the template file “dumpall.j2” with the following content

  3. Finally you can check all dumped variables in… Continue reading Ansible – Dump all variables

Ansible – Failing playbook with Error: AttributeError: ‘str’ object has no attribute ‘format’

Published on Author gryzliLeave a comment

The problem My playbook task was looking like this:

The error persisted even after changing “command:” to “shell:”   If you happen to hit ansible error like this: failed: [some_host] => {“failed”: true, “parsed”: false} Traceback (most recent call last): File “/root/.ansible/tmp/ansible-tmp-1425474902.88-6397676824195/command”, line 129, in ? PARAM_REGEX = re.compile( AttributeError: ‘str’ object has no… Continue reading Ansible – Failing playbook with Error: AttributeError: ‘str’ object has no attribute ‘format’

Ansible – Failing playbook with Error: ansible requires a json module, none found!

Published on Author gryzliLeave a comment

If your ansible-playbook happens to fail with the following error message: Error: ansible requires a json module, none found! Most probably your solution will be to: install “python-simplejson” on the remote host (where ansible-playbook tries to connect) In my case the remote host is running Centos 5.x, but if you are using a different distro,… Continue reading Ansible – Failing playbook with Error: ansible requires a json module, none found!

Ansible Commands

Published on Author gryzliLeave a comment

Here I will describe some ansible related commands, which I use in my day-to-day ansible usage.   ansible-playbook Execute test_job.yml playbook

  Ansible ansible-playbook limit playbook execution to a certain hosts only Sometime you may want to execute a given playbook (or part of it), only on certain hosts. Instead of making different inventory… Continue reading Ansible Commands

Ansible – Basic installation

Published on Author gryzli1 Comment

Here are the very basic steps of getting running copy of Ansible.   Clone ansible from Git:

  Alternatively run ansible from the git cloned directory If you don’t want to make a system wide ansible install, you could run it from the git cloned directory. Here are the commands:

You could make… Continue reading Ansible – Basic installation