Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Rajath__S_N
Employee Alumnus
Employee Alumnus

Ansible warnings type (dict) to type ( string)

Hi team,

I am trying to use ansible with Red Hat Enterprise server 8 for a customer. The Playbook created works fine, However i get warnings like the one shown below.

ansible warning.png

I can login to the management server and the objects.

Any workarounds or solutions for this?

 

0 Kudos
5 Replies
Jim_Oqvist
Employee
Employee

Hi,

The warning message you get seems to be because the parameters you wrote for your login command in the playbook is interpreted by the YAML parser as a dictionary, rather than as a string.

I guess that later when Ansible tries to pass the parameters specified in the task to the check_point_mgmt module, since the parameters in the login command is defined as a dictionary, it converts the dictionary to a string and this generates the warning.

Can you try to format your login command like we do in the example on our the cpAnsible GitHub repository to something like this:

- name: "login"
    check_point_mgmt:
      command: login
      parameters:
        username: "{{mgmt_user}}"           # Variables set in /etc/ansible/hosts, to avoid needing
        password: "{{mgmt_password}}"       # to type your login details in every playbook.
        management: "{{mgmt_server}}"
      fingerprint: "XX:XX:XX:XX:XX:XX"      # Mgmt Server's fingerprint
    register: login_response                # Register the output from the login
                                            # command so we can use it later to run commands.

 

Kind Regards
Jim

0 Kudos
Rajath__S_N
Employee Alumnus
Employee Alumnus

the format seems correct.

ansible - play.png

 

0 Kudos
Jim_Oqvist
Employee
Employee

Hi,

I am getting the same warning after updating to the latest check_point_mgmt module from github.

sysadmin@jimo-7480:~/Playbooks/AnsiblePolicyDemo$ ansible-playbook R80-login.yml

PLAY [localhost] **************************************************************************************

TASK [login] ******************************************************************************************
[WARNING]: The value {'username': 'admin', 'management': '172.27.254.10', 'domain': 'nordics',
'password': 'vpn123'} (type dict) in a string field was converted to u"{'username': 'admin',
'management': '172.27.254.10', 'domain': 'nordics', 'password': 'vpn123'}" (type string). If this does
not look like what you expect, quote the entire value to ensure it does not change.

ok: [127.0.0.1]
0 Kudos
Jim_Oqvist
Employee
Employee

Hi,

It seems like it is not the updated module after all.
Thanks to @Ryan_Darst for pointing this out to me, there seems to be a behaviour changes in ansible 2.8 and later.

https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.8.html#module-option-conversi...

Module option conversion to string

Beginning in version 2.8, Ansible will warn if a module expects a string, but a non-string value is passed and automatically converted to a string. This highlights potential problems where, for example, a yes or true (parsed as truish boolean value) would be converted to the string 'True', or where a version number 1.10 (parsed as float value) would be converted to '1.0'. Such conversions can result in unexpected behavior depending on context.

This behavior can be changed to be an error or to be ignored by setting the ANSIBLE_STRING_CONVERSION_ACTION environment variable, or by setting the string_conversion_action configuration in the defaults section of ansible.cfg.

You can add the following the defaults section of ~/.ansible.cfg or /etc/ansible/ansible.cfg

[defaults]
string_conversion_action = ignore

 This is the result I get after adding that to my ~/.ansible.cfg

2019-06-15_21-16-53.jpg

Please note that R&D is currently working on an official (by default included) module for ansible where this should be addressed. 

0 Kudos
Rajath__S_N
Employee Alumnus
Employee Alumnus

Thanks for that!

0 Kudos
Upcoming Events

    CheckMates Events