How To Use Ansible For Centos 5 / RHEL 5

Published on Author gryzli

If you try to run some of your playbooks over old Centos/Rhel 5 host, you might be ending with weird message like this: {“changed”: false, “module_stderr”: ” File \”<stdin>\”, line 39\n with open(module, ‘wb’) as f:\n ^\nSyntaxError: invalid syntax\n”, “module_stdout”: “”, “msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”, “rc”: 1} Without going into too… Continue reading How To Use Ansible For Centos 5 / RHEL 5

Tuning Ansible For Maximum Performance

Published on Author gryzli

I hate stuff running slow and I love Ansible.  In this guide, I will share how achieved more than 50x speedup for executing simple ansible playbooks (which are meant to be fast , but they was not ).   Measuring Ansible Tasks Execution Time Before optimizing whatever it is, we should have some good baseline… Continue reading Tuning Ansible For Maximum Performance

Ansible Cheatsheet

Published on Author gryzli

The idea of this post is to make something like a cheatsheet, which I can refer in a future (after I forget almost everything I have learned so far). So I will try to add the most useful things I’ve found about Ansible. Short Ansible Tasks Examples   Task Example Comment

Install nginx with… Continue reading Ansible Cheatsheet

Ansible Debug Print All Variables

Published on Author gryzli

I have written a post about how to debug playbooks by dumping all variables in file (on remote server) by using Ansible template file. Here is some faster and more convenient way to print multiple variables or all with debug purpose inside a playbook. Here are some handy commands for quick dumping of a given… Continue reading Ansible Debug Print All Variables

Ansible Dump All Variables In A File

Published on Author gryzli1 Comment

Sometimes you need all ansible variables for a debugging purpose or just to choose some from it. This is explanation how to make a nice dump of the variables to a file residing on the remote host. If you want to print multiple/all variables in a more convenient way by seeing them directly on the… Continue reading Ansible Dump All Variables In A File

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