ansible-role-yedit icon indicating copy to clipboard operation
ansible-role-yedit copied to clipboard

Error with string value beginning from "!" sign

Open l-e-s opened this issue 5 years ago • 1 comments

I use ansible 2.7.9 (Ansible AWX 4.0.0.0), latest yedit. I found that yedit cannot parse the string if it begins from "!" sign, for example:

somerole/tasks/main.yml

- name: import kwoodson.yedit YAML editor
  import_role:
    name: ansible-role-yedit

- name: Update environment
  yedit:
    src: '{{ deploypath }}/file.yml'
    separator: '|'
    state: present
    edits:
    - { key: a|b, value: '{{ somevalue }}' }

host_vars/somehost somevalue: '!sometext'

I receive an error:

File \"/tmp/ansible_yedit_payload_ECyASG/__main__.py\", line 969, in <module>\r\n  File \"/tmp/ansible_yedit_payload_ECyASG/__main__.py\", line 961, in main\r\n  File \"/tmp/ansible_yedit_payload_ECyASG/__main__.py\", line 889, in run_ansible\r\n  File \"/tmp/ansible_yedit_payload_ECyASG/__main__.py\", line 784, in process_edits\r\n  File \"/tmp/ansible_yedit_payload_ECyASG/__main__.py\", line 775, in parse_value\r\n__main__.YeditException: Could not determine type of incoming value. value=[<type 'str'>] vtype=[]\r\n"

l-e-s avatar May 20 '19 16:05 l-e-s

Old issue but I've found that if you define value_type as str the error should disappear:

- name: import kwoodson.yedit YAML editor
  import_role:
    name: ansible-role-yedit

- name: Update environment
  yedit:
    src: '{{ deploypath }}/file.yml'
    separator: '|'
    state: present
    value_type: str
    edits:
    - { key: a|b, value: '!sometext' }

atodorov-storpool avatar Aug 05 '20 10:08 atodorov-storpool