Ansible Version Migration

Hi Team,

We wrote YAML scripts under the version 1.5.3 and 2.1.1 (virtual environment).

Now, we would like to move to either ansible-2.4 or ansible-2.5

So, what is the way to migrate my code to latest version ? Or do i need write the complete code from scratch ?

Can anyone please suggest me on this ?

Thanks & Regards
Devaraju Gedela

The answers are in the Porting guides.
https://docs.ansible.com/ansible/latest/porting_guides/

Cheers,

  -vlado

Usualy compatibility is quite good...
When going from 1.9 to 2.1, I had quite some porting code to do
From now, change between version is generally deprecated before being obsoleted.

So expect some work for your very old scripts using version 1.5...

Regards,

Hi Devaraju,

It’s best to upgrade to a maintained version. We maintain 3 versions at all times - currently those versions are 2.9, 2.8, and 2.7 - see https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html.

We do not fix bugs in unmaintained versions, so if security vulnerabilities exist in version 2.4 or 2.5, they will not be fixed.

Best wishes,
Alicia

Thanks Alicia for letting us know about maintained versions.

But, While i’m upgrading my scripts from 1.5.3/2.1.1 to 2.9 , Some of the expressions were not getting evaluated successfully.

I found that “%{%d:%Y:%H:%m:%S}t” is not getting evaluated and throwing the error like “ERROR! failed at splitting arguments, either an unbalanced jinja2 block or quotes”

Finally, {%{%d} is not getting evaluated in ansible2.9 bit i’m not sure in rest of the maintained versions.

Could you please help me on this ?

Thanks Alicia for letting us know about maintained versions.

But, While i'm upgrading my scripts from 1.5.3/2.1.1 to 2.9 , Some of the expressions were not getting evaluated
successfully.

I found that "%{%d:%Y:%H:%m:%S}t" is not getting evaluated and throwing the error like "ERROR! failed at splitting
arguments, either an unbalanced jinja2 block or quotes"

Finally, {%{%d} is not getting evaluated in ansible2.9 bit i'm not sure in rest of the maintained versions.

Could you please help me on this ?

Please explain the context of this expressions and what you expect as outcome.

Regards
        Racke

Hi Stefan,

FYI >>>

vars.yml

apache_log_format: '[%{%d/%b/%Y:%H:%M:%S}t.%{msec_frac}t %{%z}t] %a %h \“%r\” ’

  • name: Standardize access log format
    shell:
    sed -i ‘/LogFormat/c LogFormat “rev_proxy@{{ hostname }} {{ apache_log_format }}” common/’ /var/httpd/conf/httpd.conf;

Error:

TASK [Standardize access log format] ******************************************************************************************************************
fatal: [test.local]: FAILED! => {“msg”: "An unhandled exception occurred while templating '\[%{%d\/%b\/%Y:%H:%M:%S}t\.%{msec_frac}t %{%z}t\] %a %h \\"%r\\" '. Error was a <class ‘ansible.errors.AnsibleError’>, original message: template error while templating string: Encountered unknown tag ‘d’… String: \[%{%d\/%b\/%Y:%H:%M:%S}t\.%{msec_frac}t %{%z}t\] %a %h \\"%r\\" "}

Hi Stefan,

FYI >>>

vars.yml

apache_log_format: '\[%{%d\/%b\/%Y:%H:%M:%S}t\.%{msec_frac}t %{%z}t\] %a %h \\"%r\\" '

- name: Standardize access log format
shell:
sed -i '/LogFormat/c LogFormat "rev_proxy@{{ hostname }} {{ apache_log_format }}" common/'
/var/httpd/conf/httpd.conf;

Error:

TASK [Standardize access log format]
******************************************************************************************************************
fatal: [test.local]: FAILED! => {"msg": "An unhandled exception occurred while templating
'\\[%{%d\\/%b\\/%Y:%H:%M:%S}t\\.%{msec_frac}t %{%z}t\\] %a %h \\\\\"%r\\\\\" '. Error was a <class
'ansible.errors.AnsibleError'>, original message: template error while templating string: Encountered unknown tag 'd'..
String: \\[%{%d\\/%b\\/%Y:%H:%M:%S}t\\.%{msec_frac}t %{%z}t\\] %a %h \\\\\"%r\\\\\" "}

Hello Deva,

please use lineinfile module or templating instead of the shell.

Regards
         Racke