Ansible Don’t Wait All Hosts To Complete A Task

Published on Author gryzliLeave a comment

Sometimes you don’t want to wait all hosts to complete a task, before going to the next one in Ansible.   For example you have the the following scenario 1) Stop web server 2) Do some magic  (takes different time on different hosts) 3) Start web server   You don’t want your web servers to… Continue reading Ansible Don’t Wait All Hosts To Complete A Task

How To Use Ansible For Centos 5 / RHEL 5

Published on Author gryzliLeave a comment

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 gryzli1 Comment

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 Debug Print All Variables

Published on Author gryzliLeave a comment

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: – name: Execute simple command command: /some/simple/commmand 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 =… 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 # –check –> Only check, don’t apply any changes # -i –> Tell the playbook to use “my_custom_hosts_file” as an inventory list ansible-playbook –check -i my_custom_hosts_file test_job.yml   Ansible ansible-playbook limit playbook execution to a… 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: mkdir ansible_install && cd ansible_install # Clone the source tree git clone git://github.com/ansible/ansible.git # Now make sure to download/update the core modules: cd ansible git submodule update –init –recursive # Install some necessary modules pip install paramiko PyYAML… Continue reading Ansible – Basic installation