Ajitabh Pandey's Soul & Syntax

Exploring systems, souls, and stories – one post at a time

Tag: ansible

  • Ansible Quirks – 1

    I started on the ansible learning path about 6 months or so back and have been writing my roles for deploying / configuring various systems I manage. Today while writing a template for sshd_config, I came across a point wherein the handler failed to restart the SSH service on the target server. Fortunately I was logged in as sudo on one of the terminals, and then I checked the config file generated and pushed by ansible. I found that the line

    PermitRootLogin {{ permit_root_login }}

    was translated to

    PermitRootLogin True

    . For a while I though that the variable I defined in

    defaults/main.yml

    was wrongly having a value of True instead of Yes, but I was wrong. Looking into some of the bugs filed in ansible I realised that this is the expected behaviour. The way to prevent strings like yes/no and true/false to be converted to True/False they have to be preceded with !!str in the variable definition. So the variable definition in my case would look like –

    permit_root_login: !!str Yes