Ansible Daily
  • Home
  • About
Konstantin Suvorov

Konstantin Suvorov

Saint-Petersburg, Russia •
14 posts •

Add beauty to long Jinja2 chains

Do you have a long-long Jinja2 expression with chain of filters? Need to scroll screen? Have linter errors about 80+ long lines? Wait no more! Use YAML block scalar syntax: - set_fact:

  • Konstantin Suvorov
    Konstantin Suvorov
1 min read

Define what `diff` means for Ansible task

I was inspired to dig into this topic by this ServerFault question. So you have some Ansible task that supports diff output (e.g. copy). But imagine that you copy files that are

  • Konstantin Suvorov
    Konstantin Suvorov
2 min read

Idempotent shell command in Ansible

Ever wanted to make your command or shell call in Ansible playbook idempotent and avoid those nasty yellow changed lines in run logs? Wait no more! Here's bash trick for you: - name:

  • Konstantin Suvorov
    Konstantin Suvorov
1 min read

Print to standard output without escaping

If you want to print some values during debugging or show some message to user with debug module, you may notice that Ansible outputs JSON-encoded strings. There are some tricks to overcome this.

  • Konstantin Suvorov
    Konstantin Suvorov
1 min read

Process complex variables with set_fact and with_items

Need to process complex data? Like rearranging keys in a list of nested dicts. No problem! You can do it with set_fact, with_items and register. Let's take this list of users

  • Konstantin Suvorov
    Konstantin Suvorov
2 min read

SSH with port knocking

Does your target server require port knocking to enable SSH access? No problem. You can try this handy ssh_pkn connection plugin. It is based on Ansible stock ssh plugin. It tries to

  • Konstantin Suvorov
    Konstantin Suvorov
1 min read

Force "check mode" for single task

Need to run some preparation tasks on your host in case of package update? You can trick Ansible to run single task in check mode to predict the result with check_mode: yes

  • Konstantin Suvorov
    Konstantin Suvorov
1 min read

Idempotent random number

Need a random number for your Ansible playbook? But want to be idempotent on subsequent runs? There is an answer! Let's say you want to register cron jobs on a bunch of servers

  • Konstantin Suvorov
    Konstantin Suvorov
1 min read

Avoid Ansible command warning

Sometimes you need to execute a shell command on remote host, but Ansible gives you an annoying warning, for example: [WARNING]: Consider using service module rather than running service If it is a

  • Konstantin Suvorov
    Konstantin Suvorov
1 min read

Template as variable

If you need to use a template without file generation, there is a handy lookup plugin for you: template. You can use it with lookup function: - debug: msg="{{ lookup('template', 'mytemplate.

  • Konstantin Suvorov
    Konstantin Suvorov
1 min read

Prevent playbook execution without tags

If you have a playbook or a role with extensive tags usage (e.g. install/update/uninstall) and want to prevent its execution without tags (in which case every task will be executed)

  • Konstantin Suvorov
    Konstantin Suvorov
1 min read

Offline docs with ansible-doc

Did you know that you can get Ansible module's documentation with ansible-doc? $ ansible-doc --help Usage: ansible-doc [options] [module...] Options: -h, --help show this help message and exit -l, --list List available modules -M

  • Konstantin Suvorov
    Konstantin Suvorov
1 min read

Execute detached process with Ansible

How to execute long running process on remote host with Ansible? There are several ways to achieve this. Let's look into them: Async task You can use async option for your task with

  • Konstantin Suvorov
    Konstantin Suvorov
1 min read
long-read

Troubleshooting Ansible connection issues

How to handle this: managed-host | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true } or other connection error when

  • Konstantin Suvorov
    Konstantin Suvorov
2 min read
Ansible Daily © 2025
Latest Posts Twitter Ghost